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

[Bug]: missing top y-axis tick when no autoMinValue is set #898

Open
adamhenson opened this issue Jan 9, 2024 · 3 comments
Open

[Bug]: missing top y-axis tick when no autoMinValue is set #898

adamhenson opened this issue Jan 9, 2024 · 3 comments
Labels
Status: Blocked A fix for this issue is blocked on another internal or external fix being in place Type: Bug Confirmed bug, something is not working as intended

Comments

@adamhenson
Copy link
Contributor

adamhenson commented Jan 9, 2024

Tremor Version

3.12.2

Link to minimal reproduction

main...adamhenson:tremor:repro/unequal-y-axis-ticks

Steps to reproduce

Set prop minValue to 0 and maxValue to 7000.

What is expected?

6000 should be a y-axis tick and a corresponding grid line should render.

In the screenshot below, the minValue of 0 isn't honored, which seems expected since we set autoMinValue. But, with autoMinValue, ticks are evenly spread.

Screenshot 2024-01-09 at 8 45 52 AM

What is actually happening?

There is a gap where 6000 would be.

Screenshot 2024-01-09 at 8 26 45 AM

What browsers are you seeing the problem on?

No response

Any additional comments?

I don't think this is expected behavior, but please correct me if I'm wrong. I started looking at how tremor uses recharts YAxis and CartisanGrid, but nothing is standing out to me. The next step is to pull down and dabble with recharts, but would prefer to find out any info first, if anyone has experienced this and if it's known.

@severinlandolt
Copy link
Member

This is indeed unexpected, I suppose it has to do with some internal defaults set by Tremor and/or Recharts, that can lead to some undesired outcomes. Maybe @nikolasrieble has some ideas where this should/can be addressed 🔎

@severinlandolt severinlandolt added the Type: Bug Confirmed bug, something is not working as intended label Jan 9, 2024
@adamhenson
Copy link
Contributor Author

adamhenson commented Jan 9, 2024

I attempted to track this down in Recharts and it got really gnarly. I discovered that they actually import another package called recharts-scale. I identified the culprit line... or at least what seems to be the culprit. No idea how this is working as expected in other cases.

https://github.com/recharts/recharts-scale/blob/8e181785d20a686ce4f3f83a4b789fb61a32806f/src/getNiceTickValues.js#L249

When I make this change it works as expected (by hacking into the node_module or using npm link)

- new Decimal(cormax).sub(new Decimal(0.99).mul(step)),
+ new Decimal(cormax),

The only reason why I got there is by an unreasonable amount of logging.

Arithmetic.rangeStep was returning [0, 2000, 4000] and new Decimal(cormax).sub(new Decimal(0.99).mul(step)) was returning 5020. After changing that part Arithmetic.rangeStep returns [0, 2000, 4000, 6000] and new Decimal(cormax) is 7000.

I don't really know what to make of all that. I don't think value Tremor passes would cause that. It seems like it could be a bug in recharts-scale, but that file was last touched 4 years ago 😕

@severinlandolt severinlandolt added the Status: Blocked A fix for this issue is blocked on another internal or external fix being in place label Feb 3, 2024
@ckifer
Copy link

ckifer commented Feb 12, 2024

recharts maintainer piping in: recharts-scale is a mysterious library to the current maintainers of recharts that existed before any of us. We haven't touched it because we don't even have npm publish permissions to it. Most likely we will port it to the recharts repo so we can refactor and manage it more directly.

Timeline of this could be a while, apologies for the bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Blocked A fix for this issue is blocked on another internal or external fix being in place Type: Bug Confirmed bug, something is not working as intended
Projects
None yet
Development

No branches or pull requests

3 participants