Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CartesianAxis): render the axis line when there are no ticks #4433

Merged
merged 1 commit into from Apr 18, 2024

Conversation

ckifer
Copy link
Member

@ckifer ckifer commented Apr 16, 2024

Description

Bug reported in linked issue where after recharts 2.5 the YAxis line would "disappear" with 0 data points or ticks, where it would previously show.

It would previously show because NaN was being calculated as a tick value and added to the dom as a tick item. This was fixed in #3454.

I would not call this a regression because as per the lines changed in this PR, the axis lines were never meant to show unless there were ticks. (See !finalTicks || !finalTicks.length). I believe however, that they should be able to.

Thus, this is a breaking change for both X and Y axes where even with 0 ticks or 0 valid data items, the axis lines will still render.

For a user to return to the old behavior of no Axis, they only have to do something simple like YAxis hide={data.length === 0} /> or use React convention and conditionally render it

Related Issue

#4426

Motivation and Context

  • It makes sense to show an axis line even when there are no ticks

How Has This Been Tested?

  • unit tests
  • see screenshot

Screenshots (if appropriate):

image

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

@ckifer ckifer added the breaking change Use this label to indicate a breaking change in the Recharts API label Apr 16, 2024
@@ -40,7 +40,6 @@ export const YAxis: FunctionComponent<Props> = ({ yAxisId }: Props) => {
const width = useChartWidth();
const height = useChartHeight();
const axisOptions = useYAxisOrThrow(yAxisId);

Copy link
Member Author

Choose a reason for hiding this comment

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

oops

Copy link

codecov bot commented Apr 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.04%. Comparing base (97f07f3) to head (9088fd8).

Additional details and impacted files
@@            Coverage Diff             @@
##              3.x    #4433      +/-   ##
==========================================
- Coverage   95.04%   95.04%   -0.01%     
==========================================
  Files         106      106              
  Lines       20723    20722       -1     
  Branches     2818     2820       +2     
==========================================
- Hits        19696    19695       -1     
  Misses       1021     1021              
  Partials        6        6              

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

Copy link
Member Author

@ckifer ckifer left a comment

Choose a reason for hiding this comment

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

I'm just going to ship this. Willing to defend it if anyone thinks its an issue

@ckifer ckifer merged commit 1d60cc6 into 3.x Apr 18, 2024
11 checks passed
@ckifer ckifer deleted the fix/always-render-axis-line branch April 18, 2024 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Use this label to indicate a breaking change in the Recharts API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant