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

fix: Keep color mapping up to date #1943

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

bprusinowski
Copy link
Collaborator

@bprusinowski bprusinowski commented Jan 6, 2025

Fixes #1513

This PR makes sure we keep the colorMapping up to date in case new values appear in the cube (only possible when editing a chart that's based on a cube that was updated with a new value in dimension used as a color dimension after the chart was initially made). It also makes sure we keep old colors for existing values when updating the colorMapping.

How to test

  1. Go to this link.
  2. Open developer tools.
  3. Switch to a Storage > Local Storage tab (Safari) or Application > Local storage (Chrome).
  4. Check the id of your chart in the URL tab (last part after slash, e.g. /create/aclFD9sq5POy.
  5. Look for an entry with that id in the local storage tab.
Screenshot 2025-01-06 at 11 01 13
  1. Double click the value, remove it and paste the below one (copied from the original chart from chart shows the additional year, but it doesn't appear in the left-hand filter #1513, which doesn't work on INT).
{"key":"52j3bDy8VD6e","version":"4.0.0","state":"CONFIGURING_CHART","dataSource":{"url":"https://int.lindas.admin.ch/query","type":"sparql"},"chartConfigs":[{"key":"_FFhHndsYAyF","meta":{"title":{"de":"","en":"","fr":"","it":""},"description":{"de":"","en":"","fr":"","it":""},"label":{"de":"","fr":"","it":"","en":""}},"cubes":[{"iri":"https://environment.ld.admin.ch/foen/ubd010702/14","filters":{"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/messparameter":{"type":"single","value":"https://ld.admin.ch/cube/dimension/pol01air/pol13"},"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/jahr":{"type":"multi","values":{"2022":true,"2023":true,"2024":true,"2025":true}}}}],"fields":{"x":{"componentId":"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/station"},"y":{"componentId":"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/wert"},"segment":{"type":"grouped","palette":"category10","sorting":{"sortingType":"byAuto","sortingOrder":"asc"},"colorMapping":{"2003":"#1f77b4","2004":"#ff7f0e","2005":"#2ca02c","2006":"#d62728","2007":"#9467bd","2008":"#8c564b","2009":"#e377c2","2010":"#7f7f7f","2011":"#bcbd22","2012":"#17becf","2013":"#1f77b4","2014":"#ff7f0e","2015":"#2ca02c","2016":"#d62728","2017":"#9467bd","2018":"#8c564b","2019":"#e377c2","2020":"#7f7f7f","2021":"#bcbd22","2022":"#17becf","2023":"#1f77b4","2024":"#ff7f0e"},"componentId":"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/jahr"}},"version":"4.0.0","chartType":"column","activeField":"segment","interactiveFiltersConfig":{"legend":{"active":false,"componentId":""},"timeRange":{"active":false,"presets":{"to":"2024","from":"2003","type":"range"},"componentId":"https://environment.ld.admin.ch/foen/ubd010702(VISUALIZE.ADMIN_COMPONENT_ID_SEPARATOR)https://environment.ld.admin.ch/foen/ubd010702/jahr"},"calculation":{"type":"identity","active":false},"dataFilters":{"active":false,"componentIds":[]}}}],"activeChartKey":"_FFhHndsYAyF","dashboardFilters":{"timeRange":{"active":false,"timeUnit":"","presets":{"from":"","to":""}},"dataFilters":{"filters":{},"componentIds":[]}},"layout":{"type":"tab","meta":{"title":{"de":"","en":"","fr":"","it":""},"description":{"de":"","en":"","fr":"","it":""},"label":{"de":"","fr":"","it":"","en":""}}}}
  1. ✅ Refresh the page and see that the 2025 value is correctly displayed in the filters panel.

How to reproduce

See #1513 (copy and edit the chart, see that the values are not in the filters panel)

Copy link

vercel bot commented Jan 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
visualization-tool ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2025 10:11am

Copy link
Contributor

@noahonyejese noahonyejese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@bprusinowski bprusinowski merged commit 6b6f9a5 into main Jan 6, 2025
6 of 10 checks passed
@bprusinowski bprusinowski deleted the fix/keep-color-mapping-up-to-date branch January 6, 2025 14:13
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.

chart shows the additional year, but it doesn't appear in the left-hand filter
2 participants