0

I am building my own sunburst diagram from this example by adding multiline captions as .

for(i = 0; i < MAX_LINES; i++){

 var text = g.append("text")
.attr("transform", function(d) { return "translate(" + getCentroid(d) + ")rotate(" + textRotation(d) + ")"; })
.attr('text-anchor', function (d) { return textRotation(d) > 180 ? "end" : "start"; })
.attr("dx", "0") 
.attr("dy", "0em")
.attr("class", function(d) { return setStyle(d); })
.style("fill", function(d) { return setColor(d); }) 
.style("text-anchor", "middle")
.append("tspan")
.attr("dy", function(d) { return getDY(d, i); } )
.text(function(d) { return getLine(d, i); });
//.text(function(d) { return d.name; });

}

This works absolutely fine on initial state, but when you are zooming it by clicking on certain partition everything becomes messy. The script only moves first line element and doesn't hide other elements shouldn't be on screen.

.duration(500)
.attrTween("d", arcTween(d))
.each("end", function(e, i) {
if (e.x >= d.x && e.x < (d.x + d.dx)) {

var arcText = d3.select(this.parentNode).select("text");

arcText.transition().duration(750)
.attr("opacity", 1)
.attr("transform", function(d) { return "translate(" + getCentroid(d) + ")rotate(" + textRotation(d) + ")"; })
.attr('text-anchor', "middle")


}
});
}
});

How I can transform for every partition? I have tried to do selection by "tspan" or its style class.

Is it possible to completely renew block by reassigning name and recreating 's

VVK
  • 435
  • 2
  • 27
  • You haven't included enough code to really answer this question (a re-producible example would be nice) but looking at your `for` loop, it looks like you are appending a new `text` element for each line in a text block. Instead, you should be appending a single `text` element with multiple `tspan` elements nested below it. – Mark Dec 07 '16 at 15:17
  • 1
    Thanks, actually you have managed to help me. Cheers! – VVK Dec 07 '16 at 18:27

0 Answers0