demo D167
Gauge, funnel and radar
The specialist types and what each is for
type: 'gauge' · 'funnel' · 'radar'
Loading a live grid…
The configuration
<script>
import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.esm.min.js';
import createLatticeAction from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/svelte.esm.min.js';
import { createChart } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/modules/charts.esm.min.js';
const lattice = createLatticeAction({ createGrid });
let gaugeEl, funnelEl, radarEl;
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
// onGrid hands over the live grid the moment it is created. A gauge reads one
// measure, y; funnel and radar read x and y. All three follow the grid's
// filters and sort.
onGrid: (grid) => {
createChart({ grid, container: gaugeEl, type: 'gauge', y: 'charge' });
createChart({ grid, container: funnelEl, type: 'funnel', x: 'status', y: 'charge' });
createChart({ grid, container: radarEl, type: 'radar', x: 'region', y: 'charge' });
},
};
</script>
<svelte:head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.28.0/lattice-grid.min.css">
</svelte:head>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; height: 240px">
<div bind:this={gaugeEl}></div>
<div bind:this={funnelEl}></div>
<div bind:this={radarEl}></div>
</div>
<div use:lattice={config} style="height: 340px; margin-top: 14px"></div>