Skip to content

fix(funnel): 修复漏斗图图例操作后显示错误#3874

Open
taoeer wants to merge 1 commit intoantvis:masterfrom
taoeer:fix-funnel
Open

fix(funnel): 修复漏斗图图例操作后显示错误#3874
taoeer wants to merge 1 commit intoantvis:masterfrom
taoeer:fix-funnel

Conversation

@taoeer
Copy link

@taoeer taoeer commented Feb 3, 2026

PR includes

Screenshot

Before After

@github-actions github-actions bot added the bugfix label Feb 3, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @taoeer, 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!

此拉取请求旨在解决漏斗图在用户进行图例操作后出现的显示错误。核心改动在于优化了数据转换逻辑,通过采用不可变数据操作的方式,确保每次数据处理都生成新的数据副本,从而避免了因数据意外修改而导致的渲染问题,提升了图表的稳定性和交互体验。

Highlights

  • 修复漏斗图显示错误: 此PR修复了漏斗图在图例操作后可能出现的显示错误。
  • 数据转换逻辑优化: 通过修改 transformData 函数,确保数据转换时返回新的数据对象,而非直接修改原始数据行,从而避免了潜在的副作用和数据突变问题。
Changelog
  • src/plots/funnel/geometries/common.ts
    • 修改了 transformData 函数,使其在处理数据时返回一个新的数据对象,而不是直接修改传入的 row 对象,以实现数据不可变性。
Activity
  • 拉取请求由 taoeer 创建。
  • 此更改旨在修复 🐛 [BUG] 漏斗图点击图例后展示错误 #3873 中描述的问题。
  • PR 描述中包含前后对比截图,清晰展示了问题已得到解决。
  • PR 描述中未明确指出增加了或修改了测试用例或文档。
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 通过在 transformData 函数中采用不可变(immutable)的方式处理数据,修复了漏斗图在图例交互后可能出现的显示错误,这是一个很好的改进。我添加了一条评论,建议增加相应的测试用例来防止未来的回归。除此之外,代码修改看起来很棒。

Comment on lines 26 to 34
formatData = map(data, (row, index) => {
const percent = (row[yField] || 0) / maxYFieldValue;
row[FUNNEL_PERCENT] = percent;
row[FUNNEL_MAPPING_VALUE] = (max - min) * percent + min;
// 转化率数据存储前后数据
row[FUNNEL_CONVERSATION] = [get(data, [index - 1, yField]), row[yField]];
return row;
return {
...row,
[FUNNEL_PERCENT]: percent,
[FUNNEL_MAPPING_VALUE]: (max - min) * percent + min,
[FUNNEL_CONVERSATION]: [get(data, [index - 1, yField]), row[yField]],
};
});

Choose a reason for hiding this comment

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

medium

这个修改很棒,通过返回新对象而不是修改原始对象,避免了副作用。为了保证这个修复的长期有效性并防止回归,建议增加一个单元测试来验证 transformData 的调用不会修改传入的 data 数组中的对象。例如,可以在测试中保留一份原始数据的副本,并在调用 render 后断言原始数据未被更改。

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [BUG] 漏斗图点击图例后展示错误

2 participants