Skip to content

Conversation

@lxfu1
Copy link
Member

@lxfu1 lxfu1 commented Dec 23, 2025

Checklist
  • npm test passes
Description of change

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lxfu1, 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 a bug in the brush selection mechanism, particularly affecting ordinal scales. The core of the fix involves refining the coordinate inversion logic to ensure accurate mapping to domain values and improving how selections are processed, especially when dealing with partial selections. The changes are supported by updated and new test cases, ensuring the stability and correctness of the brush selection feature.

Highlights

  • Brush Selection Logic Fix: Corrected the invert function for ordinal scales to accurately map screen coordinates to domain values by finding the nearest band center, resolving a brush selection error.
  • Selection Handling Improvement: Enhanced the selectionOf utility to properly handle cases where one of the selection dimensions might be undefined, preventing potential errors during selection calculation.
  • Updated Test Expectations: Modified existing integration tests for scrollbar and slider filters to reflect the corrected selection behavior, adjusting expected selection ranges.
  • New Bugfix Test Case: Introduced a dedicated test (issue6751) to reproduce and validate the fix for the brush selection error, ensuring the bug does not reoccur.
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
Contributor

@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

This pull request fixes a brush selection error by refactoring the invert function for ordinal scales in src/utils/scale.ts. The new implementation, which finds the nearest band center, is more robust and readable than the previous version. The changes are supported by updates to existing tests and a new test case for the specific bug. My review includes a suggestion to prevent a potential runtime error by checking for undefined scales, and a minor cleanup in a test file to remove debugging code. The changes are logical and well-implemented.

return [invert(scaleX, x, start), invert(scaleY, y, start)];
const abstract = (point) => {
const [px, py] = coordinate.invert(point);
return [invert(scaleX, px), invert(scaleY, py)];
Copy link
Contributor

Choose a reason for hiding this comment

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

high

It's possible for scaleX or scaleY to be undefined if a scale for that channel is not defined in the view. Calling invert with an undefined scale will cause a runtime error. You should add a check to ensure the scale exists before calling invert. The subsequent logic already handles undefined domain values correctly.

Suggested change
return [invert(scaleX, px), invert(scaleY, py)];
return [scaleX && invert(scaleX, px), scaleY && invert(scaleY, py)];

Comment on lines +42 to +44
chart.on('brush:end', (e) => {
console.log(e.data.selection);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This chart.on('brush:end', ...) block contains a console.log which appears to be for debugging. This should be removed from the test code before merging. If the event emission needs to be tested, it should be replaced with an assertion.

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.

[Bug]: brush:end 事件在柱状图下返回了错误的 selection

3 participants