feat(world-map): migrate World Map plugin to the v1 chart data API#42356
Draft
Naktibalda wants to merge 2 commits into
Draft
feat(world-map): migrate World Map plugin to the v1 chart data API#42356Naktibalda wants to merge 2 commits into
Naktibalda wants to merge 2 commits into
Conversation
The World Map chart was one of the remaining legacy-API plugins fetching data via /superset/explore_json/. That endpoint rejects embedded guest tokens unconditionally, so world maps could never render in embedded dashboards, and it keeps the deprecated endpoint alive. - Add buildQuery replicating the legacy WorldMapViz.query_obj (superset/viz.py): group by the entity column, request the metric plus the bubble-size metric when distinct (compared by label), translate sort_by_metric into an orderby. - Rebuild the country/code/name/latitude/longitude/m1/m2 row shape in transformProps: the v1 endpoint returns rows keyed by the entity column and metric labels, so the country-code conversion and centroid/name enrichment WorldMapViz.get_data performed server-side via superset/examples/countries.py now happens client-side with a mirrored country table (countries.ts, case-insensitive lookup like the Python). - Rename @superset-ui/legacy-plugin-chart-world-map to @superset-ui/plugin-chart-world-map (1.0.0) following the preset-chart-deckgl precedent; the world_map viz key is unchanged, so existing charts keep working. Existing charts should be re-saved to refresh their stored query_context for embedded (guest token) use. - Add buildQuery/transformProps unit tests. The legacy WorldMapViz Python class is left in place for now and can be removed in a follow-up alongside the other explore_json cleanups. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #42356 +/- ##
==========================================
+ Coverage 65.28% 65.29% +0.01%
==========================================
Files 2793 2795 +2
Lines 157260 157295 +35
Branches 35955 35972 +17
==========================================
+ Hits 102660 102702 +42
+ Misses 52623 52616 -7
Partials 1977 1977
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Migrates the World Map chart from the deprecated legacy data endpoint (
/superset/explore_json/) to the v1 chart data API (POST /api/v1/chart/data), and renames the package@superset-ui/legacy-plugin-chart-world-map→@superset-ui/plugin-chart-world-map(1.0.0), following the precedent set bypreset-chart-deckglin #38035.Rationale: besides moving one more chart off the deprecated endpoint, this fixes World Map charts in embedded dashboards:
/superset/explore_json/rejects guest tokens unconditionally, so embeddedusers get "Access is Denied" on every World Map chart while all v1-API charts on the same dashboard work.
Design decisions:
buildQueryreplicates the legacyWorldMapViz.query_obj(superset/viz.py) exactly: group by the entity column, request the metric plus the bubble-size metric when distinct (compared viagetMetricLabel, so adhoc metrics dedupe correctly), and translatesort_by_metricinto anorderby.transformPropsnow rebuilds thecountry/code/name/latitude/longitude/m1/m2shape the renderer consumes — thecountry-code conversion and centroid/name enrichment that
WorldMapViz.get_dataperformed server-side viasuperset/examples/countries.py. The country table is mirrored client-side (src/countries.ts,case-insensitive lookup like the Python
get()), including the legacym2 = m1fallback and theXXXsentinel for unmappable values.world_mapviz key is unchanged, so existing charts keep working without migration. Existing charts should be re-saved (Save → overwrite) to refresh their storedquery_contextbefore use behind guesttokens, since the guest
query_context_modifiedcheck compares against it.WorldMapVizPython class is intentionally left in place; it can be removed in a follow-up together with the otherexplore_jsoncleanups.WorldMap.ts/datamaps) is untouched — no visual changes.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
No visual changes — same renderer, new data path. (Before/after of an embedded dashboard: previously "Access is Denied" on World Map charts under a guest token, now rendering.)
TESTING INSTRUCTIONS
country/metric, cross-filtering and drill-to-detail/drill-by all behave as before.
POST /api/v1/chart/data(no/superset/explore_json/request).country_fieldtypeoption still maps correctly (cca2/cca3/cioc/full name), including lower-cased values, and that unmappable values are simply omitted from the map.EMBEDDED_SUPERSETenabled, embed a dashboard containing a World Map chart and render it with a guest token — the chart loads (previously failed with "Access is Denied"). Re-savethe chart first if it existed before this change.
npm run test -- plugins/plugin-chart-world-map(newbuildQuery/transformPropssuites plus the existing renderer suite).ADDITIONAL INFORMATION