2
我想根据某些数据旋转矩形。用下面的代码,旋转适用于整行。我怎样才能让每个“矩形”都有自己的轮换应用,并保持在同一条线上?在D3.js中旋转对象
let canevas = d3.select("body")
.append("svg")
.attr("width", 1000)
.attr("height", 1000);
let rectangles = d3.select("svg")
.selectAll("rect")
.data([10, 20, 30, 40])
.enter()
.append("rect")
.attr("x", (d, i) => (i * 30) + 30)
.attr("y", 20)
.attr("width", 20)
.attr("height", 20)
.attr("transform", (d) => `rotate(${d})`);