Packed Circle Chart of Teams by Headcount
If you are the people lead showing how the company is made up, the question is not how many people there are. It is how they divide: which departments are large, which teams make them so, and how a small team compares with its neighbours in the same department.
A packed circle chart answers that. Each team is a circle whose area is its headcount, and the teams sit inside a larger circle for their department. The chart above is bound to the grid beneath it, one row per team, so filtering the rows redraws the chart. Filter the Department column to Engineering and only its teams are left, filling the view.
Why packed circles and not a treemap
A treemap fills a rectangle edge to edge, which is exact but dense: a department is a block among blocks. Packed circles leave space between teams, so each department reads as a group you can point at, and a click on one zooms in to see its teams larger. For an org that people explore, that is easier than reading a wall of slabs.
The chart over a grid
The chart reads the grid’s rows, and the tree it draws is the grid’s own grouping. Group the grid by department and then team, and the chart has a circle per department with a circle per team inside. The measure, y, sizes the teams, and a department is the sum of its teams. Packed circles are an opt-in chart type, so import the 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-pack';
const rows = [
{ id: 1, department: 'Engineering', team: 'Web', headcount: 14 },
{ id: 2, department: 'Engineering', team: 'Platform', headcount: 12 },
{ id: 3, department: 'Engineering', team: 'Data', headcount: 8 },
{ id: 4, department: 'Sales', team: 'Enterprise', headcount: 11 },
{ id: 5, department: 'Sales', team: 'Mid-market', headcount: 9 },
{ id: 6, department: 'Customer success', team: 'Support', headcount: 13 },
{ id: 7, department: 'Customer success', team: 'Onboarding', headcount: 6 },
];
const gridEl = document.createElement('div');
const chartEl = document.createElement('div');
gridEl.style.height = '240px';
chartEl.style.height = '420px';
document.body.append(gridEl, chartEl);
const grid = createGrid(gridEl, {
rowKey: 'id', rows, groupDefaultExpanded: false,
columns: [
{ field: 'department', title: 'Department', filter: { type: 'set' }, group: { enabled: true, index: 0 } },
{ field: 'team', title: 'Team', group: { enabled: true, index: 1 } },
{ field: 'headcount', title: 'Headcount', type: 'number', total: 'sum' },
],
});
createChart({ grid, container: chartEl, type: 'pack', y: 'headcount',
title: 'Teams by headcount, packed into their departments' });
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-pack';
const LatticeGrid = createLatticeGrid({ React, createGrid });
const rows = [
{ id: 1, department: 'Engineering', team: 'Web', headcount: 14 },
{ id: 2, department: 'Engineering', team: 'Platform', headcount: 12 },
{ id: 3, department: 'Sales', team: 'Enterprise', headcount: 11 },
{ id: 4, department: 'Customer success', team: 'Support', headcount: 13 },
];
const columns = [
{ field: 'department', title: 'Department', filter: { type: 'set' }, group: { enabled: true, index: 0 } },
{ field: 'team', title: 'Team', group: { enabled: true, index: 1 } },
{ field: 'headcount', title: 'Headcount', type: 'number', total: 'sum' },
];
export function TeamCircles() {
const gridRef = useRef(null);
const chartRef = useRef(null);
useEffect(() => {
const chart = createChart({ grid: gridRef.current.grid, container: chartRef.current,
type: 'pack', y: 'headcount' });
return () => chart.destroy();
}, []);
return (<>
<LatticeGrid ref={gridRef} rowKey="id" columns={columns} rows={rows}
groupDefaultExpanded={false} 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 | 'pack' here, circles inside circles drawn from the grid’s group tree. |
y |
string | The measure column. Here it is headcount, which sets the area of each team’s circle. |
title |
string | Drawn above the plot. |
One more option is worth knowing: padding sets the gap between sibling circles in pixels, 3 by default. The tree comes from the grid’s grouping, one level per grouped column in order, so x is not used.
Reading the circles
Compare areas, not widths: a circle twice the area is twice the headcount. In the example, Engineering is the largest department and Web its largest team, while People and finance is made of several small teams. Click a department to zoom into it and see its team names, and click the circle that fills the view to zoom back out. With no filter the chart draws every department at once, so filter to one when you want its teams to fill the view.
Next
See packed circles beside the other flow and hierarchy charts in the hierarchy 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.