Repository navigation
Highlight and toggle chart lines from the legend (fix #15) - #484
Merged
Merged
Conversation
stephaniehobson
force-pushed
the
15--legend-highlight
branch
from
November 12, 2026 19:17
878f6a2 to
6d89f37
Compare
stephaniehobson
force-pushed
the
15--legend-highlight
branch
from
November 12, 2026 22:53
6d89f37 to
6816dcf
Compare
Highlighting a population rebuilt the plot, so the readout a click had pinned disappeared as soon as the pointer reached the legend. The fade is now applied to the SVG already drawn, and ObservablePlot redraws only when what the chart is drawn from changes. Hover and keyboard focus are tracked separately, so moving the pointer off a focused entry, or blurring a hovered one, no longer clears its highlight. A population with no points shown can't be highlighted, since doing so faded every line.
stephaniehobson
force-pushed
the
15--legend-highlight
branch
from
November 13, 2026 15:02
6816dcf to
952b37e
Compare
Highlighting a legend entry renders the chart again, and on a chart with more than eleven populations each render ran distinctColors, which takes several milliseconds, for a palette it had already made.
stephaniehobson
marked this pull request as ready for review
November 13, 2026 16:06
stevejalim
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

One-line summary
Highlight a chart line while its legend entry is hovered or focused, and hide or show the line by clicking it.
Significant changes and points to review
<button aria-pressed>elements, styled to look as before. Three specs now find them by.legend-entryinstead of.legend span.ChartContainer.jsxstate. They reset when the data changes, such as on a region change, since another region can have different populations.Issue / Bugzilla link
#15
Testing
Run
npm installandnpm run build:cssfirst, thennpm start.