Skip to content

Split scattergl tozero fills where the line crosses zero - #8181

Open
Eliot5566 wants to merge 2 commits into
plotly:mainfrom
Eliot5566:fix-scattergl-fill-tozero
Open

Eliot5566 wants to merge 2 commits into
plotly:mainfrom
Eliot5566:fix-scattergl-fill-tozero

Conversation

@Eliot5566

Copy link
Copy Markdown

Fixes plotly/plotly.py#5617.

cells.format holds a number format. A cell with a non-numeric value, such as 'rgb(8, 81, 156)', went through the number formatter and showed NaN. With this change, the format applies only to numeric values (fast-isnumeric). Other cells keep their text. The attribute description already limits the format to numbers.

The issue says Plotly.restyle(gd, {'cells.format': [1]}, [0]) shows the text. That call sets the format of trace 0 to the scalar 1. coerce rejects a scalar for a data_array, so no format applies.

Behavior change for reviewers: a null or empty cell in a formatted column used to show 0.00 (for .2f). It now shows the same text as a column without a format (null or an empty cell).

Tests:

  • New jasmine test in table_test.js: applies cells.format only to numeric values. It fails on main with NaN cells.
  • I ran table_test.js in headless Chrome: 26 of 26 pass. npm run lint, npm run typecheck and npm run test-syntax pass.
  • Image baselines: no table mock sets cells.format on a column with non-numeric values, so I expect no baseline change.

Before and after, rendered from local bundles with the example from the issue:

Before After
before after

The draftlog is draftlogs/PR_NUMBER_fix.md; I will rename it to this PR's number in the next commit.

I used Claude to help write and test this change, and reviewed the diff before opening the PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3

Eliot5566 and others added 2 commits November 20, 2026 14:54
A scattergl tozeroy or tozerox fill was one polygon closed along the zero
line. When the line crosses zero, that closing edge crosses the line, and
the triangulation of the self-intersecting polygon fills the wrong areas.
Close the polygon on the zero line at each crossing and at each point on
zero, start a new one there, and split the fill at the null point between
them. Gaps are skipped, so the fill goes across them as in SVG scatter.

Fixes plotly#4017

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
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.

[BUG]: Table string cells render as NaN when cells.format is set before initial render, but Plotly.restyle renders correctly

1 participant