Update treemap text for each node
See original GitHub issueHello!
I’m working with the treemap
diagram and I need to update color and text for each node without re-drawing the entire diagram. I only was able to update the color and I’m not sure how to update the text.
This is my CodePen example: https://codepen.io/elv1s42/pen/yLydprX
I’ve tried both update
and restyle
functions and read the documentation here: https://plot.ly/javascript/plotlyjs-function-reference/#plotlyreact but didn’t find the examples of how text can be updated.
var upd = {
marker: {colors: ['white', 'orange', 'green', 'red']},
text: ['t1', 't2', 't3', 't4'] // how to update the text?
};
Plotly.update('myDiv', upd);
//Plotly.restyle('myDiv', upd);
Please help me to resolve the issue. Thank you.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Plotly.js: update text of each node using restyle - Stack Overflow
So the working solution is to use nested arrays for the text field: ... 'red']}, text: [['t1', 't2', 't3', 't4']] // how to...
Read more >Treemap charts in Python - Plotly
Treemap charts visualize hierarchical data using nested rectangles. The input data format is the same as for Sunburst Charts and Icicle Charts: the ......
Read more >How to Make a Treemap in Python - Towards Data Science
A treemap is a visualization used to display hierarchical data. ... The labels list correspond to the text displayed for each node.
Read more >Day 10 - Treemap / Tyler Wolf - Observable
Each leaf node has a name and a value attached to it. With this data, we'll use a treemap to visualize how much...
Read more >Create a Treemap Using d3 and React With Wrapping SVG Text
The 'each' method will allow us access to each node within that selection. In our case that selection will contain every 'g' element...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So @elv1s42
should work.
To improve performance, I suggest calling
that way, you only update the marker colors and the text (as opposed to all the marker attributes and the text).
Here’s a working version: https://codepen.io/etpinard/pen/BaygOXo?editors=0010
Remember that the outer array in restyle/update calls maps to trace indices and the inner array maps to data indices.