Skip to content

fix: don't filter zero out of brush scaleValues#6323

Merged
ckifer merged 1 commit intomainfrom
fix/dont-filter-0-brush
Sep 16, 2025
Merged

fix: don't filter zero out of brush scaleValues#6323
ckifer merged 1 commit intomainfrom
fix/dont-filter-0-brush

Conversation

@ckifer
Copy link
Member

@ckifer ckifer commented Sep 16, 2025

Description

we were filtering out 0 which breaks Brush when the first scaleValue in the list happens to be 0. This usually works because our default margin adds value to the scale values to make the first one > 0

Related Issue

#6308

Motivation and Context

bug fix

How Has This Been Tested?

unit test, storybook

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (880c3d6) to head (9e08a59).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6323      +/-   ##
==========================================
+ Coverage   96.61%   96.63%   +0.01%     
==========================================
  Files         221      221              
  Lines       20329    20329              
  Branches     4170     4173       +3     
==========================================
+ Hits        19641    19645       +4     
+ Misses        681      677       -4     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov
Copy link

codecov bot commented Sep 16, 2025

Bundle Report

Changes will increase total bundle size by 35 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.05MB 15 bytes (0.0%) ⬆️
recharts/bundle-es6 902.79kB 15 bytes (0.0%) ⬆️
recharts/bundle-umd 487.88kB 5 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Brush.js 15 bytes 27.33kB 0.05%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Brush.js 15 bytes 26.08kB 0.06%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 5 bytes 487.88kB 0.0%

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the Brush component where zero values were being filtered out from scaleValues, causing index misalignment when the first scale value is 0. The fix changes the filter condition from Boolean to explicitly checking for null/undefined values.

  • Changed filter logic in Brush component to preserve zero values
  • Added comprehensive test coverage for the zero value edge case
  • Added a storybook story to demonstrate the fix

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/cartesian/Brush.tsx Updated filter condition to preserve zero values in scaleValues
test/cartesian/Brush.spec.tsx Added test case for zero value handling in brush navigation
storybook/stories/Examples/cartesian/Brush/Brush.stories.tsx Added NoChartBrush story for visual testing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

.domain()
.map(entry => prevScale(entry))
.filter(Boolean);
.filter(value => value != null);
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider using strict equality (!== null && value !== undefined) instead of loose equality (!= null) for more explicit null/undefined checking, which is a common TypeScript best practice.

Suggested change
.filter(value => value != null);
.filter(value => value !== null && value !== undefined);

Copilot uses AI. Check for mistakes.
@ckifer ckifer merged commit e7bca0d into main Sep 16, 2025
26 of 27 checks passed
@ckifer ckifer deleted the fix/dont-filter-0-brush branch September 16, 2025 07:11
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