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
YAxis is missing if value = null || undefined #4426
Comments
This has been in place for over a year without issue... But it makes sense to render the line when there are no ticks so I'll check into that as free time allows |
@Kaiyrgali the best I can do is address this behavior in the next major version #4433 See the PR for more explanation, but basically the behavior you relied on should never have worked reliably. It only did because of a bug that was fixed in the PR you linked |
<!--- 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>
@ckifer Hi! The problem starts in version v2.5.0, most likely from this pull request #3454
We use Yaxis even when there is no data = null || undefined. The user later selects a data source
Before version v2.5.0, the YAxis is rendered empty, without ticks
https://codesandbox.io/p/sandbox/yaxis-with-null-value-v2-4-3-pt4ws7
Now the Yaxis is missing in our case
https://codesandbox.io/p/sandbox/yaxis-problem-with-null-value-v2-5-0-w9ffxd
The text was updated successfully, but these errors were encountered: