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

Add shapes & points filtering to maps #367

Merged
merged 6 commits into from
Feb 17, 2022
Merged

Conversation

bprusinowski
Copy link
Collaborator

@bprusinowski bprusinowski commented Feb 17, 2022

Closes #342.

This PR adds an ability to filter geoDimension in the right panel. There was a need for some custom logic for shapes, as they are fetched separately from dimension's values.

  • should symbol layer based on the area layer be filterable separately? In such case filtering applies to both areas and symbols

@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-add-s-8usxwv February 17, 2022 15:09 Inactive
Copy link
Collaborator

@ptbrowne ptbrowne left a comment

Choose a reason for hiding this comment

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

I think the filtering could be improved so that we are not in O(N^2). Otherwise LGTM, very cool 👍

return data.filter((d) => hierarchyLabels.includes(getLabel(d)));
return data
.filter((d) => dimensionLabels.includes(getLabel(d)))
.filter((d) => hierarchyLabels.includes(getLabel(d)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to have an index to check for inclusion here as otherwise we are looping in N^2.

const index = Object.fromEntries([...dimensionLabel, ...hierarchyLabels].map(l => [l, true]))
return data.filter(d => !!index[getLabel(d)])

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have modified the code, so it's no longer needed 🥳

@ptbrowne ptbrowne temporarily deployed to visualize-ad-feat-add-s-8usxwv February 17, 2022 16:06 Inactive
@ptbrowne
Copy link
Collaborator

@bprusinowski
Copy link
Collaborator Author

It doesn't work because #364 is not merged yet 😅

@bprusinowski
Copy link
Collaborator Author

I had made a quick fix locally to test it on my machine, but I would have to merge #364 to this PR to enable a correct deployment preview 👀

@ptbrowne ptbrowne self-requested a review February 17, 2022 16:49
Copy link
Collaborator

@ptbrowne ptbrowne left a comment

Choose a reason for hiding this comment

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

LGTM ! Thanks :)

@ptbrowne ptbrowne merged commit 9372e75 into main Feb 17, 2022
@ptbrowne ptbrowne deleted the feat/add-shapes-hiding-to-maps branch February 17, 2022 16:49
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.

Maps: Choose which cantons can be displayed
2 participants