Problem
Fourteen services on one chart. The viewer wants to compare two of them, and the other twelve are in the way. Editing the query is not an option, because they will want a different two in thirty seconds.
Solution
Make the legend a control. Clicking a series isolates it; modifier-clicking builds a set; clicking again restores everything. The chart becomes explorable without anyone touching a query.
Grafana’s behaviour is the one most products converged on and it is worth stating exactly, because it surprises people the first time: clicking a series label removes all other series from view. It isolates rather than hides. To build up a comparison you Ctrl or Cmd-click additional labels, and clicking a label twice returns to showing everything.
Isolate-on-click is the right default, and the reason is the asymmetry of intent. Someone with fourteen series almost always wants one or two, so isolating gets them there in one click while hiding would take twelve. The cost is that the first click is destructive-looking and undiscoverable, which is why the double-click-to-restore has to be reliable.
The legend also has a second job that has nothing to do with toggling: identifying which line is which. This is where it either earns its space or wastes it. Grafana offers List and Table modes, placement at Bottom or Right, and the ability to put values and calculations in the legend itself. Table mode with a value column turns the legend into a sortable summary and often removes the need for a separate panel.
Placement matters more than it looks. A legend at the bottom pushes the chart up and gets cut off with many series. A legend on the right takes horizontal space permanently but scrolls gracefully, which is why dense charts end up on the right.
The accessibility point is unavoidable here: a legend that maps colour to name is the mechanism by which a chart’s meaning depends entirely on colour. WCAG’s requirement that colour not be the sole carrier of information means either direct labelling, distinguishable line styles, or an interaction that lets someone isolate a series and read its name.
Use when
More than about four series share a chart and viewers compare subsets that differ by person and by question.
Don’t use when
There is one series, where the legend is a label pretending to be furniture. Or when there are fifty, where the legend is a scrolling list nobody reads and small multiples would answer better.
Trade-offs
Toggle state is invisible to anyone who didn’t set it, so a screenshot of an isolated chart looks like a chart with one series and gets read as such. It rarely persists into a shared link, so the thing you found is not the thing they open. Legends consume real space that the chart wanted. And with many series the legend becomes the dominant object on the panel, which is a strong signal the chart is the wrong shape rather than the legend the wrong size.
Checklist
- Does clicking a series isolate it or hide it, and is that discoverable?
- Is there a reliable one-action restore?
- Can the viewer build a set of two or three, and how?
- Does the legend carry values or calculations, or only names?
- Is placement right for the series count, and does it scroll rather than truncate?
- Are series names readable, or truncated into ambiguity?
- Does the chart’s meaning survive for someone who cannot distinguish the colours?
- Does toggle state go into the URL or a shared link?
- Is series order stable between refreshes?
- At what series count should this be small multiples instead?
Compare
Grafana isolates on click and builds sets with Ctrl or Cmd, offers list and table legends with values in them, and lets the legend sit bottom or right, which makes it as much a summary table as a key. Datadog leans on hover-to-highlight over click-to-isolate, so exploring is transient and nothing persists into a state someone could misread. Honeycomb mostly avoids the problem by grouping at query time: rather than toggling fourteen series off a chart, you change what you grouped by and get the two you wanted. Netdata puts a dimension list under every chart with per-dimension toggling, which at hundreds of charts makes the legend the primary way of narrowing anything.
Related
Time series is the chart this sits on. Categorical series palette is what makes the mapping between key and line possible at all. Hover detail is the other way to answer “which line is this”. Small multiples is the answer when the series count has outgrown one chart. Cross-filter is the page-wide version of narrowing by selection.