0

Additional question to the answer found here: Truncate text in d3

.text(function (d) {
 if(d.name.length > 5)
     return d.name.substring(0,5)+'...';
 else
     return d.name;                       
 });

I'd like to add a condition where if the text is a label in the outermost ring of a bilevel partition chart, the text is no longer truncated.

Possible solution would be to add something like: if outermost ring is clicked, redraw the text.

Edit: Sorry I forgot to mention that this condition should only happen if the outermost ring is clicked. So initially the text is truncated, and when the outermost ring is zoomed in, the truncation is removed.

inside function click(d):
    if d.depth >= 3 {
        modify firstLine, remove code that shortens the text
    }
    else if other d.depth is clicked { 
        keep/revert back to the same code
    }
Community
  • 1
  • 1

1 Answers1

0

you'll need to check your data for outermost level and add a check in the same code. or you can add an extra attribute to ur dataset (Say: level), and assign it to be (root). You'll also need to add an identifier(id or class) to each element/text.

UPDATED

.on("click", function (d) {
 if(d.level == 'root')
     d3.select("#ID").text(d.label);
 });
Taran J
  • 805
  • 6
  • 10
  • sorry for the confusion. i made a mistake with my question and modified it. but i'll still check your answer to see if i can work with that. – Tactician Jenro Jun 13 '16 at 15:52