[英]How to transform and rotate the rectangles on partition layout in d3.js
I want to place rectangles inside partition layout with transform of arc position. 我想通过弧形位置的转换在分区布局中放置矩形。 just like below image 就像下面的图片
D3.js : 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))+ ")"});
In rect transform ,rotate need to rotate(" + ((dx + (d.dx / 2)) - Math.PI ) / Math.PI * 180 + ")"
instead of rotate(" + ((dx + (d.dx / 2)) - Math.PI/2 ) / Math.PI * 180 + ")"
在rect变换中,rotate需要rotate(" + ((dx + (d.dx / 2)) - Math.PI ) / Math.PI * 180 + ")"
而不是rotate(" + ((dx + (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 + ")"});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.