Skip to main content
100%

Treemap by Count

✓ Published0🌍 Public
Mmbostock
Last edited Mar 10, 2019
Created on Aug 22, 2016

This treemap displays the hierarchical structure of the Flare dataset, counting each leaf node as equal in size rather than scaling by a numeric value. The visualization uses d3.stratify to build the hierarchy and d3.treemap with a custom sum function that assigns a value of one to non-zero leaves. Each rectangular leaf is rendered as an HTML div, colored by its top-level category using d3.scaleOrdinal with schemeCategory10, and labeled with the node name split across multiple lines.

AI-generated description

This example demonstrates how to create a treemap where each leaf node is treated as having equal value, rather than being sized according to a quantitative property.

In the flare.csv file, leaf nodes (representing class source files) have a non-zero value, while internal nodes (representing packages) have a zero value. Thus, when calling node.sum, any non-zero value can be treated as one:

root.sum(function(d) { return d.value ? 1 : 0; });

If you instead give all nodes a value of one, then one unit of additional space will be reserved for the parent.

gpl-3.0 Licensed

Similar vizzes