Lattice Grid

blog

Bump Chart for Product Rank by Quarter

Building…
Loading a live grid…

If you are a category manager, the question you bring to the quarterly numbers is who overtook whom. Which product moved up into the top spot, which one slipped, and in which quarter it happened. A table of units sold makes you work out the order in your head, quarter after quarter.

A bump chart answers it with lines. Each product gets a line that runs across the quarters, and its height at each quarter is its rank, so first place is at the top. Where two lines cross, two products have swapped places. The chart above is bound to the grid beneath it, one row per product and quarter, so filtering the rows redraws the lines. Filter the Product column to compare just two products and see the ranks worked out again from the rows that are left.

Why a bump chart and not a line chart

A line chart of units sold shows how much each product sold, so a product that grows slowly can look like it is climbing while it is being passed by a faster one. The bump chart throws the amounts away and keeps only the order. Every quarter has the same spacing from first to last, so a crossing is a change of place and nothing else.

The chart over a grid

Name the quarter column in x, the product column in series and the measure in y. You do not store a rank column: the chart ranks the products within each quarter by that measure, the highest first. Bump is an opt-in chart type, so you import its module once after the charts module. 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';
import '@toclocoinc/lattice-grid/modules/chart-bump';

const rows = [
  { id: 1, product: 'Atlas', quarter: '2025 Q1', units: 410 },
  { id: 2, product: 'Atlas', quarter: '2025 Q2', units: 395 },
  { id: 3, product: 'Atlas', quarter: '2025 Q3', units: 380 },
  { id: 4, product: 'Atlas', quarter: '2025 Q4', units: 350 },
  { id: 7, product: 'Beacon', quarter: '2025 Q1', units: 380 },
  { id: 8, product: 'Beacon', quarter: '2025 Q2', units: 400 },
  { id: 9, product: 'Beacon', quarter: '2025 Q3', units: 420 },
  { id: 10, product: 'Beacon', quarter: '2025 Q4', units: 430 },
  { id: 13, product: 'Cinder', quarter: '2025 Q1', units: 350 },
  { id: 14, product: 'Cinder', quarter: '2025 Q2', units: 360 },
  { id: 15, product: 'Cinder', quarter: '2025 Q3', units: 370 },
  { id: 16, product: 'Cinder', quarter: '2025 Q4', units: 390 },
];
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: 'product', title: 'Product', filter: { type: 'set' } },
    { field: 'quarter', title: 'Quarter' },
    { field: 'units', title: 'Units sold', type: 'number' },
  ],
});
createChart({ grid, container: chartEl, type: 'bump', x: 'quarter', series: 'product',
  y: 'units', title: 'Product rank by quarter' });

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';
import '@toclocoinc/lattice-grid/modules/chart-bump';

const LatticeGrid = createLatticeGrid({ React, createGrid });
const rows = [
  { id: 1, product: 'Atlas', quarter: '2025 Q1', units: 410 },
  { id: 2, product: 'Atlas', quarter: '2025 Q2', units: 395 },
  { id: 3, product: 'Atlas', quarter: '2025 Q3', units: 380 },
  { id: 4, product: 'Atlas', quarter: '2025 Q4', units: 350 },
  { id: 7, product: 'Beacon', quarter: '2025 Q1', units: 380 },
  { id: 8, product: 'Beacon', quarter: '2025 Q2', units: 400 },
  { id: 9, product: 'Beacon', quarter: '2025 Q3', units: 420 },
  { id: 10, product: 'Beacon', quarter: '2025 Q4', units: 430 },
];
const columns = [
  { field: 'product', title: 'Product', filter: { type: 'set' } },
  { field: 'quarter', title: 'Quarter' },
  { field: 'units', title: 'Units sold', type: 'number' },
];

export function ProductRank() {
  const gridRef = useRef(null);
  const chartRef = useRef(null);
  useEffect(() => {
    const chart = createChart({ grid: gridRef.current.grid, container: chartRef.current,
      type: 'bump', x: 'quarter', series: 'product', y: 'units' });
    return () => chart.destroy();
  }, []);
  return (<>
    <LatticeGrid ref={gridRef} rowKey="id" columns={columns} rows={rows} style={{ height: 240 }} />
    <div ref={chartRef} style={{ height: 400 }} />
  </>);
}

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 'bump' here, one line per series, riding its rank.
x string The quarter column, one position across per distinct value.
series string Splits the measure into one series per distinct value, here one per product.
y string The measure column the products are ranked by within each position.
title string Drawn above the plot.

Reading the lines

Start at the right edge and trace each line back. In the example, Beacon is first in the last quarter and was first from the second quarter on, after Atlas had led the first. Atlas is the product to look at next: it starts in first place and ends in last, passed one product at a time. Filter out Beacon and the others move up a place, which is a quick way to ask who is next in line.

Next

See the bump chart beside the other ranking charts in the ranking and change 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

All posts RSS