Skip to content

[WC-3671]: Update plotly.js to v4 - #2522

Open
r0b1n wants to merge 1 commit into
mainfrom
r0b1n/plotly-v4
Open

r0b1n wants to merge 1 commit into
mainfrom
r0b1n/plotly-v4

Conversation

@r0b1n

@r0b1n r0b1n commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Plotly.js 3.x (latest 3.7.0) bundles maplibre-gl 4.7.1, which is affected by GHSA-jrc7-96c5-q579 (critical XSS in the attribution control, fixed in maplibre-gl 6.4.1). There's no 3.x backport; the fix shipped in plotly.js 4.1.1. 4.2.0 bundles maplibre-gl 6.11.2. pnpm audit also flagged probe-image-size through the same path; both are clean after this change.

Only Custom Chart accepts arbitrary Plotly JSON (and so could reach map traces), but the vulnerable code is in every chart widget's bundle.

What

  • plotly.js-dist-min ^3.0.0 -> ^4.2.0 in the 9 chart widgets and shared/charts
  • react-plotly.js ^2.6.0 -> ^4.1.0
  • Removed @types/plotly.js-dist-min and @types/react-plotly.js (v4 packages ship their own types; the old @types/plotly.js clashed with them)
  • Added plotly.js@^4.2.0 as a shared/charts devDependency so the react-plotly.js peer stops auto-resolving to 3.7.0 (it is never bundled; react-plotly.js/factory is used)
  • shared/charts moduleResolution: bundler so react-plotly.js/factory resolves
  • Type fixes: PlotData and Annotations no longer exist in v4; Layout["xaxis"] is now optional; a cast in CustomChartControllerHost
  • User-facing changelog entries for all 9 widgets; Custom Chart lists the breaking changes

Status

  • tsc, unit tests and rollup builds pass for all chart widgets and chart-playground
  • CI is green (build, release tasks on ubuntu/windows, code quality, all e2e shards, Sigrid, Snyk code/license). Snyk's security/snyk check still fails and is being ignored for this PR.
  • Expect possible visual diffs from the new automatic text contrast (WCAG) and bundle size growth (~4.9 MB -> ~6.2 MB unpacked).

Breaking changes for Custom Chart users

Mapbox traces removed (use scattermap etc.), stricter color parsing (fractional rgb(), hsv()), Chart Studio config options removed, geo.fitbounds / splom.axis.matches defaults changed. Migration guide: https://plotly.com/javascript/guides/migrating-to-v4/

Versioning (major bump for Custom Chart) is to be decided at release time.

Plotly.js 3.x bundles maplibre-gl 4.x (GHSA-jrc7-96c5-q579) and has no
backport. 4.2.0 bundles maplibre-gl 6.11.2.

- plotly.js-dist-min ^3 -> ^4.2.0 in all chart widgets and shared-charts
- react-plotly.js ^2.6 -> ^4.1; drop @types/plotly.js-dist-min and
  @types/react-plotly.js (v4 ships its own types)
- shared-charts: moduleResolution bundler to resolve react-plotly.js/factory
- adapt to v4 types (PlotData and Annotations removed)
@r0b1n r0b1n changed the title fix(charts): update plotly.js to v4 [WC-3671]: Update plotly.js to v4 Nov 17, 2026
@r0b1n
r0b1n marked this pull request as ready for review November 17, 2026 09:20
@r0b1n
r0b1n requested a review from a team as a code owner November 17, 2026 09:20
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

✅ Approved — no issues found


What was reviewed

Package Change
9 chart widgets (area, bar, bubble, column, custom, heatmap, line, pie-doughnut, time-series) plotly.js-dist-min bumped from ^3 to ^4.2.0, plus a CHANGELOG.md entry under [Unreleased] for each
custom-chart-web, heatmap-chart-web (src) Type-only changes for the v4 types: Annotations became Annotation, and Layout/Config casts were added in the controller
shared/charts v4 type adaptations (PlotData replaced by Data, NonNullable<Layout["xaxis"]>), moduleResolution: bundler, and dependency changes

Skipped (out of scope): pnpm-lock.yaml

CI: pending: AI Code Review (this review) · unrelated failures: security/snyk (external scanner, noted in the PR description as ignored). All other checks passed ✅, including the E2E shards, the release builds on ubuntu and windows, and code quality.


Questions

  • The Custom Chart changelog entry lists breaking changes under ### Changed, and the PR defers versioning to release time. Please make sure the release PR makes this a major bump for Custom Chart.

Positives

  • All 9 widgets have a user-facing changelog entry. Custom Chart spells out the breaking changes and links the Plotly migration guide.
  • The changes are limited to types and dependencies. No widget XML contract changed, and the Plotly v4 type adaptations in the diff look correct.
  • The PR description gives the security rationale (GHSA-jrc7-96c5-q579) and flags the expected bundle size growth and visual differences.

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.

3 participants