Reputation: 13
I want to place rectangles inside partition layout with transform of arc position.
just like below image
D3.js:
svg.selectAll("rect")
.data(node)
.enter()
.append("rect")
.attr("x", function (d) {return d.x;})
.attr("y", function (d) { return d.x + d.dx - 0.01 / (d.depth + 2.6); })
.attr("width", 20)
.attr("height", 100)
.attr("transform", function(d) { return "translate("+arc.centroid(d)+")rotate(" + ((2*Math.PI)+2.6*(d.x + d.dx))+ ")"});
Upvotes: 0
Views: 368
Reputation: 1890
In rect transform ,rotate need to rotate(" + ((d.x + (d.dx / 2)) - Math.PI ) / Math.PI * 180 + ")"
instead of rotate(" + ((d.x + (d.dx / 2)) - Math.PI/2 ) / Math.PI * 180 + ")"
svg.selectAll("rect")
.data(node)
.enter()
.append("rect")
.attr("x", function (d) {return d.x;})
.attr("y", function (d) { return d.x + d.dx - 0.01 / (d.depth + 2.6); })
.attr("width", 20)
.attr("height", 100)
.attr("transform", function(d) { return "translate("+arc.centroid(d)+")rotate(" + ((d.x + (d.dx / 2)) - Math.PI ) / Math.PI * 180 + ")"});
Upvotes: 2