I greyed out the other lines and forgot to bring the chosen one to the front
I recently shipped a small feature for our dashboard charts, and it doesn’t work for the one thing it was built to do. This post covers what I got wrong, why I missed it, and what I’m changing.
The feature
Several dashboards have line charts with one line per machine: CPU, memory, storage. With six or more machines, the lines get tangled. So we added isolation. If you hover over a series’ legend key, or tap it, that series keeps its color, every other series turns grey, and the key shows as selected. The idea is that you can pick out one machine’s line and read it.
What I built
I built isolation as a styling change only. Each series that isn’t isolated gets a class, and the stylesheet maps that class to a soft grey. That’s the whole thing. Nothing moves.
Charts are SVG, and SVG has no z-index. Whatever is painted later covers whatever was painted earlier. Our lines are painted in the order they’re listed. When you isolated a machine, its line stayed in its usual position in that order, and every machine after it was still painted on top of it, now in grey.
What it caused
- Overlapping lines made the feature useless. If two machines both sat at 100% CPU, they drew the same path. Isolating the earlier one showed you a grey line, because the later machine’s grey line covered it completely. You couldn’t see the data of the machine you had just selected.
- Busy charts chopped up the selected line. Even when no values matched exactly, every grey line that crossed or overlapped the colored one from above broke it into pieces. With six machines this happened a lot. It was easy to see on the first hover.
- The hover dot had the same problem. The dot that marks the hovered value was greyed or kept in the same way, and it also stayed where it was in the paint order.
Why this one is on me
I can’t say I didn’t know paint order mattered. I knew. The charting library paints series in the order they’re mounted, and I had already written code to control that order when new series join a chart. The same file has a comment saying series are “drawn in order so the last one sits on top.” I wrote that comment. I just never asked the obvious question: when someone singles out a series, which one should be on top?
The written design had a gap too. It said the isolated series “keeps its color while every other series is drawn in grey” and nothing about stacking. Elsewhere, the same design doc says a different element is drawn “above every element of the page,” so we did have the words for this and didn’t use them here. But a gap in the spec doesn’t excuse the implementation. I had the context to catch it.
I also skipped a step. The task asked me to try the change in the running app with a real pointer against real data. I wrote down that I hadn’t done that, and shipped anyway. My automated test only checked that the greyed lines came out as the theme’s grey. It checked the half of the feature I had built and said nothing about the half I hadn’t.
What it should have been
Design. The spec should have said that the isolated series, both its line and its marks, is drawn above every other series, so you can read it in full. For example:
Hovering a series’ key, or tapping it, isolates the series: it keeps its color and is drawn above every other series of the chart, which are drawn in grey, and its key reads as the selected one.
Implementation. Isolation has to change paint order, not just color. While a series is isolated, its line and dots are painted last. When the isolation ends, they go back to their usual position. There are two reasonable ways to do this:
- Render the series list with the isolated one moved to the end, and include the isolated series in the value the chart is keyed on, so the library re-mounts in the new order. This reuses the mechanism I already had.
- Keep the normal order, and when isolation changes, move the isolated series’ SVG group to the end of its parent, then put it back when isolation ends.
Testing. Along with checking the grey, the test should assert that the isolated series’ group is the last series group in the DOM. That single check would have caught the bug.
What I’m doing differently
- Highlighting means stacking. Any time one thing is emphasized against others (a series, a mark, a row, a layer), I’ll decide and implement where it sits in the stacking order. It has to be painted above everything it’s being emphasized against. Dimming the rest is only half the feature.
- I’ll call out incomplete specs. If a spec describes emphasis only in terms of color, I’ll flag it before building, not fill the gap with whatever is easiest.
- Tests should check what the user sees. For visual features, a test that checks a style value isn’t enough. I’ll also check the thing the user actually depends on, which here is being able to see the line.
- “Not tested in the running app” blocks shipping. If a task asks for a manual check with a pointer and I haven’t done it, the work isn’t done. Here, the bug would have shown up on the first hover with the real fleet.
The fix is small: a reorder and one more test assertion. The real lesson is about how I think about emphasis. Making one thing stand out has two parts, color and stacking, and I only did the color.