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

refactor: Move dataSet from configurator state to chart state #1240

Merged
merged 6 commits into from
Nov 1, 2023

Conversation

bprusinowski
Copy link
Collaborator

@bprusinowski bprusinowski commented Oct 31, 2023

This PR provides the technical foundation for the dashboards to allow charts based on different datasets within the same configurator state.

Essentially, it moves the dataSet property from the configurator state down to the charts themselves.

How to test

  1. Go to the deployment preview.
  2. Add the following object to the local storage (use vizualize-configurator-state:EpXqRKzyJxIy key):
{"version":"3.0.0","state":"CONFIGURING_CHART","dataSource":{"type":"sparql","url":"https://lindas.admin.ch/query"},"meta":{"title":{"de":"","fr":"","it":"","en":""},"description":{"de":"","fr":"","it":"","en":""}},"chartConfigs":[{"key":"tPfhn1Lsv4u1","version":"2.3.0","meta":{"title":{"en":"","de":"","fr":"","it":""},"description":{"en":"","de":"","fr":"","it":""}},"dataSet":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/9","chartType":"column","filters":{"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Kanton":{"type":"single","value":"https://ld.admin.ch/canton/1"}},"interactiveFiltersConfig":{"legend":{"active":false,"componentIri":""},"timeRange":{"active":false,"componentIri":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Jahr","presets":{"type":"range","from":"","to":""}},"dataFilters":{"active":false,"componentIris":[]},"calculation":{"active":false,"type":"identity"}},"fields":{"x":{"componentIri":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/Jahr","sorting":{"sortingType":"byAuto","sortingOrder":"asc"}},"y":{"componentIri":"https://energy.ld.admin.ch/sfoe/bfe_ogd84_einmalverguetung_fuer_photovoltaikanlagen/AnzahlAnlagen"}}},{"key":"tWem-qDvBFyn","version":"2.3.0","meta":{"title":{"en":"","de":"","fr":"","it":""},"description":{"en":"","de":"","fr":"","it":""}},"dataSet":"https://environment.ld.admin.ch/foen/ubd0104/6","chartType":"line","filters":{"https://environment.ld.admin.ch/foen/ubd0104/parametertype":{"type":"single","value":"E.coli"},"https://environment.ld.admin.ch/foen/ubd0104/station":{"type":"single","value":"https://environment.ld.admin.ch/foen/ubd0104/Station/CH10001"}},"interactiveFiltersConfig":{"legend":{"active":false,"componentIri":""},"timeRange":{"active":false,"componentIri":"https://environment.ld.admin.ch/foen/ubd0104/dateofprobing","presets":{"type":"range","from":"","to":""}},"dataFilters":{"active":false,"componentIris":[]},"calculation":{"active":false,"type":"identity"}},"fields":{"x":{"componentIri":"https://environment.ld.admin.ch/foen/ubd0104/dateofprobing"},"y":{"componentIri":"https://environment.ld.admin.ch/foen/ubd0104/value"}}}],"activeChartKey":"tPfhn1Lsv4u1"}
  1. Go to /en/create/EpXqRKzyJxIy?dataSource=Prod.
  2. See that the first chart is based on Photovoltaikanlagen dataset, while the second one is based on Bathing water quality dataset.

...as we don't have a chart yet, it doesn't bring a lot of value; and with the recent change of storing dataSet in ChartConfig, we can't really access chart config when selecting a dataset.
Copy link

vercel bot commented Oct 31, 2023

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 Nov 1, 2023 8:44am

@bprusinowski bprusinowski changed the title feat: Move dataSet from configurator state to chart state refactor: Move dataSet from configurator state to chart state Oct 31, 2023
Copy link
Collaborator

@lloydrichards lloydrichards left a comment

Choose a reason for hiding this comment

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

Nothing looks too out of place. Nice to be able to remove that guards when !stata.dataSet 👍

There are a few places where you replace state.dataSet with chartConfig.dataSet but my understanding was that chartConfig could either be an object or an array of objects 🤔 is this not the case or are all these cases when the configurator has been split up for each chart?

@bprusinowski
Copy link
Collaborator Author

Discussed with @lloydrichards offline; basically we are always in the context of a chart config, which we retrieve from the configurator state using the activeChartKey property.

@bprusinowski bprusinowski merged commit 07b2e09 into main Nov 1, 2023
3 checks passed
@bprusinowski bprusinowski deleted the feat/allow-charts-to-specify-datasets branch November 1, 2023 08:41
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.

2 participants