Skip to content

feat(world-map): migrate World Map plugin to the v1 chart data API#42356

Draft
Naktibalda wants to merge 2 commits into
apache:masterfrom
Naktibalda:feature/world-map-v1-api
Draft

feat(world-map): migrate World Map plugin to the v1 chart data API#42356
Naktibalda wants to merge 2 commits into
apache:masterfrom
Naktibalda:feature/world-map-v1-api

Conversation

@Naktibalda

Copy link
Copy Markdown

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 by preset-chart-deckgl in #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 embedded
users get "Access is Denied" on every World Map chart while all v1-API charts on the same dashboard work.

Design decisions:

  • buildQuery replicates the legacy WorldMapViz.query_obj (superset/viz.py) exactly: group by the entity column, request the metric plus the bubble-size metric when distinct (compared via
    getMetricLabel, so adhoc metrics dedupe correctly), and translate sort_by_metric into an orderby.
  • The v1 endpoint returns generic rows keyed by the entity column and metric labels, so transformProps now rebuilds the country/code/name/latitude/longitude/m1/m2 shape the renderer consumes — the
    country-code conversion and centroid/name enrichment that WorldMapViz.get_data performed server-side via superset/examples/countries.py. The country table is mirrored client-side (src/countries.ts,
    case-insensitive lookup like the Python get()), including the legacy m2 = m1 fallback and the XXX sentinel for unmappable values.
  • The world_map viz key is unchanged, so existing charts keep working without migration. Existing charts should be re-saved (Save → overwrite) to refresh their stored query_context before use behind guest
    tokens, since the guest query_context_modified check compares against it.
  • The legacy WorldMapViz Python class is intentionally left in place; it can be removed in a follow-up together with the other explore_json cleanups.
  • Rendering (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

  1. Open any World Map chart (e.g. from the World Bank's Data example dashboard) in Explore and on a dashboard: choropleth, bubbles (enable "Show Bubbles" with a secondary metric), tooltips, color-by
    country/metric, cross-filtering and drill-to-detail/drill-by all behave as before.
  2. In the network tab, confirm the chart now fetches via POST /api/v1/chart/data (no /superset/explore_json/ request).
  3. Verify each country_fieldtype option still maps correctly (cca2/cca3/cioc/full name), including lower-cased values, and that unmappable values are simply omitted from the map.
  4. Embedded regression: with EMBEDDED_SUPERSET enabled, 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-save
    the chart first if it existed before this change.
  5. Unit tests: npm run test -- plugins/plugin-chart-world-map (new buildQuery/transformProps suites plus the existing renderer suite).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Naktibalda and others added 2 commits July 23, 2026 18:31
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>
@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 80378cf
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a6238aecc1e770009d4c25d
😎 Deploy Preview https://deploy-preview-42356--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.29%. Comparing base (67924ad) to head (80378cf).
⚠️ Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
...ugins/plugin-chart-world-map/src/transformProps.ts 94.44% 1 Missing ⚠️
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              
Flag Coverage Δ
javascript 71.22% <97.22%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants