Skip to content

Apply table cells.format only to numeric cell values - #8178

Open
Eliot5566 wants to merge 2 commits into
plotly:mainfrom
Eliot5566:fix-table-format-strings
Open

Eliot5566 wants to merge 2 commits into
plotly:mainfrom
Eliot5566:fix-table-format-strings

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 09:51
cells.format holds number formats. A non-numeric cell such as
'rgb(8, 81, 156)' went through the number formatter and showed NaN.
Keep the text of such cells, because the format applies only to numbers.

Fixes plotly/plotly.py#5617

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

This branch has not been deployed

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

Labels

None yet

1 participant