Skip to content

chore(deps): upgrade plotly.js to 4.1.1 - #105

Merged
jvdd merged 3 commits into
mainfrom
chore/plotly-js-4
Sep 27, 2026
Merged

jvdd merged 3 commits into
mainfrom
chore/plotly-js-4

Conversation

@jvdd

@jvdd jvdd commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Closes #90.

Change

  • The Plotly adapter loads plotly.js 4.1.1 instead of 3.0.0.
  • The script comes from jsDelivr ([email protected]), not from cdn.plot.ly. The file is byte-identical (same SHA-256). jsDelivr already serves gridstack, ECharts, marked and DOMPurify.
  • One browser test hovers a heatmap bin by its x and y values. Since plotly.js 3.7.0, Plotly.Fx.hover shows no label for a heatmap [row, col] pointNumber (plotly.js #7882 reads cd[pointNumber]). No product code calls Fx.hover.
  • Architecture.md, the adapter docstring, a test docstring and CHANGELOG.md are updated.

I picked 4.1.1, not 4.0.0. 4.1.1 bundles maplibre-gl 6.9.0, which fixes the critical XSS CVE-2026-85061. 4.0.0 and 3.0.0 bundle a vulnerable maplibre.

Breaking changes from 3.0.0 to 4.1.1

plotly.js change Effect on FlexViz
4.0: TinyColor replaced by culori Our own colors are not affected: hex, transparent, none, comma rgba(). User colors pass through: rgb() values from 0 to 1 now draw almost black, hsv() is not accepted. In the changelog.
4.0: contrast text color by WCAG ratio Visual only: some pie and treemap labels can switch from dark to white.
4.0: mapbox traces removed None. We use choroplethmap and scattermap on the map subplot.
4.0: overlaying-axis tickmode, geo.fitbounds, splom.matches, hoveranywhere values, Chart Studio config keys, *src attributes None. We use none of these.
4.0: map center and zoom auto-fit None. We set center and zoom, so the fit does not run.
4.0: "Upload to Cloud" modebar button on by default None. We set displayModeBar: false.
4.1.0: double-click delay 300 ms to 500 ms UX only. Autorange and deselect still need two clicks. A legend click now waits up to 500 ms. In the changelog.
4.1.1: maplibre-gl v6 drops WebGL 1 Map figures need WebGL 2. In the changelog.
3.7.0: selections GUI edits map to selectionrevision No change: we set no uirevision, so our layout.selections still wins on Plotly.react. The "Unrecognized GUI edit" warnings stop.

The Plotly internals that the adapter reads all exist in 4.1.1: _fullLayout._activeSelectionIndex, _fullLayout.selections, the map._derived relayout key, axis _length, Plotly.Plots.resize, and the window.Plotly global. Plotly.react still does one render per call (no full replot when the config is unchanged).

Performance

Measured on an M5 MacBook with headless Chromium. Cold browser context per run, versions alternate, median of 10 runs (6 at 4x throttle). The bundle is served locally for the CPU numbers, so only plotly.js differs.

Network (Plotly script, what a browser downloads):

3.0.0, cdn.plot.ly (main) 4.1.1, cdn.plot.ly 4.1.1, jsDelivr (this PR)
Transfer 1,411,123 B gzip 1,472,154 B gzip (+4.3 %) 1,410,481 B brotli (same as main)
Cache no cache-control no cache-control max-age=1y, immutable
Extra origin yes yes no (shares the gridstack connection)

Real network, 5-figure dashboard: TTFR 569 ms on main, 558 ms on this branch (the ranges overlap).

CPU, 10-figure dashboard with 2 map figures (1x CPU):

Metric 3.0.0 4.1.1 Delta
Script parse and run 373 ms 364 ms −9 ms
Time to first render 851 ms 867 ms +16 ms (+1.9 %)
Main-thread task time 682 ms 700 ms +18 ms
JS heap 32.6 MB 24.9 MB −7.7 MB
Line zoom Plotly.react 8.3 ms 9.0 ms +0.7 ms

The 8 non-map figures render in the same time (±1 ms). Each map figure takes about 20 ms more (about 60 ms at 4x CPU). 4.0.0 already adds about 16 ms of this, so the cost comes from the maplibre update. The security fix needs maplibre v6.

Dashboard without map figures: time to first render 490 → 483 ms, main-thread time 382 → 377 ms, script parse and run 372 → 362 ms. No regression.

Tests

  • make test: 2390 passed, 2 skipped. ruff format --check and ruff check are clean.
  • make test-browser: 316 passed, 12 skipped. The test that the first commit changes passes on 3.0.0 and 4.1.1.
  • A smoke run of a 10-figure dashboard (line, histogram, box, bar, pie, treemap, log histogram2d, geo_histogram2d, geo_line, corr_heatmap) under 3.0.0 and 4.1.1 gives the same traces, and zoom, pie click and re-click, treemap click and map pan behave the same. 4.1.1 logs no console errors. The map attribution control now draws correctly (3.0.0 put a large broken attribution line below each map).
  • The abandoned-gesture test docstring still holds on 4.1.1: Escape mid-drag and a drag back to the origin both still send a ranged plotly_selected.
  • Not yet run: the CI browser job on Ubuntu (WebGL 2 in headless Chromium). This PR's CI covers it.

@codspeed

codspeed Bot commented Sep 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing chore/plotly-js-4 (46cd833) with main (771b7e6)

Open in CodSpeed

@jvdd
jvdd merged commit 7476be7 into main Sep 27, 2026
18 checks passed
@jvdd
jvdd deleted the chore/plotly-js-4 branch September 27, 2026 18:41
This was referenced Sep 27, 2026
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.

Update plotly.js to 4.0

1 participant