Skip to content

[BUGFIX] (piechart): hide slice labels that do not fit - #907

Open
colivi wants to merge 1 commit into
perses:mainfrom
colivi:fix/piechart-hide-small-slice-labels
Open

colivi wants to merge 1 commit into
perses:mainfrom
colivi:fix/piechart-hide-small-slice-labels

Conversation

@colivi

@colivi colivi commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Description

Inner labels overlap when a slice is too small to hold the text, this contribution skips slices under 5% and drop a label that still collides with another.

Screenshots

  • before:
pie-before
  • after:
pie-after

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

Inner labels overlap when a slice is too small to hold the text.
Skip slices under 5% and drop a label that still collides with another.

Signed-off-by: colivi <charles.olivi@gmail.com>
@colivi
colivi requested a review from a team as a code owner October 31, 2026 18:38
@colivi
colivi requested review from Gladorme and removed request for a team October 31, 2026 18:38
@AntoineThebaud
AntoineThebaud requested a lite review from Copilot October 31, 2026 23:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test does not exercise the below-5% slice or label-overlap behavior it claims to cover, so it cannot detect regressions in that functionality.

1 open issue
What changed in this PR

This pull request improves pie chart readability by hiding labels for slices that are too small or overlap with other labels.

Changes:

  • Adds an 18° minimum slice angle for displaying labels.
  • Enables ECharts overlap hiding for pie labels.
  • Adds test coverage for the generated chart options.
File Summary Review note
piechart/​src/​PieChartBase.tsx Configures minimum slice angle and overlap hiding for pie labels. —
piechart/​src/​PieChartBase.test.tsx Verifies that the new label-layout options are passed to ECharts. Nit: The regression test uses empty data, so it does not exercise small slices or overlapping labels. Consider using representative non-empty data and asserting the resulting label visibility.

Review effort: Lite

Comment on lines +97 to +100
it('omits labels that cannot fit in a slice', () => {
render(
<ChartsProvider chartsTheme={testChartsTheme}>
<PieChartBase width={400} height={300} data={EMPTY_DATA} showLabels outerRadius={90} />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants