demo D228
Confidence intervals, charted: JavaScript Data Grid Demo
The mean lead time of each supplier with its 95% interval as a whisker, and a tile that narrows as you filter
grid.statistics.interval(col) · chart error: true
This grid charts each supplier's mean lead time with its 95 percent interval as a whisker, and a tile that narrows as you filter. It shows not just the average but how sure of it you can be, so a difference within the noise does not read as real.
Loading a live grid…
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.css">
<script src="https://cdn.latticegrid.dev/lattice-grid@1.103.2/lattice-grid.min.js"></script>
<div id="grid" style="height: 340px"></div>
<div id="chart" style="height: 250px; margin-top: 14px"></div>
<div id="tiles" style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0"></div>
<script type="module">
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
toolPanel: { side: 'left', panels: ['filters', 'columns', 'statistics'] },
columns: [
{ field: 'supplier', title: 'Supplier', filter: { type: 'set' } },
{ field: 'days', title: 'Lead time', type: 'number', format: { suffix: ' d', decimals: 1 }, total: 'avg' },
],
rows, // e.g. [{ id: 'O0', supplier: 'Kestrel', days: 3.1 }, ...]
});
LatticeGrid.createStat({
grid, container: document.getElementById('tiles').appendChild(document.createElement('div')),
title: 'Mean lead time', of: 'days', fn: 'avg',
interval: (value, g) => g.statistics.interval('days'), footer: '95% confidence interval',
});
// error: true draws each mean's interval as a whisker, computed from the
// readings behind the bar. The chart reads the same grid as the tile, so
// the bars and the whiskers follow the filters.
createChart({
grid, container: document.getElementById('chart'), type: 'bar',
x: 'supplier', y: { col: 'days', fn: 'avg' }, error: true,
title: 'Mean lead time by supplier, with confidence interval',
});
</script>