Lattice Grid Buy a licence

demo D34

Progress and bullet

Completion against a target, with a threshold marker

render: 'progress' | 'bullet'

Building…
Loading a live grid…

The configuration

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.min.css">

<div id="grid"></div>

<script type="module">
  import React from 'https://esm.sh/react@18';
  import { createRoot } from 'https://esm.sh/react-dom@18/client';
  import { createGrid } from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/lattice-grid.esm.min.js';
  import createLatticeGrid from 'https://cdn.jsdelivr.net/npm/@toclocoinc/lattice-grid@1.27.0/modules/react.esm.min.js';

  const LatticeGrid = createLatticeGrid({ React, 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 */];

  function App() {
    return (
      <LatticeGrid
        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}
        style={{ height: '540px' }}
      />
    );
  }

  createRoot(document.getElementById('grid')).render(<App />);
</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.