Skip to content

fix(pie): apply percentage number format to labels - #42880

Open
EvanGruhlkey wants to merge 2 commits into
apache:masterfrom
EvanGruhlkey:fix/pie-percentage-number-format
Open

fix(pie): apply percentage number format to labels#42880
EvanGruhlkey wants to merge 2 commits into
apache:masterfrom
EvanGruhlkey:fix/pie-percentage-number-format

Conversation

@EvanGruhlkey

@EvanGruhlkey EvanGruhlkey commented Aug 7, 2026

Copy link
Copy Markdown

Apply a selected percentage-style D3 number format to pie chart percentages instead of always using the hardcoded two-decimal formatter. Non-percentage number formats retain the existing percentage formatting behavior.

This affects percentage values rendered in pie labels, templates, tooltips, and grouped "Other" tooltip rows.

Fixes #42834

@EvanGruhlkey
EvanGruhlkey marked this pull request as ready for review August 7, 2026 06:27
@dosubot dosubot Bot added the viz:charts:pie Related to the Pie chart label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.37%. Comparing base (38ba4a6) to head (b5dfd83).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42880      +/-   ##
==========================================
+ Coverage   57.10%   66.37%   +9.26%     
==========================================
  Files        2857     2857              
  Lines      161125   161049      -76     
  Branches    37060    37049      -11     
==========================================
+ Hits        92014   106890   +14876     
+ Misses      68259    52143   -16116     
- Partials      852     2016    +1164     
Flag Coverage Δ
javascript 73.19% <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.

@bito-code-review

bito-code-review Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #472e84

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 0506aae..0506aae
    • superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/Pie/transformProps.test.ts
  • 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

@sadpandajoe

Copy link
Copy Markdown
Member

@EvanGruhlkey thanks for the PR! Since there is a visual component to your change, can you add before and after screenshots of your fix into the PR description?

@sadpandajoe
sadpandajoe requested a review from SBIN2010 August 7, 2026 17:16
Comment on lines +303 to +305
const percentFormatter = numberFormat.endsWith('%')
? getNumberFormatter(numberFormat)
: defaultPercentFormatter;

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.

Suggestion: Calling endsWith directly on numberFormat can throw when an older or partially populated chart payload explicitly provides number_format: undefined (or null). The merged form data then overwrites DEFAULT_PIE_FORM_DATA, while getValueFormatter already accepts an absent format. Guard the value before checking its suffix so such charts continue to render. [null pointer]

Severity Level: Major ⚠️
- ❌ Legacy pie charts with null formats fail transformation.
- ❌ Pie labels and tooltips do not render.
- ⚠️ Dashboard hydration preserves malformed form values.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts
**Line:** 303:305
**Comment:**
	*Null Pointer: Calling `endsWith` directly on `numberFormat` can throw when an older or partially populated chart payload explicitly provides `number_format: undefined` (or `null`). The merged form data then overwrites `DEFAULT_PIE_FORM_DATA`, while `getValueFormatter` already accepts an absent format. Guard the value before checking its suffix so such charts continue to render.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. Calling endsWith on numberFormat will throw a TypeError if numberFormat is null or undefined. To resolve this, you should add a nullish check or optional chaining before calling endsWith.

Here is the corrected implementation for superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:

  const percentFormatter = numberFormat?.endsWith('%')
    ? getNumberFormatter(numberFormat)
    : defaultPercentFormatter;

There are no other comments on this pull request to address.

superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts

const percentFormatter = numberFormat?.endsWith('%')
    ? getNumberFormatter(numberFormat)
    : defaultPercentFormatter;

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

Labels

plugins size/S viz:charts:pie Related to the Pie chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pie Charts do not format Percentage values correctly

2 participants