demo D178
Charts with no grid on screen
The data engine driving charts on its own
createHeadlessGrid
Loading a live grid…
The configuration
<script>
import { createHeadlessGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/charts.esm.min.js';
import { onMount } from 'svelte';
let byRegionEl;
let byStatusEl;
let distributionEl;
const config = {
rowKey: 'id',
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' },
],
rows, // an array of circuit records
};
// No visible table: createHeadlessGrid is the data engine on its own, and
// every chart draws from it, with the same follow behaviour.
onMount(() => {
const grid = createHeadlessGrid(config);
createChart({ grid, container: byRegionEl, type: 'bar', x: 'region', y: 'charge' });
createChart({ grid, container: byStatusEl, type: 'donut', x: 'status', y: 'charge' });
createChart({ grid, container: distributionEl, type: 'histogram', y: 'charge' });
return () => grid.destroy();
});
</script>
<svelte:head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">
</svelte:head>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; height: 260px">
<div bind:this={byRegionEl}></div>
<div bind:this={byStatusEl}></div>
<div bind:this={distributionEl}></div>
</div>