feat(plotly)!: migrate maps to plotly.js 4

Merged
KR
10d ago
+710-168

Summary

Closes #7002.

Plotly.js 4 removes the Mapbox traces used by rx.plotly.mapbox. Add rx.plotly.map for MapLibre figures and upgrade all bundles to 4.3.0. Existing Mapbox figures keep rendering in rx.plotly, rx.plotly.map and rx.plotly.mapbox through a rename until 1.0, so the app loads one Plotly.js version.

What changed

  • Add the MapLibre bundle with locale, reactive data and event support.
  • Deprecate rx.plotly.mapbox and Mapbox figures in Reflex 0.11.1 with removal scheduled for 1.0. rx.plotly.mapbox loads plotly.js-map-dist-min@4.3.0; Plotly.js 3.7.0 is no longer a dependency.
  • Every Plotly component (and subclass) checks the figure for Mapbox traces or layout.mapbox* keys, including state updates. On a match it logs one browser warning and passes Plotly a copy with MapLibre trace types (scattermapbox → scattermap, etc.), subplot references and layout.mapbox* keys, in the figure and its animation frames. The user's figure is not changed. Templates, geojson, customdata and button arguments keep their names. Figures without Mapbox names pass through unchanged, so the warning stops once the user migrates.
  • Render a None state figure when layout or the default template is set; mergician threw on null and crashed the page (also on main).
  • Update dependency locks, migration documentation, news fragments and regression coverage.

Verification

  • Full unit suite at a19690c: 11,263 passed and 158 skipped with 73.75% coverage. The review follow-up passes all 20 focused unit tests; all 9 Node-dependent cases skip cleanly when Node.js is unavailable.
  • Plotly browser suite: 14 passed in development and production using Chrome. Covers migration warnings, loading figures, translated modern and legacy map controls, state updates and click callbacks.
  • Upgrade check: an app written on released Reflex 0.11.0 (plotly 6.9) with rx.plotly.mapbox (literal, state, density, choropleth, two-subplot, fr, animated px.scatter_mapbox, relayout buttons) and default rx.plotly (literal, state, mixed map + bar) Mapbox plots, rerun in the same folder on this branch. All eleven render with the same center, zoom, size, locale, click result and animation; buttons with mapbox.* relayout paths no longer act, as documented; .web/package.json keeps only Plotly.js 4.3.0.
  • Ruff lint, formatting, pyright reflex tests and changed-file pre-commit hooks passed.
  • All tracked Python files passed Pyright with the Linux platform setting. The macOS all-files hook reports six existing affinity API errors in unchanged Linux benchmark code; other hooks passed.

Deployment notes

All renderers use Plotly.js 4. Mapbox figures keep rendering through the rename until 1.0 and should migrate to MapLibre traces and layout.map. This is still a breaking change for some Mapbox code: Mapbox paths in buttons, sliders and templates no longer act, on_relayout data uses map.* keys, styles hosted by Mapbox (mapbox:// URLs) do not load and the access token is ignored. The docs list these changes. The migration guide also covers removed MathJax 2 support, Chart Studio options, source-reference attributes and changed rendering defaults.