Lattice Grid

blog

Dumbbell Chart for Pay Gap by Department

Building…
Loading a live grid…

If you are an HR analyst, the question you bring to a pay review is where the gap between two groups is widest. A table of medians per department gives you two numbers to subtract in your head, twenty-four times over, and the departments with the largest gap do not announce themselves.

A dumbbell chart answers it with a bar. Each department gets a row with two dots, one for the median pay of each group, joined by a bar, and the length of the bar is the gap. The blue dot is the start column and the amber dot the end column. The chart above is bound to the grid beneath it, one row per department, so filtering the rows redraws the dumbbells. Filter the Site column to look at one site and the chart keeps only the departments left.

Why a dumbbell chart and not a bar chart

Two bars per department make you compare the ends of bars that start at zero, and with medians that sit close together the difference is a sliver. The dumbbell drops the shared baseline and draws only the two values and the distance between them, so the long bars are the departments to look at first.

The chart over a grid

Name the department column in x, the column for one group in start and the column for the other in end. Dumbbell 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-dumbbell';

const rows = [
  { id: 1, department: 'Engineering', site: 'North', groupA: 96, groupB: 91 },
  { id: 2, department: 'Sales', site: 'North', groupA: 78, groupB: 68 },
  { id: 3, department: 'Marketing', site: 'South', groupA: 72, groupB: 70 },
  { id: 4, department: 'Finance', site: 'South', groupA: 82, groupB: 75 },
  { id: 5, department: 'Support', site: 'East', groupA: 54, groupB: 53 },
  { id: 6, department: 'Legal', site: 'East', groupA: 108, groupB: 97 },
];
const gridEl = document.createElement('div');
const chartEl = document.createElement('div');
gridEl.style.height = '240px';
chartEl.style.height = '320px';
document.body.append(gridEl, chartEl);

const grid = createGrid(gridEl, {
  rowKey: 'id', rows,
  columns: [
    { field: 'department', title: 'Department' },
    { field: 'site', title: 'Site', filter: { type: 'set' } },
    { field: 'groupA', title: 'Group A median (k)', type: 'number' },
    { field: 'groupB', title: 'Group B median (k)', type: 'number' },
  ],
});
createChart({ grid, container: chartEl, type: 'dumbbell', x: 'department',
  start: 'groupB', end: 'groupA', title: 'Median pay by department' });

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-dumbbell';

const LatticeGrid = createLatticeGrid({ React, createGrid });
const rows = [
  { id: 1, department: 'Engineering', site: 'North', groupA: 96, groupB: 91 },
  { id: 2, department: 'Sales', site: 'North', groupA: 78, groupB: 68 },
  { id: 3, department: 'Marketing', site: 'South', groupA: 72, groupB: 70 },
  { id: 4, department: 'Finance', site: 'South', groupA: 82, groupB: 75 },
  { id: 5, department: 'Legal', site: 'East', groupA: 108, groupB: 97 },
];
const columns = [
  { field: 'department', title: 'Department' },
  { field: 'site', title: 'Site', filter: { type: 'set' } },
  { field: 'groupA', title: 'Group A median (k)', type: 'number' },
  { field: 'groupB', title: 'Group B median (k)', type: 'number' },
];

export function PayGap() {
  const gridRef = useRef(null);
  const chartRef = useRef(null);
  useEffect(() => {
    const chart = createChart({ grid: gridRef.current.grid, container: chartRef.current,
      type: 'dumbbell', x: 'department', start: 'groupB', end: 'groupA' });
    return () => chart.destroy();
  }, []);
  return (<>
    <LatticeGrid ref={gridRef} rowKey="id" columns={columns} rows={rows} style={{ height: 240 }} />
    <div ref={chartRef} style={{ height: 320 }} />
  </>);
}

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 'dumbbell' here, a start and an end per category, joined by a bar.
x string The category column, here the department.
start string The column for the first dot of each pair.
end string The column for the second dot, the far end of the bar.
title string Drawn above the plot.

Reading the gap

Look for the longest bars first. In the example, Legal and Sales have the widest gaps, while Design, Support and Facilities are close to level. A short bar is not proof of fairness and a long one is not proof of the opposite, since medians hide the spread inside a group, but the chart tells you which departments to open up next. Filter the Site column and see whether a wide gap belongs to the department or to one site.

Next

See the dumbbell 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