Skip to content

feat(pie): geometric recentering and scaling for partial arcs#42151

Open
rusackas wants to merge 2 commits into
masterfrom
feat/pie-geometric-recentering
Open

feat(pie): geometric recentering and scaling for partial arcs#42151
rusackas wants to merge 2 commits into
masterfrom
feat/pie-geometric-recentering

Conversation

@rusackas

@rusackas rusackas commented Jul 18, 2026

Copy link
Copy Markdown
Member

SUMMARY

Follow-up to #35459, which added Start angle / Sweep angle controls to the Pie chart with a hardcoded layout table that only recentered half-donuts at exact cardinal start angles (0°/90°/180°/270°), and left partial arcs at full-circle sizing (so a half donut wasted roughly half the canvas).

This PR replaces that table with layout derived from the arc's actual geometry:

  • getArcBoundingBox computes the arc's bounding box from the start/sweep angles and inner radius (outer endpoints, inner endpoints, and every axis extreme the arc sweeps through).
  • getPieLayout scales the radius until that box fills the padded series rect, capped at the 2× factor a quarter arc reaches naturally, and shifts the pie origin so the box is centered. Partial arcs reclaim the space a full circle would leave empty.
  • Recentering applies to any start/sweep combination, which removes the behavior cliff where nudging the start angle from 180° to 170° made the chart jump off-center.
  • The Total label is anchored on the pie origin with align/verticalAlign centering instead of empirically tuned percentage offsets, and is clamped into the arc's box so narrow arcs keep it on-canvas. With side legends the label is centered exactly in the padded rect rather than approximated with fudge factors.
  • A full circle reproduces the ECharts default layout exactly, so existing charts are unchanged (locked in by tests).

The magic-constant table, getHalfDonut, and getTotalValuePadding are deleted; the sweep-angle control description is updated accordingly and translation catalogs are synced for the reworded string.

Verified visually across a 12-configuration matrix (full, all four halves, quarter, non-cardinal 170°, diagonal 45°, 20° sliver, 270° arc, legend padding, non-donut half) rendered with ECharts.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: a half donut with Start angle 170° rendered off-center at full-circle size; only exact cardinal angles recentered, without scaling.
After: every partial arc is centered and scaled to use the available space.

TESTING INSTRUCTIONS

  1. Create a Pie chart, enable Donut, and set Sweep angle to 180°. The chart should render centered and noticeably larger than before.
  2. Try Start angle values that are not multiples of 90° (e.g. 170°): the chart stays centered instead of jumping.
  3. Set Sweep angle to 90° for a quarter donut: it scales up to fill the canvas.
  4. Enable Show Total with and without legends on each side; the total stays centered on the donut hole (or the top of the chart for non-donut pies).
  5. A full 360° sweep renders identically to current master.

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

🤖 Generated with Claude Code

Follow-up to #35459. Replaces the hardcoded half-donut layout table with
geometry derived from the arc itself:

- getArcBoundingBox computes the arc's bounding box from the start/sweep
  angles and inner radius (outer endpoints, inner endpoints, and every
  axis extreme the arc sweeps through)
- getPieLayout scales the radius until the box fills the padded series
  rect (capped at the 2x factor a quarter arc reaches naturally) and
  shifts the pie origin so the box is centered, so partial arcs reclaim
  the space a full circle would leave empty
- Recentering applies to ANY start/sweep combination, removing the
  previous behavior cliff at non-cardinal start angles
- The Total label anchors on the pie origin via graphic text
  align/verticalAlign instead of tuned percentage offsets, clamped into
  the arc box so narrow arcs keep it on-canvas
- A full circle reproduces the ECharts default layout exactly, so
  existing charts are unchanged
- Sweep-angle control description updated; translation catalogs synced

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added i18n Namespace | Anything related to localization i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language plugins i18n:dutch i18n:slovak i18n:ukrainian i18n:portuguese i18n:brazilian i18n:traditional-chinese i18n:persian i18n:czech i18n:latvian labels Jul 18, 2026
@dosubot dosubot Bot added change:frontend Requires changing the frontend i18n:general Related to translations viz:charts:pie Related to the Pie chart labels Jul 18, 2026

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #ac672d

Actionable Suggestions - 10
  • superset/translations/zh/LC_MESSAGES/messages.po - 1
  • superset/translations/sl/LC_MESSAGES/messages.po - 1
  • superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts - 2
  • superset/translations/ja/LC_MESSAGES/messages.po - 1
  • superset/translations/sr_Latn/LC_MESSAGES/messages.po - 1
  • superset/translations/es/LC_MESSAGES/messages.po - 1
  • superset/translations/fr/LC_MESSAGES/messages.po - 1
  • superset/translations/it/LC_MESSAGES/messages.po - 1
  • superset/translations/ca/LC_MESSAGES/messages.po - 1
Additional Suggestions - 8
  • superset/translations/tr/LC_MESSAGES/messages.po - 1
    • Incomplete Turkish translation · Line 16623-16623
      Turkish translation for 'Total angle covered by the chart' (lines 16623-16626) has empty msgstr. Turkish-speaking users will see untranslated English text. Per BITO.md rule [13343], all user-facing messages must have complete translations before merging.
  • superset/translations/pt/LC_MESSAGES/messages.po - 1
    • Missing Portuguese translation · Line 24662-24662
      The `msgstr` for this entry is empty, leaving the help text untranslated for Portuguese users. Rule [12743] requires complete translation coverage for all user-facing messages before merging.
  • superset/translations/pt_BR/LC_MESSAGES/messages.po - 1
    • Incomplete Portuguese translation · Line 17447-17451
      The msgstr field for the "Total angle covered by the chart" entry is empty (line 17451). Portuguese users will see untranslated English text when configuring chart sweep angles. Rule [12665] prohibits merging unreviewed entries with empty translations. Rule [12743] requires complete translation coverage for all user-facing messages. Rule [13346] requires validation of technical term translations like "degrees" and "arcs".
  • superset/translations/ar/LC_MESSAGES/messages.po - 1
    • Incomplete translation needs filling · Line 17322-17326
      The msgstr at line 17326 remains empty after the source text was updated. Arabic users will see untranslated English text for this chart configuration tooltip. Per BITO.md rule [13343], complete translations are required before merging.
  • superset/translations/sk/LC_MESSAGES/messages.po - 1
    • Missing Slovak translation · Line 16156-16156
      The msgstr is empty but the msgid has been updated with new source text. Slovak users will see untranslated English text instead of their native language. Per BITO.md rule [12743], all user-facing messages require complete translations for every supported language before merging. Add the Slovak translation to ensure consistent user experience for Slovak-speaking users. ([CWE-164](https://cwe.mitre.org/data/definitions/164.html))
  • superset/translations/pl/LC_MESSAGES/messages.po - 1
    • Incomplete translation needs filling · Line 17756-17756
      The msgstr remains empty after the msgid was updated. Polish translation needs to be added for this tooltip text describing the sweep angle behavior. Rule 12743 requires complete translation coverage for all user-facing messages.
  • superset/translations/lv/LC_MESSAGES/messages.po - 1
    • Missing translation for updated msgid · Line 15792-15795
      The source text for 'Total angle covered' has been updated to match the implementation in `controlPanel.tsx` (lines 326-329), but the Latvian translation remains empty (`msgstr ""`). Provide a translation to complete localization for Latvian users.
  • superset/translations/de/LC_MESSAGES/messages.po - 1
    • Incomplete German translation · Line 15800-15803
      The English tooltip text was updated (partial arcs re-centering behavior), but the `msgstr` at line 15803 remains empty. Consider providing the German translation to complete this entry per translation coverage standards.
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/translations/ro/LC_MESSAGES/messages.po - 1
  • superset/translations/th/LC_MESSAGES/messages.po - 1
Review Details
  • Files reviewed - 34 · Commit Range: 45c4c97..45c4c97
    • superset-frontend/plugins/plugin-chart-echarts/src/Pie/controlPanel.tsx
    • superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/src/Pie/types.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts
    • superset/translations/ar/LC_MESSAGES/messages.po
    • superset/translations/ca/LC_MESSAGES/messages.po
    • superset/translations/cs/LC_MESSAGES/messages.po
    • superset/translations/de/LC_MESSAGES/messages.po
    • superset/translations/en/LC_MESSAGES/messages.po
    • superset/translations/es/LC_MESSAGES/messages.po
    • superset/translations/fa/LC_MESSAGES/messages.po
    • superset/translations/fi/LC_MESSAGES/messages.po
    • superset/translations/fr/LC_MESSAGES/messages.po
    • superset/translations/it/LC_MESSAGES/messages.po
    • superset/translations/ja/LC_MESSAGES/messages.po
    • superset/translations/ko/LC_MESSAGES/messages.po
    • superset/translations/lv/LC_MESSAGES/messages.po
    • superset/translations/messages.pot
    • superset/translations/mi/LC_MESSAGES/messages.po
    • superset/translations/nl/LC_MESSAGES/messages.po
    • superset/translations/pl/LC_MESSAGES/messages.po
    • superset/translations/pt/LC_MESSAGES/messages.po
    • superset/translations/pt_BR/LC_MESSAGES/messages.po
    • superset/translations/ro/LC_MESSAGES/messages.po
    • superset/translations/ru/LC_MESSAGES/messages.po
    • superset/translations/sk/LC_MESSAGES/messages.po
    • superset/translations/sl/LC_MESSAGES/messages.po
    • superset/translations/sr/LC_MESSAGES/messages.po
    • superset/translations/sr_Latn/LC_MESSAGES/messages.po
    • superset/translations/th/LC_MESSAGES/messages.po
    • superset/translations/tr/LC_MESSAGES/messages.po
    • superset/translations/uk/LC_MESSAGES/messages.po
    • superset/translations/zh/LC_MESSAGES/messages.po
    • superset/translations/zh_TW/LC_MESSAGES/messages.po
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Comment thread superset/translations/zh/LC_MESSAGES/messages.po
Comment thread superset/translations/sl/LC_MESSAGES/messages.po
Comment thread superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts Outdated
Comment thread superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts Outdated
Comment thread superset/translations/ja/LC_MESSAGES/messages.po
Comment thread superset/translations/sr_Latn/LC_MESSAGES/messages.po
Comment thread superset/translations/es/LC_MESSAGES/messages.po
Comment thread superset/translations/fr/LC_MESSAGES/messages.po
Comment thread superset/translations/it/LC_MESSAGES/messages.po
Comment thread superset/translations/ca/LC_MESSAGES/messages.po
@codecov

codecov Bot commented Jul 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.07%. Comparing base (91f814a) to head (7cec2d4).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42151   +/-   ##
=======================================
  Coverage   65.06%   65.07%           
=======================================
  Files        2758     2758           
  Lines      155222   155224    +2     
  Branches    35570    35560   -10     
=======================================
+ Hits       101002   101010    +8     
+ Misses      52305    52299    -6     
  Partials     1915     1915           
Flag Coverage Δ
hive 38.94% <ø> (ø)
javascript 70.75% <100.00%> (+<0.01%) ⬆️
mysql 57.62% <ø> (ø)
postgres 57.68% <ø> (ø)
presto 40.90% <ø> (ø)
python 59.10% <ø> (ø)
sqlite 57.30% <ø> (ø)
unit 100.00% <ø> (ø)

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.

@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for 45c4c97

Environment: http://52.39.23.249:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

…tion

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added 🎪 7cec2d4 🚦 building 🎪 7cec2d4 📅 2026-07-18T02-16 Environment 7cec2d4 created at 2026-07-18T02-16 🎪 7cec2d4 🤡 rusackas Environment 7cec2d4 requested by rusackas 🎪 ⌛ 48h Environment expires after 48 hours (default) labels Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime is building environment on GHA for 7cec2d4

@github-actions github-actions Bot added 🎪 7cec2d4 🚦 deploying 🎪 7cec2d4 🚦 running Environment 7cec2d4 status: running 🎪 7cec2d4 🌐 34.220.30.183:8080 Environment 7cec2d4 URL: http://34.220.30.183:8080 (click to visit) and removed 🎪 7cec2d4 🚦 building 🎪 7cec2d4 🚦 running Environment 7cec2d4 status: running labels Jul 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎪 Showtime deployed environment on GHA for 7cec2d4

Environment: http://34.220.30.183:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@bito-code-review

bito-code-review Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #915419

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 45c4c97..7cec2d4
    • superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@SBIN2010 SBIN2010 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.

Thanks for the improvements! It turned out great.
For the sake of code cleanliness, it’s better to move the interfaces to a types file. Otherwise —
LGTM!

right: { centerOffset: { x: -10, y: 0 }, totalBase: { left: 35, top: 50 } },
none: { centerOffset: { x: 0, y: 0 }, totalBase: { left: 50, top: 50 } },
};
export interface ArcBoundingBox {

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.

It’s probably better to move this to types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I went back and forth on this, but I think it's fine where it is. ArcBoundingBox is tightly coupled to getArcBoundingBox right below it and only used internally (plus in tests). legendLayout.ts and treeBuilder.ts do the same co-location elsewhere in this plugin, so it matches the local convention. types.ts feels more like the place for the form data/props contract.

*/
const MAX_RADIUS_SCALE = 2;

export interface PieLayout {

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.

And it's better to move this to types.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same reasoning as above, PieLayout is an implementation detail of getPieLayout right below it, not part of the shared props/form-data contract in types.ts.

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

Labels

change:frontend Requires changing the frontend i18n:brazilian i18n:chinese Translation related to Chinese language i18n:czech i18n:dutch i18n:french Translation related to French language i18n:general Related to translations i18n:italian Translation related to Italian language i18n:japanese Translation related to Japanese language i18n:korean Translation related to Korean language i18n:latvian i18n:persian i18n:portuguese i18n:russian Translation related to Russian language i18n:slovak i18n:spanish Translation related to Spanish language i18n:traditional-chinese i18n:ukrainian i18n Namespace | Anything related to localization plugins preset-io size/XL viz:charts:pie Related to the Pie chart 🎪 7cec2d4 🚦 running Environment 7cec2d4 status: running 🎪 7cec2d4 🤡 rusackas Environment 7cec2d4 requested by rusackas 🎪 7cec2d4 🌐 34.220.30.183:8080 Environment 7cec2d4 URL: http://34.220.30.183:8080 (click to visit) 🎪 7cec2d4 📅 2026-07-18T02-16 Environment 7cec2d4 created at 2026-07-18T02-16 🎪 ⌛ 48h Environment expires after 48 hours (default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants