fix(CartesianAxis): render the axis line when there are no ticks #4433
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 itRelated Issue
#4426
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: