Use slope and dumbbell views only after the before-and-after population is reconciled.
Paired-change charts: match entities before drawing a slope
The line encodes identity
A slope chart connects two measurements for the same entity. Its line claims a valid pair, not just two values with matching labels. If a store was renamed, split or absent in one period, resolve that identity before drawing. A join on display name can connect unrelated stores, while a broad outer join can make missing endpoints look like zero. Join cardinality should be checked at one row per entity and period. Record which entities were excluded from the paired population.
Choose difference or ratio deliberately
A dumbbell chart places two points on a shared quantitative scale; a slope chart emphasizes direction between endpoints. The axis unit and baseline decide whether a move appears large. A change from 47 to 81 is 34 units and about 72 percent of the starting value, but those answer different questions. For baseline zero, a percentage change is undefined. State which measure is encoded by the sorted order and put exact start, end and difference in accessible text. Axis rules apply to both forms.
Control clutter and crossings
With dozens of entities, labels and crossing segments become hard to follow. Sort by one declared endpoint or difference, keep label positions consistent, and consider small multiples or a ranked difference bar when comparison is more important than identity tracking. Highlight selected entities without fading the rest into illegibility. A connected pair should use a line style, endpoint labels or shape in addition to color. Accessible encodings matter when the positive and negative groups share a palette.
Check comparability across periods
Before-after values may use different denominator definitions, currencies, coverage windows or measurement instruments. Do not join a complete prior quarter to an incomplete current quarter. Record the cohort cutoff and period length. If the chart includes only entities observed in both periods, say how many were lost and whether they differ from those retained; survivorship can reverse the narrative. Provisional-period handling also applies when there are only two points.
Worked contract
def paired_depot_change(
prior: dict[str, int | None], current: dict[str, int | None]
) -> tuple[list[tuple[str, int, int, int]], set[str]]:
if any(value is not None and value < 0 for value in [*prior.values(), *current.values()]):
raise ValueError("negative request count")
matched = []
excluded = set(prior) | set(current)
for depot_id in sorted(set(prior) & set(current)):
before, after = prior[depot_id], current[depot_id]
if before is None or after is None:
continue
matched.append((depot_id, before, after, after - before))
excluded.remove(depot_id)
return matched, excluded
pairs, absent = paired_depot_change(
{"depot-47": 47, "depot-81": 81, "depot-94": 31},
{"depot-47": 81, "depot-81": None, "depot-109": 40})
assert pairs == [("depot-47", 47, 81, 34)]
assert absent == {"depot-81", "depot-94", "depot-109"}Performance and operating cost
For P prior and C current entities, hash-set intersection and validation take O(P + C) expected time; sorting K matched IDs takes O(K log K), with O(P + C) temporary space. If an ordered warehouse query already supplies stable IDs, sorting can be handled upstream. The excluded set is part of the chart contract; deleting it to make the visualization tidy hides selection bias. A renderer still needs label-collision handling for crowded panels.
Common Mistakes
- Connecting two stores with the same display name but different stable IDs.
- Substituting zero for a missing endpoint.
- Showing a percentage increase when the baseline is zero.
- Ignoring entities absent from the second period when describing the population.
Validation drill
Compare 47 depots across two quarters. Plant a renamed depot, a split depot and four incomplete current-quarter records; reconcile identity and report matched and excluded counts before drawing slopes.
Read next
- Axis scales, baselines and labels: prevent a correct number from telling a false story
- Small multiples: compare groups with honest scales and facet order
- Accessible charts: encode meaning without relying on color alone
- Time-series charts: distinguish missing days, zeros and provisional periods
