Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 (line+slope) add focus state / TAS-739 #4272

Merged
merged 23 commits into from
Dec 17, 2024
Merged

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented Dec 9, 2024

Adds the option to highlight lines in line and slope charts

Summary

  • Adds a new config field, focusedSeriesNames (suggestions for a different name welcome)
  • A line is identified by its series name which is either an entity name, a column display name or a combination of both
  • The list of focused series names is persisted to the URL as focus query param
    • The entity name utility functions are used to parse and serialise focused series names, so that the same delimiter is used and entity names are mapped to their codes if possible
    • This breaks if a column name contains ~ (the delimiter) which theoretically is possible but I don't think we need to worry about that now
  • Focused lines have bold labels, non-focused lines are grayed out
  • Grapher makes an effort to prevent the chart to enter a 'bad state' where all lines are grayed out because the focused line doesn't exist
    • This includes removing all elements from the focus array when the facet strategy changes and dismissing focused entities when they're unselected

In the admin

  • There is a new 'Data to highlight' section below the entity selection section
  • If the chart is in a bad state because one of the focused series names is invalid, saving is disabled and shows an error message

Follow up

  • It's a bit ugly that selectedEntityNames and focusedSeriesNames are always serialised, even for an empty Grapher. I've fixes that in a follow-up PR
  • The line legend method that drops labels if there are to many is a bit difficult to read. I'll open another PR with a refactor

@sophiamersmann sophiamersmann changed the title 🔨 move colors to ColorConstants file 🎉 (line+slope) add focus state / TAS-739 Dec 9, 2024
Copy link

@owidbot
Copy link
Contributor

owidbot commented Dec 9, 2024

Quick links (staging server):

Site Dev Site Preview Admin Wizard Docs

Login: ssh owid@staging-site-focus-state-viz

SVG tester:

Number of differences (default views): 1354 (d99454) ❌
Number of differences (all views): 450 (aa8e0f) ❌

Edited: 2024-12-17 16:13:28 UTC
Execution time: 1.34 seconds

@sophiamersmann sophiamersmann force-pushed the refactor-hover-viz branch 2 times, most recently from 01cf272 to cdfbf4c Compare December 11, 2024 13:04
@sophiamersmann sophiamersmann force-pushed the refactor-hover-viz branch 2 times, most recently from a643f80 to a48699c Compare December 11, 2024 17:26
@sophiamersmann
Copy link
Member Author

Thank you for the quick review!

  • I find it a bit weird that for slope charts, clicking the right legend entry changes focus state, but clicking the left one (or the line itself) does nothing.

true! will add it for the left legend. I don't want to overload slope interactions too much though and since it's only a power user feature...

  • It would be nice if discrete bar charts could also support this.

yap!

There's one such case that is still possible, which you can see in http://staging-site-focus-state-viz/grapher/population-density-of-the-capital-city?country=~DEU&focus=~FRA: Here, selectedEntityNames and focusedSeriesNames are non-overlapping, making everything gray. Although it should be quite hard to get into such a state without manually changing the URL, if I see that correctly?

The URL isn't validated at all. You can also focus a non-existing entity and everything is grayed out: http://staging-site-focus-state-viz/grapher/population-density-of-the-capital-city?focus=hello. That's how Grapher currently works for other query params as well, so I just went with that for now :)

@sophiamersmann sophiamersmann force-pushed the focus-state-viz branch 2 times, most recently from b3eda9e to e0b3788 Compare December 17, 2024 15:56
Copy link
Member Author

sophiamersmann commented Dec 17, 2024

Merge activity

  • Dec 17, 11:23 AM EST: A user started a stack merge that includes this pull request via Graphite.
  • Dec 17, 11:24 AM EST: Graphite rebased this pull request as part of a merge.
  • Dec 17, 11:25 AM EST: A user merged this pull request with Graphite.

@sophiamersmann sophiamersmann merged commit 2c1bc83 into master Dec 17, 2024
14 of 16 checks passed
@sophiamersmann sophiamersmann deleted the focus-state-viz branch December 17, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants