Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3: Avoid unchanged nodes?

When passsing data through d3.js, the library divides the data into enter/update/exit components, but I've found that we waste a good deal of computation in the update section for values that are unchanged by re-computing and re-setting the attributes to the same value which is already current.

Is there any good way to further divide the "updated" set into changed/unchanged sets?

like image 633
bukzor Avatar asked Nov 13 '22 06:11

bukzor


1 Answers

You could do another selection on your update selection. That is, call .selectAll() again with a selector that gets you only the things that need to be updated. This of course assumes that you can produce such a selector. One approach might be to do everything through CSS classes and set no attributes in the code itself. Then you could select based on the CSS class.

Apart from that, there's nothing you can really do. The whole idea behind D3 is that the visualisation is determined by the data and if the data is unchanged, the visual elements remain unchanged as well.

like image 154
Lars Kotthoff Avatar answered Nov 15 '22 04:11

Lars Kotthoff