demo D34
Progress and bullet
Completion against a target, with a threshold marker
render: 'progress' | 'bullet'
The configuration
import * as ng from '@angular/core';
import { Component } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import createLatticeGrid from '@toclocoinc/lattice-grid/modules/angular';
const { LatticeGridComponent } = createLatticeGrid({ ng, createGrid });
// progress draws a length; bullet draws a length with an opinion about what
// good looks like, which is the reason to reach for it.
const 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' } },
// The variant is the renderer's own: it selects a theme token and never
// carries a colour of its own.
{ field: 'utilisation', title: 'Capacity', type: 'number', layout: { width: 220 },
format: { suffix: '%' }, cell: { render: 'progress', props: { variant: 'warning' } } },
// Bands shade the background: poor below 60, acceptable to 90, good beyond.
// The tick is the target.
{ field: 'attainment', title: 'Against plan', type: 'number', layout: { width: 240 },
format: { suffix: '%' }, 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' },
];
const rows = [/* service records, one object per service */];
@Component({
selector: 'app-root',
standalone: true,
imports: [LatticeGridComponent],
template: '<lattice-grid [config]="grid" style="display:block;height:540px"></lattice-grid>',
})
export class AppComponent {
grid = {
rowKey: 'id',
selection: 'multiple',
toolPanel: { side: 'left', panels: ['columns', 'filters', 'views', 'quick'],
actions: ['undo', 'redo', 'export', 'restore', 'maximise'], exportName: 'lattice-demo' },
columns: columns,
rows: rows,
};
}
bootstrapApplication(AppComponent);
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.