-
vizulySeptember 18, 2017 at 9:05 am #8052
Hello Pretty,
The Tree supports a label function in viz.label(); You can pass in your own function that will determine how to trim labels. For instance for your use case you may do something like this:
viz.label(function (d) {
if (d.children) {
return String(d.myLabel).substr(0,5);
}
});I hope that helps to point you in the right direction. Also you can adjust he spacing between branches by adjusting the size of the tree or adjust the span between nodes by explicitly setting viz.fixedSpan(mySpanInPixels).
Cheers,
Tom
preety.sehrawatSeptember 18, 2017 at 9:33 am #8053Hi Tom,
Thank you so much i have tried
viz.label(function (d) {
if (d.children) {
return trimLabel(d.key); // where trimLabel is trimming my label if its length is 15 or greater than it
}
});but it didn’t really help. After applying it my labels are not visible now.
Please suggest am i doing anything wrong?Regards
PreetyvizulySeptember 18, 2017 at 10:22 am #8054Hello Pretty,
Oops, I forgot the else part of the if clause.
viz.label(function (d) { if (d.children) { return trimLabel(d.key); } else { return d.key } });
This function will format a label for each node based on the logic you write.
– Tom
-
|
You must be logged in to reply to this topic.