demo D165
Pie, donut, sunburst, treemap
Composition, flat and hierarchical
type: 'pie' · 'donut' · 'sunburst' · 'treemap'
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
<script type="module">
import { defineLatticeGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/webcomponent.esm.js';
defineLatticeGrid();
</script>
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; height: 210px">
<div id="pie"></div>
<div id="donut"></div>
<div id="sunburst"></div>
<div id="treemap"></div>
</div>
<lattice-grid row-key="id" style="display: block; height: 340px; margin-top: 14px"></lattice-grid>
<script type="module">
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';
const el = document.querySelector('lattice-grid');
el.config = {
columns: [
{ field: 'circuit', title: 'Circuit', layout: { width: 180 } },
{ field: 'region', title: 'Region', filter: { type: 'set' } },
{ field: 'status', title: 'Status', filter: { type: 'set' } },
{ field: 'bandwidth', title: 'Bandwidth', type: 'number' },
{ field: 'charge', title: 'Monthly charge', type: 'number',
format: { style: 'currency', currency: 'GBP' }, total: 'sum' },
],
};
el.rows = rows; // an array of circuit records
// Each chart reads el.grid, the live grid inside the element, so filtering or
// sorting the table redraws them all.
createChart({ grid: el.grid, container: '#pie', type: 'pie', x: 'status', y: 'charge' });
createChart({ grid: el.grid, container: '#donut', type: 'donut', x: 'status', y: 'charge' });
createChart({ grid: el.grid, container: '#sunburst', type: 'sunburst', x: 'region', y: 'charge' });
createChart({ grid: el.grid, container: '#treemap', type: 'treemap', x: 'region', y: 'charge' });
</script>