Tag: diagram

如何使用d3.js在Sunburst图表上定位文本标签

我正在尝试将文本放置在基于d3.js的Sunburst图表的楔形内部时遇到问题。即使在缩放时, text元素似乎也没有按照需要定位。 这是我尝试的代码的简短片段,但未成功: var slices = svg.selectAll(“.form”) .data(function(d) { return data_slices; }) .enter() .append(“g”); slices.append(“path”) .attr(“d”, arc) .attr(“id”,function(d,i){return d[2]+””+i;}) .style(“fill”, function(d) { return color(d[2]);}) .on(“click”,animate) .attr(“class”,”form”) .append(“svg:title”) .text(function(d) { return Math.round(d[0]*100)/100 +” , “+ Math.round(d[1]*100)/100; }); //Something needs to change below…. slices.append(“text”) .style(“font-size”, “10px”) .attr(“x”, function(d) { return y(d[1]); }) .attr(“transform”, function(d) { return “rotate(” […]