Lattice Grid

blog

Gauge Chart of Warehouse Utilisation

Building…
Loading a live grid…

If you run an operations board, the question you are asked every morning is how full each warehouse is, and whether it is full enough to worry about. The answer is a percentage per zone in a table, but a column of numbers does not tell you which side of a threshold you are on.

A gauge chart answers that. One needle reads the current figure against bands you set: green while there is room, amber when it is busy, red when it is nearly full. The chart above is bound to the grid beneath it, one row per warehouse zone, so filtering the rows redraws the chart. Filter the Warehouse column to one site and the needle moves to the average of its zones.

Why a gauge and not a bar chart

A bar chart shows many figures side by side and leaves you to remember where the limit is. A gauge shows one figure and draws the limit into the dial, so a reading that has crossed into the red is obvious without a legend or a second look. It suits a single number that matters against a threshold, which is what a utilisation board is.

The chart over a grid

The gauge reads one figure from the rows it is bound to. The y option names the utilisation column and reduces it with avg, so the needle shows the mean of the rows left after a filter, not their total. The bands option shades the dial, and needle swaps the filled arc for a pointer that takes the colour of the band it sits in. Gauge is built in, so there is no extra module to import. Here is the example in plain JavaScript, with sample rows inline in place of your own.

import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';

const rows = [
  { id: 1, warehouse: 'North hub', zone: 'Inbound', utilisation: 92 },
  { id: 2, warehouse: 'North hub', zone: 'Picking', utilisation: 90 },
  { id: 3, warehouse: 'South hub', zone: 'Inbound', utilisation: 64 },
  { id: 4, warehouse: 'South hub', zone: 'Picking', utilisation: 69 },
  { id: 5, warehouse: 'West depot', zone: 'Inbound', utilisation: 45 },
  { id: 6, warehouse: 'West depot', zone: 'Picking', utilisation: 47 },
];
const gridEl = document.createElement('div');
const chartEl = document.createElement('div');
gridEl.style.height = '240px';
chartEl.style.height = '400px';
document.body.append(gridEl, chartEl);

const grid = createGrid(gridEl, {
  rowKey: 'id', rows,
  columns: [
    { field: 'warehouse', title: 'Warehouse', filter: { type: 'set' } },
    { field: 'zone', title: 'Zone' },
    { field: 'utilisation', title: 'Utilisation', type: 'number', format: { decimals: 0, suffix: '%' } },
  ],
});
createChart({ grid, container: chartEl, type: 'gauge', x: 'zone',
  y: { col: 'utilisation', fn: 'avg' }, min: 0, max: 100, needle: true,
  bands: [{ from: 0, to: 70, colour: '#43a047' }, { from: 70, to: 90, colour: '#ffb300' },
    { from: 90, to: 100, colour: '#e53935' }],
  ticks: [0, 50, 70, 90, 100], centre: { label: 'Average utilisation' } });

The same thing in React

The React adapter is a factory, so you build the component once at module scope. The ref’s grid is the real grid, which is what the chart binds to.

import React, { useEffect, useRef } from 'react';
import { createGrid } from '@toclocoinc/lattice-grid';
import '@toclocoinc/lattice-grid/css';
import { createLatticeGrid } from '@toclocoinc/lattice-grid/modules/react';
import { createChart } from '@toclocoinc/lattice-grid/modules/charts';

const LatticeGrid = createLatticeGrid({ React, createGrid });
const rows = [
  { id: 1, warehouse: 'North hub', zone: 'Inbound', utilisation: 92 },
  { id: 2, warehouse: 'South hub', zone: 'Inbound', utilisation: 64 },
  { id: 3, warehouse: 'West depot', zone: 'Inbound', utilisation: 45 },
];
const columns = [
  { field: 'warehouse', title: 'Warehouse', filter: { type: 'set' } },
  { field: 'utilisation', title: 'Utilisation', type: 'number' },
];
const bands = [{ from: 0, to: 70, colour: '#43a047' }, { from: 70, to: 90, colour: '#ffb300' },
  { from: 90, to: 100, colour: '#e53935' }];

export function UtilisationBoard() {
  const gridRef = useRef(null);
  const chartRef = useRef(null);
  useEffect(() => {
    const chart = createChart({ grid: gridRef.current.grid, container: chartRef.current,
      type: 'gauge', x: 'warehouse', y: { col: 'utilisation', fn: 'avg' },
      min: 0, max: 100, needle: true, bands });
    return () => chart.destroy();
  }, []);
  return (<>
    <LatticeGrid ref={gridRef} rowKey="id" columns={columns} rows={rows}
      style={{ height: 200 }} />
    <div ref={chartRef} style={{ height: 360 }} />
  </>);
}

The options used

These are the rows of the charts reference for the options in the listings above.

Option Type What it does
grid Grid Required. The grid to read.
container Element or string Required. Where to draw.
type string 'gauge' here, one figure read against a dial.
x string The category column.
y string or { col, fn } The measure column. With fn it reduces every row the gauge is bound to: sum, avg, min, max and the rest.
min / max number Fix the measure axis rather than taking it from the data.
bands { from, to, colour?, label? }[] Threshold bands behind the value, clipped to min and max and drawn in order.
needle boolean or { width?, pin? } Draw a pointer instead of the filled value arc. It takes the colour of the band the value falls in.
ticks number or array Tick values drawn round the arc. Values outside min and max are dropped.
centre { label? } A gauge reads label as its caption.

Reading the board

Look at the colour of the needle first, then at the rows behind it. An average can sit comfortably in the amber while one zone is in the red, so filter the Band column to Near full to see which zones are driving it. A value outside min and max is held at the end of the dial while the tooltip keeps the real number.

Next

See gauges beside the other specialist charts in the specialist charts family demo, read the full list of chart types on the charts page, or follow the how-to for a chart that follows the grid.

Read next

  • Funnel Chart for a Sales Pipeline

    Bind a funnel chart to a grid of pipeline counts: leads, qualified, proposal, won. Filter the rows by region to redraw the drop at each stage.

  • Radar Chart for Supplier Scorecards

    Bind a radar chart to a grid of supplier scores: one spoke per criterion, one shape per supplier. Filter the rows to redraw it.

  • Force Tree Chart of Service Dependencies

    Bind a force tree chart to a grid of services and what each depends on, the hub at the centre. Filter the rows and the map redraws.

All posts RSS