Skip to content

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

Merged
camdecoster merged 3 commits into
plotly:masterfrom
SAY-5:fix-categoryorder-null-crash
Jul 2, 2026
Merged

camdecoster merged 3 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
Contributor

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>
@camdecoster camdecoster self-assigned this Jun 24, 2026
@camdecoster

Copy link
Copy Markdown
Contributor

Thanks for the PR! I'll review this and follow up with you.

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good fix. I left you one comment.

Comment thread src/plots/plots.js Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants