I am in an early stage of the JS project. So far, everything is going well, except for positioning one piece. The sample in question is a teal diamond (square rotation of 45 degrees). I can get a square on the screen without problems, but when I add:
.attr("transform", "rotate(45)")
the square rotates correctly, but moves to the left of the screen, for example:

I am not sure what causes this. If this helps, here are some of the code that gave this result:
var svg = d3.select("body") .append("svg") .attr("width", w) .attr("height", h); svg .append("rect") .attr("transform", "rotate(45)") .attr("x", 250) .attr("height", w / 10) .attr("width", w / 10) .attr("fill", "teal")
Note. If I insert the attribute "y", the square disappears completely.
What causes this? I did something wrong that I just canβt see?
1080p
source share