Skip to content

fix(pie): center pies in Cartodiagram when the chart size is unknown - #46478

Open
schizophrenicmaniac wants to merge 2 commits into
apache:masterfrom
schizophrenicmaniac:fix/46477-pie-chart-are-not-correctly-displayed
Open

schizophrenicmaniac wants to merge 2 commits into
apache:masterfrom
schizophrenicmaniac:fix/46477-pie-chart-are-not-correctly-displayed

Conversation

@schizophrenicmaniac

Copy link
Copy Markdown
Contributor

SUMMARY

Since #42151 the Pie chart works out its center in pixels from the chart's width and height (getPieLayout). The Cartodiagram builds the pie props once with width/height set to null, on purpose so resizing on zoom doesn't trigger extra updates, and then renders each pie at a zoom-dependent size. With a null size the layout rect collapsed to 1x1 px, so every pie on the map was drawn around the top-left corner of its box.

When no size is available, getPieLayout now lays the arc out in a 100x100 square and returns the center as percentages, which ECharts resolves against the real size when rendering. For a full pie this is the usual ['50%', '50%'] with unscaled radii, as in 6.1. Partial arcs keep their recentering, which is exact for square charts (the Cartodiagram default). The "Total" label also relied on pixel coordinates, so in that case it falls back to ECharts' left/top positioning. Charts that pass a size are unchanged.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: see the screenshot in #46477 (pies stuck in the top-left corner of each box). After screenshots still to be added.

TESTING INSTRUCTIONS

  1. Create a Pie chart on a dataset that has a point geometry column, then create a Cartodiagram that uses that dataset and Pie chart (the dataset in Pie chart are not correctly displayed in cartodiagram #46477 works).
  2. Open the Cartodiagram in Explore and on a dashboard, and zoom in and out.
  3. Each pie should be centered on its location at every zoom level. Also try a donut with "Show total" on and a half donut (start angle 180, swept angle 180).
  4. Check that regular Pie charts outside the Cartodiagram look the same as before.

Unit tests: npm run test -- plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts plugins/plugin-chart-cartodiagram

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Pie chart are not correctly displayed in cartodiagram #46477
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: d90e7f5c5fca

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.93%. Comparing base (174aa90) to head (b3fa927).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #46478   +/-   ##
=======================================
  Coverage   85.93%   85.93%           
=======================================
  Files        3122     3122           
  Lines      217023   217034   +11     
  Branches    51450    51459    +9     
=======================================
+ Hits       186491   186502   +11     
  Misses      27112    27112           
  Partials     3420     3420           
Flag Coverage Δ
javascript 82.75% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas

Copy link
Copy Markdown
Member

CC @jansule

…layed

# Conflicts:
#	superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pie chart are not correctly displayed in cartodiagram

2 participants