Spiral Treemap
The spiral treemap visualizes a hierarchy of perfect squares, where each square’s children are the nonzero digits of its value, with color encoding the square’s order. It shows how the spiral layout preserves node order while maintaining near-golden aspect ratios. The example uses D3 v5 with `d3.treemap` and a custom `treemapSpiral` tile function, rendering SVG rectangles and text. Interactive radio buttons re-sort the tree ascending or descending, triggering animated transitions via `transition().duration(750)`, with color scaled by `d3.scaleSequential` and `d3.interpolateRdPu`.
AI-generated descriptionA treemap recursively subdivides area into rectangles; the area of any node in the tree corresponds to its value. This example uses color to encode the order of several perfect squares (the children of each perfect square are the nonzero digits of that perfect square). Treemap design invented by Ben Shneiderman. Spiral treemap algorithm by Tu and Shen.
The spiral treemap layout has several benefits: It preserves the order of the nodes in the tree, and it maintains a good average aspect ratio (close to the golden ratio in this example).