Skip to content

fix: spread crowded pie chart labels and fan out their leader lines - #2780

Closed
gadfly3173 wants to merge 1 commit into
sourcegit-scm:developfrom
gadfly3173:fix/pie-chart-label-overlap
Closed

gadfly3173 wants to merge 1 commit into
sourcegit-scm:developfrom
gadfly3173:fix/pie-chart-label-overlap

Conversation

@gadfly3173

@gadfly3173 gadfly3173 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

When many authors hold similar small percentages, their labels were anchored only a few pixels apart and every leader line shared a single vertical elbow, so names overlapped and lines became impossible to tell apart.

Extract label drawing into DrawLabels, spread overlapping labels vertically via ArrangeLabels (shrinking the gap when a side runs out of room), and route each leader line straight from the arc edge to its own label anchor so the line-to-name mapping stays one-to-one readable. Also invalidate the visuals when SecondaryFontFamily changes.

Before:
1791862025157
image

After:
image
image

Increasing the single-author minimum threshold cannot completely solve this problem, for example, in this case:

image

When many authors hold similar small percentages, their labels were
anchored only a few pixels apart and every leader line shared a single
vertical elbow, so names overlapped and lines became impossible to
tell apart.

Extract label drawing into DrawLabels, spread overlapping labels
vertically via ArrangeLabels (shrinking the gap when a side runs out
of room), and route each leader line straight from the arc edge to its
own label anchor so the line-to-name mapping stays one-to-one readable.
Also invalidate the visuals when SecondaryFontFamily changes.
@love-linger

Copy link
Copy Markdown
Collaborator
  • 由于竖直空间总是有限的,一旦显示的行数超出可用空间上限总是会产生Overlap
  • 这种显示方式在某些情况下会导致无法辨别线的实际指向
image

我之前也实现了一种方案,但想着有了ToolTip,用户可以直接移动鼠标去看更方便,就没有提交
image

@love-linger

Copy link
Copy Markdown
Collaborator

@love-linger

Copy link
Copy Markdown
Collaborator

重新优化了一下

image

最极端情况,如上面举例

image

如果你想使用,以下是相关代码(目前不打算提交修改)

patch-for-pie-chart.patch

@JC-Chung

Copy link
Copy Markdown
Contributor

I ran into the same issue and prototyped a fix in #2757 (comment) (screenshots there show the overlapping labels with small adjacent slices).

My approach was similar in spirit:

  • Sort labels per side by their ideal Y position (projected from each slice's mid-angle), then push them down as needed to keep a minimum vertical gap.
  • When more labels exist on one side than can fit vertically, labels for the smallest slices are dropped instead of overlapping — the slices still show details via the hover tooltip, so no information is lost.

That directly addresses the two concerns raised above: the drop step guarantees labels never exceed the available vertical space, and only labels that fit are drawn, so every visible leader line still points unambiguously at its slice.

Happy to share the branch/commit if it's useful for comparison.

@gadfly3173

Copy link
Copy Markdown
Contributor Author
image 如果你想使用,以下是相关代码(目前不打算提交修改)

patch-for-pie-chart.patch圆饼图补丁

我觉得这个看起来不错

@love-linger

Copy link
Copy Markdown
Collaborator

@JC-Chung 我测试了你的相关提交,对于上面相同的情况(UnrealEngine仓库)

image

@love-linger

Copy link
Copy Markdown
Collaborator

我已经交我本地的修改推送了

@love-linger

Copy link
Copy Markdown
Collaborator

需要说明的是,该实现也不能处理单侧显示的Author太多的问题(因为空间是有限的)。比如:下图中,尽管右下方已经每行显示两个提交者了,但仍有3个(最后的红、黄、绿线)未被显示出来

image

@Mingun

Mingun commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

The last examples shows, that you need to rotate pie so that each side gets approximately equal count of sectors.

Also, currently the inflection point of all leaders placed on the same circle, which produces bad results as in #2780 (comment). Need to decrease circle radius when label and inflection point have big difference on Y coordinate.

@gadfly3173
gadfly3173 deleted the fix/pie-chart-label-overlap branch October 15, 2026 01:58
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.

4 participants