vasturiano / sunburst-chart

A sunburst interactive chart web component for visualizing hierarchical data
https://vasturiano.github.io/sunburst-chart/example/flare/
MIT License
288 stars 89 forks source link

get the tooltip value inside onClick #84

Open samuira opened 2 years ago

samuira commented 2 years ago

How can I get the tooltip value when we clicked on any node? can you show a example code? function clicked(d){ if (d.children){ sunburst_chart.focusOnNode(d) }else { // get the tooltip value like ( A -> B -> C) }

}

vasturiano commented 2 years ago

@samuira the node's data is included in the onClick method. This data object has a convenience attribute called __dataNode which includes links to all the children and parent nodes. By iterating over the parent link chain you'll be able to extract all the stack until the root, giving you what you're looking for.