Squarified Treemap

A treemap is a visualization technique based on containment that partitions the space recursively according to the size of the subtrees. It is space-filling, where leaf nodes are clearly visualized.

The Squarified Algorithm

Advantages

The Algorithm

Given a rectangle with height \(h\) and large enough, the squarified algorithm draws \(n\) areas \(a_1, \dots, a_n\) within the rectangle representing the leaves of the tree. These areas should be as square as possible and have the same width. Therefore, it follows:

\[ \begin{align} h_1 \times w &= a_1\\ ...& \\ h_n \times w &= a_n \end{align} \]

where \(w\) is the width of the inserted triangles. Tthe following relations for the height and the width of the inserted rectangles apply: \[ (h_1 + \dots + h_n)\times w = (a_1 + \dots + a_n) = a \quad \implies w = \frac{a}{h}, \quad \text{width} \; h = h_1 + \dots h_n \]

The height of an inserted rectangle is given by \(h_i = \frac{a_i}{a} h\). The aspect ratio, height over width, of the \(ith\)-rectangle is:

\[ \frac{h_i}{w} = \frac{a_i}{w^2} = \frac{a_i h^2}{a^2} \]

If the aspect ratio is computed as width over height, one gets \(\frac{a^2}{a_i h^2}\).

Main Loop

Layout of Sibling Nodes

Note: the algorithm refers to rows, even if the drawing area is split vertically.

Remarks



The JavaScript Code