Take a dashboard with a row of status counters: 11 active, 4 declining, 3 new, 3 dead, 2 never seen. Add them up and you get 23. The project has 18 features.

Nobody on the team was confused by this, because we all knew that a declining feature is still an active one, and so is a new one. Those counters were each answering their own question ("how many features are declining?") and every one of them was correct. They just weren't parts of a whole, and the moment you draw them as parts of a whole, the whole stops adding up.

I ran into this while building a view I'd wanted for a while: every feature of a project as one cell, coloured by its state, so you can see how much of your product is healthy at a glance. A map like that has a legend, and a legend has to partition the thing it describes. Each cell gets exactly one colour. So each feature needs exactly one state, and the counts above the map have to add up to the number of cells.

Here's what that took, including two small things in the UI that cost me more time than the part I'd planned for.

One state per feature, decided once

The existing logic already knew all five states: new, active, declining, dead, never seen. What it didn't have was a rule for features that qualify for more than one. A feature that launched last week and is already losing users is new and declining. A feature that's silent past its threshold had to be active once, so it's active and dead, depending on which question you ask.

For the map I needed a single answer, so I wrote down an order: never seen beats dead, dead beats declining, declining beats new, new beats active. Reading it as "the worst thing that's true about it wins" is a fair summary. A feature shows as active only if nothing more specific applies.

The more important decision was where the order lives. The tempting version sends the dashboard the raw numbers and lets the client decide the colour. I did the opposite: the endpoint returns the state, already decided, and the client never reclassifies anything. The reason is that this product has per-project settings and per-feature overrides, so "is this dead?" has more than one input, and the client can't see all of them. If the browser re-derived the state, there would be two implementations of the rule, and sooner or later the map would disagree with the Dead page it links to. As it is, the map and those pages call the same code.

Turning overlapping counts into a partition

The overview already had its counters, and I didn't want to compute a second set. But they overlap, as above, so they can't go on the map's legend as they are. The fix is small arithmetic: active minus declining minus new gives the features that are only active. The other four counters are already exclusive of each other.

// overview counts overlap: a declining or new feature is also "active" const onlyActive = active - declining - new; 

I checked it against the demo project instead of trusting the algebra: 11 active, 2 declining, 3 dead, 2 never seen, which is 18 of 18, matching the number of cells on the map.

I'll mention the second case because it's the one that bites later. The endpoint has an upper limit on how many features it returns, and when a project exceeds it, the rows with the least usage are dropped first (never-seen ones go with them). The counts computed over the returned rows would then be wrong for exactly the biggest projects. So the response says when it was cut, and in that case the dashboard takes the totals from the overview and does the same subtraction. Small projects never see this code path, which is the usual sign that it needs its own test.

The tab that wouldn't explain itself

The map and the existing widgets live on the same page, with a switch between them. The widgets can be rearranged with a Customize button, which makes no sense for the map. So Customize is greyed out while the map is shown, and it has a tooltip saying why.

The tooltip never appeared. A disabled button doesn't receive pointer events in the browsers I tried, so there was nothing to hover. Switching to aria-disabled and handling the click myself fixed hover. It also left me with a different problem: the tab clipped its own overflow, so a tooltip inside it was cut off. The tooltip now sits in a fixed-size wrapper next to the tab instead of inside it. On touch screens there's no hover at all, so a tap on the inert button shows the tooltip too.

I'd have avoided all of it if I'd just hidden the button. I kept it because a control that disappears when you switch views teaches nothing, and I wanted the reason to be visible.

The view you chose, without a flash

Which view you see is a personal choice, saved in the browser. The widget layout is different: that's saved for the whole project, so everyone on the team sees the same arrangement. Mixing those two would have been confusing, so the view choice stays in localStorage.

Reading localStorage during render is the classic way to get a hydration mismatch, since the server doesn't have it. I read it with useSyncExternalStore, where the server snapshot is always "widgets", and the first client render matches that. Then the stored choice applies. The same hook gives the other open tabs the change through the storage event for free, and it falls back to memory if storage is blocked. The cost is that someone who prefers the map sees the widgets for a moment on load, which I decided was better than a mismatch warning and a broken tree.

The map only fetches when it's on screen. Anyone who never switches to it never pays for the request.

What I'd tell someone building something similar

If you're about to put a legend on a chart of anything, check whether your counters partition the thing. Add them up first. If they don't sum to the total, one of two things is true: you have overlapping categories, or you have a category that's missing. Both are easier to fix before the chart exists.

The map is in Eventra, on the Overview, and the demo account on the homepage opens straight into one.