Skip to content

fix(Bar): tooltip shows the color the bar renders with, entry id and styles stay off the background - #8000

Merged
PavelVanecek merged 1 commit into
recharts:mainfrom
kaanisthatyou:fix/bar-entry-styles
Oct 17, 2026
Merged

PavelVanecek merged 1 commit into
recharts:mainfrom
kaanisthatyou:fix/bar-entry-styles

Conversation

@kaanisthatyou

@kaanisthatyou kaanisthatyou commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

The Bar gaps from #7972:

  • Tooltip color. The tooltip item now shows the color the bar renders with: the entry fill, else the <Bar> fill, then the stroke. <Bar fill="#123456"> + { stroke: 'lime' } gives #123456 (was lime), and { color: 'blue' } with a theme gives the theme fill (was blue). With a theme, an entry with its own colors ignores the theme colors, same as the rectangle. To keep this per item, Bar passes a new optional getEntryColor in its tooltip configuration (next to getPosition); combineTooltipPayload uses it when present and keeps reading the datum color/fill/stroke for the other items.
  • id. computeBarRectangles drops the entry id before spreading the entry. The raw entry stays in payload.
  • Background. The background rectangle no longer takes SVG properties from the entry (stroke, opacity, style, data-*, id, ...). Custom background shapes still receive the other entry keys and payload.

The stroke-only open question is unchanged: with a theme, { stroke: 'blue' } still renders without a fill, and the tooltip shows the stroke.

Related Issue

Refs #7972 (part of #7968)

Motivation and Context

See #7972.

How Has This Been Tested?

  • 6 new tests in test/cartesian/Bar/Bar.theme.spec.tsx (tooltip color with and without a theme, entry color key, entry id, background styles, custom background props). All 6 fail on main and pass with this change.
  • Bar.spec.tsx and itemSorter.spec.tsx compare the whole tooltip configuration, so they now expect getEntryColor on Bar.
  • The pre-push npm run lgtm (build, lint, all unit projects, check-types) passed on Windows: 17441 tests.
  • tsc (lib and test) and eslint clean.

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

Summary by CodeRabbit

  • Bug Fixes
    • Tooltip colors now better match each bar’s rendered style, including stroke-only entries and theme overrides.
    • Bar backgrounds no longer inherit data-entry styling, and entry IDs are no longer rendered as bar properties. Click handlers and custom backgrounds continue to receive the original entry data.

…styles stay off the background

- The tooltip item color follows the bar: the entry fill, or the Bar fill, then the stroke.
  An entry `color` key no longer changes it, and with a theme an entry with its own colors
  ignores the theme colors, as the bar does. Bar reports this through an optional
  `getEntryColor` on its tooltip configuration; the other items keep reading the datum colors.
- The entry `id` is no longer spread on the bar rectangle. The raw entry stays in `payload`.
- The background rectangle no longer takes SVG properties from the entry. Custom background
  shapes still get the other entry keys and `payload`.

Refs recharts#7972

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3f2d5a1-1a6b-4b71-a7c2-d96220d43629
📥 Commits

Reviewing files that changed from the base of the PR and between 483835a and d452852.

📒 Files selected for processing: 6
  • src/cartesian/Bar.tsx
  • src/state/selectors/combiners/combineTooltipPayload.ts
  • src/state/tooltipSlice.ts
  • test/cartesian/Bar/Bar.spec.tsx
  • test/cartesian/Bar/Bar.theme.spec.tsx
  • test/component/Tooltip/itemSorter.spec.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

Bar tooltip entries now use an entry-aware color resolver with style and settings fallbacks. Bar rectangles filter selected data-entry properties from rendered SVG props while retaining the original entry as payload.

Changes

Bar entry behavior

Layer / File(s) Summary
Resolve Bar tooltip colors
src/state/tooltipSlice.ts, src/cartesian/Bar.tsx, src/state/selectors/combiners/combineTooltipPayload.ts, test/cartesian/Bar/Bar.spec.tsx, test/cartesian/Bar/Bar.theme.spec.tsx, test/component/Tooltip/itemSorter.spec.tsx
TooltipPayloadConfiguration adds getEntryColor. Bar supplies a resolver based on entry styles and effective Bar styles. Tooltip payload combination uses the resolver when present, then falls back to parsed item styles and settings.color. Tests cover theme and entry-style cases and updated tooltip configuration expectations.
Filter data-entry properties on Bar rectangles
src/cartesian/Bar.tsx, test/cartesian/Bar/Bar.theme.spec.tsx
Computed bar rectangles omit entry id from rendered props and retain the full entry in payload. Background rectangles filter SVG props and data-* attributes while retaining name and other entry fields. Tests cover rendered props, click payloads, and custom background props.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: pavelvanecek

Merge Risk: ⚪ Minimal · up to d4528

Tooltip colors match the ordinary rendered Bar styling on the inspected paths. No actionable issue remains before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main changes: matching tooltip colors to rendered bars and preventing entry IDs and styles from affecting backgrounds.
Description check Passed The description includes the required change summary, related issue, motivation, testing details, change classification, and checklist. The optional screenshots section is not included, but the descri…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes the required change summary, related issue, motivation, testing details, change classification, and checklist. The optional screenshots section is not included, but the description is otherwise complete and specific.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kaanisthatyou kaanisthatyou mentioned this pull request Oct 16, 2026
4 tasks
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 8.28kB (0.13%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.67MB 2.65kB (0.16%) ⬆️
recharts/bundle-es6 1.49MB 2.49kB (0.17%) ⬆️
recharts/bundle-umd 637.1kB 510 bytes (0.08%) ⬆️
recharts/bundle-treeshaking-cartesian 843.32kB 2.45kB (0.29%) ⬆️
recharts/bundle-treeshaking-polar 563.45kB 188 bytes (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 510 bytes 637.1kB 0.08%
view changes for bundle: recharts/bundle-treeshaking-polar

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 188 bytes 563.45kB 0.03%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Bar.js 2.47kB 43.08kB 6.07% ⚠️
state/selectors/combiners/combineTooltipPayload.js 188 bytes 12.8kB 1.49%
view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
cartesian/Bar.js 2.3kB 41.0kB 5.94% ⚠️
state/selectors/combiners/combineTooltipPayload.js 188 bytes 12.54kB 1.52%
view changes for bundle: recharts/bundle-treeshaking-cartesian

Assets Changed:

Asset Name Size Change Total Size Change (%)
bundle.js 2.45kB 843.32kB 0.29%

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.12%. Comparing base (483835a) to head (d452852).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8000      +/-   ##
==========================================
+ Coverage   89.10%   89.12%   +0.01%     
==========================================
  Files         652      652              
  Lines       16042    16062      +20     
  Branches     4239     4246       +7     
==========================================
+ Hits        14295    14315      +20     
  Misses       1556     1556              
  Partials      191      191              

☔ View full report in Codecov by Harness.
📢 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.

@flakiness-io

flakiness-io Bot commented Oct 16, 2026

Copy link
Copy Markdown

Test Results Summary

This comment shows the latest test results for this pull request.

Commit Status Test Results CI Runs
d452852 ✅ Passed 3231 passed · 522 skipped 9 runs

View full report

ℹ️ About Flakiness.io in GitHub

Your team has set up Flakiness.io pull request comments. This comment is updated when

  • The first test results arrive for this pull request
  • A later run reports more results for the same commit
  • A new commit is pushed and tested

Flakiness.io rewrites the comment in place, so it always reflects the most recently tested commit.

@PavelVanecek

Copy link
Copy Markdown
Collaborator

No visual diff? The tests we have now didn't cover this scenario?

@PavelVanecek
PavelVanecek merged commit c2cd6aa into recharts:main Oct 17, 2026
64 checks passed
PavelVanecek added a commit that referenced this pull request Oct 26, 2026
…d styles stay off the background (#8078)

## Description

The RadialBar gaps from #7973, following the Bar fix in #8000:

- **Tooltip color.** The tooltip item shows the color the sector renders
with: the entry `fill`, else the `<RadialBar>` fill, then the stroke.
`<Cell>` colors are included. `<RadialBar fill="#123456">` + `{ stroke:
'lime' }` gives `#123456` (was lime), and `{ color: 'blue' }` with a
theme gives the theme fill (was blue). RadialBar passes `getEntryColor`
in its tooltip configuration, same as Bar.
- **Legend color.** Each legend item uses the resolved color of its own
entry, `<Cell>` included. With a theme, a stroke-only entry `{ stroke:
'lime' }` now gets a lime icon instead of the theme fill; with
`<RadialBar fill>`, it gets that fill. `selectRadialBarLegendPayload` no
longer sets `color`.
- **`id`.** The entry `id` is no longer rendered on the sector or the
background sector. The raw entry stays in `payload`.
- **Background.** The background sector no longer takes SVG properties
from the entry (`stroke`, `opacity`, `style`, `data-*`, `id`, ...).

Bar's private helpers moved to `src/theme/dataEntryStyles.ts` as
`getEntryColor` and `omitEntrySvgProps`, so Bar and RadialBar share
them. Bar behavior and screenshots are unchanged.

The stroke-only open question from the issue is unchanged: with a theme
and no `<RadialBar>` colors, `{ stroke: 'lime' }` still renders a black
sector. Its legend icon now shows the stroke.

## Related Issue

Fixes #7973 (part of #7968)

## Known gap

A custom `background` function or element is never called on RadialBar:
it renders the computed geometry as the shape option instead of the
prop. This is #2535 and is not fixed here; there is a `test.fails` for
it in `RadialBar.theme.spec.tsx` so that it shows up once fixed.

## How Has This Been Tested?

- 9 new tests in `test/polar/RadialBar/RadialBar.theme.spec.tsx`
(tooltip color with and without a theme, entry `color` key, Cell color
in tooltip and legend, per-entry legend colors with a theme, entry `id`,
background styles). 7 fail on `main`; the Cell tooltip and
RadialBar-fill legend cases already passed and stay as regression
guards.
- 1 expected-fail test for #2535.
- Full unit suite, lint and check-types pass (pre-push hook).
- VR: regenerated the `RadialBar fill and stroke variants` screenshots
in Docker (legend and tooltip colors). All other RadialBar and Bar VR
tests are unchanged.

## Types of changes

- [x] 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.
- [x] I have added tests to cover my changes.
- [x] I have added a storybook story or VR test, or extended an existing
story or VR test to show my changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Bug Fixes**
* Radial bar colors now appear consistently across chart segments,
tooltips, and legends when colors are set on individual entries, series,
themes, or custom cells.
* Entry-specific styling no longer unintentionally affects chart
backgrounds.
* Clicking a chart entry continues to provide its original data,
including its ID.
* Legend colors now reflect entry-level fill and stroke styling, inline
styles, and applicable theme or cell overrides.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants