GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Fix degenerate MultiPolygon centroids by swjturay · Pull Request #7921 · plotly/plotly.js

Conversation

@swjturay

@swjturay swjturay commented Jul 26, 2026

Copy link
Copy Markdown

Overview

Fixes #7874.

Prevent a zero-area MultiPolygon feature from aborting choropleth rendering. When centroid selection cannot find a positive-area sub-polygon, the feature now receives the existing [NaN, NaN] centroid sentinel. Its geometry remains available for rendering, while valid sibling features continue through extraction.

Root cause and user impact

The MultiPolygon centroid path initialized maxArea to zero and only selected sub-polygons whose area was strictly greater. If every sub-polygon had zero area, the selected polygon remained undefined and was passed to Turf's centroid helper, causing an uncaught TypeError that stopped the entire plot.

The guard is limited to that no-positive-area case. Centroid calculation for valid Polygon and MultiPolygon features is unchanged.

Validation

  • Added a regression test using the issue's two-distinct-vertex degenerate ring alongside a valid polygon.
  • Verified the regression test failed before the source change with Cannot read properties of undefined (reading 'type').
  • npm run test-jasmine -- lib_geo_location_utils choropleth --nowatch --report-spec — 37/37 passed (Chromium-based Edge via CHROME_BIN).
  • npm run test-syntax
  • npm run lint
  • git diff --check

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
RayWang added 2 commits July 26, 2026 20:59
RayWang
Fix degenerate MultiPolygon centroids
ad1ba11
RayWang
Add draft log for plotly#7921
23a9eb8
@swjturay
swjturay marked this pull request as ready for review July 26, 2026 13:01
@robertclaus
robertclaus requested a review from camdecoster July 27, 2026 19:15
@camdecoster

camdecoster commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR! I'll take a look and follow up.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@camdecoster camdecoster self-assigned this Jul 28, 2026
camdecoster added 3 commits July 31, 2026 09:40
@camdecoster
Add guard against rings with no points, log message
2888395
@camdecoster
Add more tests, update language
e2efd58
@camdecoster
Update draftlog
7454ee0
camdecoster
camdecoster approved these changes Jul 31, 2026
View reviewed changes

@camdecoster camdecoster left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for the fix! Your solution was spot on. While reviewing, I noticed another potential failure mode where polygon rings could have no points in the array so I added a guard against that as well (along with some more tests). I also added some logging similar to what we already do for invalid GeoJSON geometry.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@camdecoster
camdecoster merged commit b074563 into plotly:master Jul 31, 2026
85 of 86 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

@camdecoster camdecoster camdecoster approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@camdecoster camdecoster

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG]: choropleth with custom GeoJSON: a single malformed feature throws an uncaught TypeError and blanks the entire plot

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@swjturay @camdecoster
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.