I recently built a chart with d3.js where users can drill down by clicking on the different slices to see the sub-slices. I had to use recursion and a tree-like structure. Luckily I discovered that d3 gives you a hierarchy function (https://d3js.org/d3-hierarchy/hierarchy) that takes a structure like the example data structure you shared, and returns a tree of nodes with some very useful stuff. Things like the depth, a reference to the parent node, and multiple methods to get the ancestors, the shortest path between two nodes, etc. It was fun!
That sounds pretty fun, yeah I have used d3 quite often a few years back and it’s really good at data visualization in general. Not sure how good it is recently for building React applications, I heard it has some recent changes regarding adopting the virtual dom stuff but haven’t got a chance to look deeper.
I recently built a chart with d3.js where users can drill down by clicking on the different slices to see the sub-slices. I had to use recursion and a tree-like structure. Luckily I discovered that d3 gives you a hierarchy function (https://d3js.org/d3-hierarchy/hierarchy) that takes a structure like the example data structure you shared, and returns a tree of nodes with some very useful stuff. Things like the depth, a reference to the parent node, and multiple methods to get the ancestors, the shortest path between two nodes, etc. It was fun!
That sounds pretty fun, yeah I have used d3 quite often a few years back and it’s really good at data visualization in general. Not sure how good it is recently for building React applications, I heard it has some recent changes regarding adopting the virtual dom stuff but haven’t got a chance to look deeper.
Thanks, that’s good to know