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

XAxis ticks not spaced evenly #4271

Open
1 task
TaoshiKen opened this issue Mar 8, 2024 · 3 comments
Open
1 task

XAxis ticks not spaced evenly #4271

TaoshiKen opened this issue Mar 8, 2024 · 3 comments
Labels
bug General bug label docs needed Issues that require documentation

Comments

@TaoshiKen
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

See Example. I would expect when the xAxis is set to type='number' that it would display ticks just like when the yAxis is set to type number. It distributes ticks evenly without respect to where data is clumped or sparse. I have tried everything to figure this out.

What is expected?

Evenly spaced ticks just like the yAxis

What is actually happening?

Unevenly spaced ticks, seemingly based upon where the data is. Its like the type='number' has no impact

Environment Info
Recharts v2.12.2
React 18
System macOS, Sonoma 14.2.1
Browser Vivaldi 6.5.3206.59

Setting the interval to "equidistantStartEnd" does not work

@ckifer
Copy link
Member

ckifer commented Mar 8, 2024

equidistantStartEnd does not exist, equidistantPreserveStart is the only current "equidistant" implementation.

You can read a description of this implementation in this PR #3392

@nikolasrieble might be able to add more here, but from my understanding the behavior with a number axis is because it is attempting to use D3 "nice" ticks, which require the domain to be nice numbers.

If I set the domain to ['dataMin', 'auto'] instead of dataMax, it will extend the domain slightly and be able to create 5 ticks nicely distributed across the axis.

But.. this happens regardless of the interval setting. Will wait for someone else who knows this better to reply 😅

@nikolasrieble
Copy link
Contributor

Hi, nice to meet you!

One of the difficulties in working with and developing recharts is the interaction effects of all the properties. These are neither (a) (well) documented or (b) fully known to us, who maintain and develop recharts.

My first assumption is that one of the arguments interacts with the effect of the interval.

Workaround

And if I remove the domain from your sandbox, it indeed works as expected.

Screenshot 2024-03-09 at 19 58 40

We are always looking for contributors

I would classify this behaviour as a bug, and would suggest to look more into the interaction of domain and interval setting. We are always looking for new contributors. Would you like to pick this up?

@nikolasrieble nikolasrieble added bug General bug label docs needed Issues that require documentation labels Mar 9, 2024
@TaoshiKen
Copy link
Author

@nikolasrieble Nice to meet you! Thanks for the response and while your solution works for the dataset provided in the sandbox it doesn't work for the exact data set I'm working with for my production app. I should have supplied the exact data set.

Here's a more specific example where removing the domain while having equidistantPreserveStart still doesn't work. Example

I unfortunately don't have the capacity to work on this right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General bug label docs needed Issues that require documentation
Projects
None yet
Development

No branches or pull requests

3 participants