demo D259
Icicle: JavaScript Data Grid Demo
A hierarchy as nested bars, each band as wide as the share of the total beneath it
type: 'icicle', y
This draws a hierarchy as nested bars, each band as wide as the share of the total beneath it. It shows how a total breaks down through levels, so where the weight sits in a tree reads as width.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.108.1/lattice-grid.min.js"></script>
<div id="grid" style="height: 340px"></div>
<div id="chart" style="height: 340px"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
import '@toclocoinc/lattice-grid/modules/chart-icicle'; // opt in to the icicle type
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
columns: [
{ field: 'region', title: 'Region', group: { enabled: true, index: 0 } },
{ field: 'status', title: 'Status', group: { enabled: true, index: 1 } },
{ field: 'charge', title: 'Monthly charge', type: 'number',
format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
],
// The icicle reads the grid's group tree, so keep the groups folded.
group: { expanded: false },
rows, // circuits: region, status, charge
});
createChart({
grid,
container: document.getElementById('chart'),
type: 'icicle',
y: 'charge',
title: 'Charge by region, then status',
});
</script>