Skip to content

Fix stacked charts with duplicate categorical data#6194

Merged
ckifer merged 3 commits intomainfrom
stacked-bar-repeated-xaxis-data-fix
Aug 10, 2025
Merged

Fix stacked charts with duplicate categorical data#6194
ckifer merged 3 commits intomainfrom
stacked-bar-repeated-xaxis-data-fix

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Aug 9, 2025

Description

I missed this use-case when refactoring.

Related Issue

Fixes #6192

How Has This Been Tested?

unit + VR tests

Screenshots (if appropriate):

https://github.com/recharts/recharts/pull/6194/files#diff-915bfdd6ee0e23439c6b300c92d732954fd0e01d4b409d82d8d369749877e1a9

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 extended an existing story to show my changes

@PavelVanecek PavelVanecek requested a review from Copilot August 9, 2025 13:20
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 stacked charts where duplicate categorical data causes rendering issues. The fix ensures that when allowDuplicatedCategory is enabled, the chart uses index-based positioning instead of relying on the data key value for tooltip positioning.

Key Changes

  • Modified combineDisplayedStackedData to use index-based positioning when allowDuplicatedCategory is true
  • Added comprehensive unit tests to verify the fix for stacked bar charts with duplicate categorical data
  • Added visual regression tests to prevent future regressions

Reviewed Changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 2 comments.

File Description
src/state/selectors/combiners/combineDisplayedStackedData.ts Core fix: uses index instead of data key value when allowDuplicatedCategory is enabled
test/cartesian/Bar.truncateByDomain.spec.tsx Unit tests covering the duplicate categorical data scenario with selector validation
test-vr/tests/Bar.6192.spec-vr.tsx Visual regression test with comprehensive dataset showing the bug fix in action

@codecov
Copy link

codecov bot commented Aug 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.74%. Comparing base (bdf962a) to head (5334fde).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6194   +/-   ##
=======================================
  Coverage   96.74%   96.74%           
=======================================
  Files         222      222           
  Lines       20019    20025    +6     
  Branches     4140     4140           
=======================================
+ Hits        19368    19374    +6     
  Misses        645      645           
  Partials        6        6           

☔ 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 Aug 9, 2025

Bundle Report

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

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.03MB -7 bytes (-0.0%) ⬇️
recharts/bundle-es6 888.03kB -7 bytes (-0.0%) ⬇️
recharts/bundle-umd 490.5kB 16 bytes (0.0%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/combiners/combineDisplayedStackedData.js -7 bytes 2.27kB -0.31%
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 16 bytes 490.5kB 0.0%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
state/selectors/combiners/combineDisplayedStackedData.js -7 bytes 2.07kB -0.34%

@ckifer ckifer merged commit 98e14b6 into main Aug 10, 2025
27 checks passed
@ckifer ckifer deleted the stacked-bar-repeated-xaxis-data-fix branch August 10, 2025 14:21
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.

Chart no longer works after version 3.1.0

3 participants