Skip to content

Stacked Bar Chart

ts
StackX({ spacing: 8, sharedScale: true },
  For(groupBy(seafood, "lake"), (lake, key) =>
    StackY({ key, spacing: 0 },
      For(lake, (d) =>
        Rect({ w: 32, h: v(d.count), fill: v(d.species) }))))
).render(root, { w: 500, h: 300, axes: true });

Live Editor

import "./styles.css";

document.getElementById("app").innerHTML = `
<h1>Hello world</h1>
`;