Stalactite plots

Hierarchical data with two quantities per node: an additive one (here sales — a parent is the sum of its children) and a proportional one (here profit margin — a parent is the average of its children, weighted by sales).

Make one from your own CSV file →

How to read it

Usage

import { stalactitePlot } from "d3-stalactite";

d3.select("svg").call(stalactitePlot, {
  data,                      // {name, children} … leaves {name, add_val, ratio_val}
  width: 960,
  height: 500,
  valueNames: ["Sales", "Profit margin"],
});

// Or just the layout, in the style of d3.treemap():
import { stalactite } from "d3-stalactite";
const { nodes, lines } = stalactite().size([960, 500])(data);