Skip to content

Fix crash when ordering categories by value with null coordinates#7855

Open
SAY-5 wants to merge 2 commits into
plotly:masterfrom
SAY-5:fix-categoryorder-null-crash
Open

Fix crash when ordering categories by value with null coordinates#7855
SAY-5 wants to merge 2 commits into
plotly:masterfrom
SAY-5:fix-categoryorder-null-crash

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 20, 2026

Copy link
Copy Markdown

Fixes #7840.

When categoryorder is set to a value-based order (e.g. sum descending, total ascending), sortAxisCategoriesByValue collects per-category values by indexing categoriesValue[catIndex]. A data point with a null/NaN category coordinate maps to BADNUM, so catIndex is undefined and categoriesValue[catIndex][1] throws TypeError: Cannot read properties of undefined (reading '1'), leaving the chart blank.

This skips points whose position is not a valid category, using the same catIndex + 1 guard already applied in the 2dMap branch above. Such points carry no category to order anyway. Added a regression test for a bar chart with a null x and sum descending.

SAY-5 added 2 commits June 19, 2026 18:20
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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]: X-Axis NULL values lead to typeError when using categoryorder sumdescending in barcharts

1 participant