[Feature] Readable outside labels for crowded pie and donut charts
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- d3, typescript
- Domain
- data-visualization
Research direction
Start with the existing radialRule and radialText marks and the pie(...) helper used in the snippet, to see how outside labels are positioned by slice angle today. The proposed radialLabels mark would need a side-by-side stacking and collision-resolution layout, so the API shape (new mark or a radialText option) should be agreed with maintainers before any code. Done means labels on both sides of the pie do not overlap, stay within chart bounds, hide lowest-priority labels first, and respect maxShift, with tests.
Written by the indexing model from the issue text.
Description
Problem
When a pie has many small, adjacent slices, outside labels made with
radialRule + radialText are placed on their slice angle and overlap.
There is no built-in way to spread or hide them, so apps must write their own
pixel layout.
const browsers = [
{ name: 'Chrome', share: 64.2 }, { name: 'Safari', share: 18.9 },
{ name: 'Edge', share: 5.4 }, { name: 'Firefox', share: 3.1 },
{ name: 'Samsung', share: 2.4 }, { name: 'Opera', share: 2.0 },
{ name: 'UC', share: 1.2 }, { name: 'Yandex', share: 0.9 },
{ name: 'Vivaldi', share: 0.7 }, { name: 'Brave', share: 0.6 },
{ name: 'Other', share: 0.6 },
]
Proposal
A radialLabels polar mark that draws outside labels with elbow connectors:
- labels stack on each side of the pie, in slice order;
- overlapping labels move apart as little as possible, inside the chart bounds;
- when a side is full, the lowest-
prioritylabels hide first (default:value, so the smallest slices); - optional
maxShifthides labels that would move too far from their slice.
radialLabels(pie(browsers, { value: 'share' }), {
text: (row) => `${row.name} ${row.share}%`,
key: 'name',
color: 'name',
maxShift: 24,
})
I have a working implementation with tests and docs, and can open a PR if this direction fits.
Happy to change the API shape (for example, an option on radialText instead of a new mark).
- Dominant language
- TypeScript
- Stars
- 819
- Forks
- 49
- Avg merge
- 4h 40m
- Merged PRs (30d)
- 16
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TanStack/charts
-
[Bug] Focus guides: `url(#id)` paints ignore `idPrefix`Possibly taken @getdownandcode claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
TanStack/charts#211 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug] Printed charts keep their screen width: resize redraw waits for an animation framePossibly taken @piecyk claimed this 1 day ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 25/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 57/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Maintainers usually reply within 1 day
Similar issues
-
documentation good first issue
Difficulty 2/5 Half a day Newbie friendliness 72/100
sujithputta02/Esapay#13 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
ehmpathy/rhachet-roles-bhuild#468 ·
Maintainers usually reply within 1 day
-
Share dialog: the address book's contact count reads "1 contacts" (no singular form in any language)Possibly taken @chibenwa claimed this today. Openai-driven-qa bug claude Cosmetic
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
linagora/twake-contacts-frontend#271 · 1 comment ·
Maintainers usually reply within 1 day
-
factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Koenkk/zigbee2mqtt#33402 ·
Maintainers usually reply within 1 day