Skip to content

Conversation

@huaxiabuluo
Copy link
Contributor

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @huaxiabuluo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where annotation lines in pie charts could obscure the chart itself. The core fix involves refining the label positioning logic by sorting labels vertically before rendering, which significantly reduces overlaps. Additionally, a new test case has been introduced to validate the behavior of spider-type pie labels when handling data slices with zero values, thereby enhancing the overall stability and correctness of the component's rendering.

Highlights

  • Pie Label Positioning: Implemented a sorting mechanism for pie chart labels based on their Y-coordinate. This ensures that labels are processed in a consistent vertical order, which helps prevent annotation lines from overlapping or obscuring the pie chart, directly addressing the reported issue.
  • Robustness for Zero Values: Added a new test case to specifically verify the correct rendering of spider-type pie labels when a data slice has a zero value. This improves the component's robustness and ensures proper visual representation for edge cases.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

这个 PR 修复了 PieLabel 标注线可能会遮挡饼图的问题。通过在调整标签位置之前按 y 坐标对标签进行排序,可以防止标签重叠。同时,还增加了一个新的测试用例,覆盖了值为 0 的数据点场景,这很可能就是触发原始 bug 的原因。这个修复是合理的,但在 adjustPosition 函数中有一个小改进可以避免修改输入数组,我已对此提出了评论。

let delta;

half.forEach((label) => {
const sortedHalf = half.sort((a, b) => a.y - b.y);

Choose a reason for hiding this comment

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

medium

sort() 方法会对数组进行原地排序,这意味着作为参数传入的 half 数组被修改了。这是一个副作用,如果代码的其他部分依赖于 half 数组的原始顺序,可能会导致难以发现的 bug。最佳实践是函数不应修改其输入,除非这是其明确的目的。你可以在排序前创建一个数组的浅拷贝来避免这个问题。

Suggested change
const sortedHalf = half.sort((a, b) => a.y - b.y);
const sortedHalf = [...half].sort((a, b) => a.y - b.y);

@github-actions
Copy link

github-actions bot commented Nov 12, 2025

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
f2/dist/index.js = 1,706.38 kB 1,706.38 kB = 323.03 kB 323.03 kB
f2/dist/index.min.js = 532.93 kB 532.93 kB = 160.21 kB 160.21 kB

Significant size changes

Includes any change greater than 0.2%:
(No significant changes)

Generated by 🚫 dangerJS against b551db7

Copy link
Contributor

Choose a reason for hiding this comment

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

效果上是不是应该在左上边,因为是最后一个数据,第一个数据是0的话应该在右边(第一象限)

let delta;

half.forEach((label) => {
const sortedHalf = half.sort((a, b) => a.y - b.y);
Copy link
Contributor

Choose a reason for hiding this comment

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

这样可以绕过去,但感觉应该改锚点角度 锚点坐标那边?两种布局应该都有这个问题

@huaxiabuluo huaxiabuluo force-pushed the fix-pielabel-occlusion branch from 40eec53 to b551db7 Compare November 13, 2025 12:07
const inflectionPoint = getEndPoint(center, anchorAngle, radius + inflectionOffset);
// 锚点方向
const side = anchorPoint.x < center.x ? 'left' : 'right';
const side = anchorPoint.x <= center.x ? 'left' : 'right';
Copy link
Contributor

Choose a reason for hiding this comment

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

这样改第一个数据也会变到左边。但标签应该是有顺序的,从右边(第一象限)绕一圈到左边第四象限

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.

3 participants