-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
feat(world-map): support color by metric or country column #19881
Conversation
Codecov Report
@@ Coverage Diff @@
## master #19881 +/- ##
==========================================
- Coverage 66.46% 66.44% -0.03%
==========================================
Files 1721 1721
Lines 64517 64542 +25
Branches 6807 6811 +4
==========================================
+ Hits 42879 42882 +3
- Misses 19906 19927 +21
- Partials 1732 1733 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Two random thoughts... and these can be separate tickets/PRs if we want to do either of them:
2a) You only actually need four colors to display a map. As a default, it might be nice to take advantage of that, if your mapping library happens to support the four color theorem as a feature. 2b) If we do take advantage of the four color theorem, it may get ugly with color consistency... so... I don't quite know what to do there.
|
...nd/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts
Outdated
Show resolved
Hide resolved
superset-frontend/plugins/legacy-plugin-chart-world-map/src/controlPanel.ts
Outdated
Show resolved
Hide resolved
processedData = filteredData.map(d => ({ | ||
...d, | ||
radius: radiusScale(Math.sqrt(d.m2)), | ||
fillColor: colorScale(d.name, sliceId), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also base this on the metric, rather than the name, so that the country with the highest value gets the first color in the palette.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. But actually we may need to use country name as the color label instead of metric value when we use categorical color, and the metric values here are not in order. If we want to make the country with the highest value get the first color in the palette, we can sort the filteredData
first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a bunch of thoughts/comments, but I'm ready to approve after those get considered :)
…ed-controls/components/RadioButtonControl.tsx Co-authored-by: Evan Rusackas <evan@preset.io>
…ntrolPanel.ts Co-authored-by: Evan Rusackas <evan@preset.io>
…ntrolPanel.ts Co-authored-by: Evan Rusackas <evan@preset.io>
SUMMARY
This PR allows world map to support country color in two ways:
Here we add a radio control to achieve it.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
before
after
2022-04-28.8.43.23.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION