Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CartesianAxis): render the axis line when there are no ticks (#4433)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> 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 <!--- This project only accepts pull requests related to open issues --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please link to the issue here: --> #4426 ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> - It makes sense to show an axis line even when there are no ticks ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> - unit tests - see screenshot ## Screenshots (if appropriate): <img width="864" alt="image" src="https://github.com/recharts/recharts/assets/25180830/c10295ea-a30c-481c-b313-2ca4936dc3d4"> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [X] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [X] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [X] I have added tests to cover my changes. - [ ] I have added a storybook story or extended an existing story to show my changes Co-authored-by: Coltin Kifer <ckifer@amazon.com>
- Loading branch information