demo D34
Progress and bullet
Completion against a target, with a threshold marker
render: 'progress' | 'bullet'
The configuration
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/lattice-grid.min.css">
<script src="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.13.0/lattice-grid.min.js"></script>
<div id="grid" style="height: 540px"></div>
<script>
const grid = LatticeGrid.createGrid(document.getElementById('grid'), {
rowKey: 'id',
selection: 'multiple',
toolPanel: {
side: 'left',
panels: ['columns', 'filters', 'views', 'quick'],
actions: ['undo', 'redo', 'export', 'restore', 'maximise'],
exportName: 'lattice-demo',
},
columns: [
{ field: 'service', title: 'Service', layout: { pin: 'start', width: 170 } },
{ field: 'team', title: 'Team', filter: { type: 'set' } },
{ field: 'completion', title: 'Migration', type: 'number', layout: { width: 220 },
format: { suffix: '%' }, cell: { render: 'progress' } },
{ field: 'utilisation', title: 'Capacity', type: 'number', layout: { width: 220 },
format: { suffix: '%' },
// The variant is the renderer's own, not a decoration's: it selects a
// theme token and never carries a colour.
cell: { render: 'progress', props: { variant: 'warning' } } },
{ field: 'attainment', title: 'Against plan', type: 'number', layout: { width: 240 },
format: { suffix: '%' },
// Bands shade the background: poor below 60, acceptable to 90, good
// beyond. The tick is the target.
cell: { render: 'bullet', props: { min: 0, max: 120, bands: [60, 90], target: 85 } } },
{ field: 'target', title: 'Target', type: 'number', layout: { width: 110 }, format: { suffix: '%' } },
{ field: 'cost', title: 'Monthly cost', type: 'number', layout: { width: 150 },
format: { style: 'currency', currency: 'USD' }, total: 'sum' },
],
rows, // rendering demo rows
});
</script>
Showing completion against a target with progress and bullet renderers
A progress renderer draws a filled bar against a maximum, the shape behind storage usage, project completion and quota consumption, anything where a single number only makes sense next to its ceiling. A bullet renderer covers the case one step up: a value plotted against a target with a threshold marker crossing it, the pattern KPI dashboards use to show a metric against a goal rather than an empty range. A developer reaches for either when a bare number in a cell would force a reader to do the comparison in their head. Lattice Grid selects between them with render: 'progress' | 'bullet' on the column definition, and the bullet variant takes the extra threshold value as a second field so the marker moves independently of the bar. Both are drawn with CSS widths and a couple of absolutely positioned spans rather than SVG or canvas, so a column of bars in a JavaScript data grid repaints on scroll and resize at the same cost as any other cell content, with no separate chart library loaded for what is, visually, two rectangles and a line. Colour and threshold are read per row, so a bar can flip from a pass colour to a warning colour the moment its row crosses the marker, without a second pass over the data.
How do you show a value against a target in a data grid column?
Set render: 'bullet' on the column and supply both the value field and a threshold field; Lattice Grid draws the value as a bar and the threshold as a marker line crossing it, so a reader compares the two at a glance. Use render: 'progress' instead when there is a maximum but no separate threshold to mark, such as storage used out of a quota.