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

fix: sparkline should be relative to values instead of zero; zero dividend/divisior issue; sub-pixel issue. #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

prathamesh-gharat
Copy link

@prathamesh-gharat prathamesh-gharat commented May 18, 2023

The code was considering 0 to be the base value for Y axis so the sparkline currently does not show relative movements in values clearly.

For example, the sparkline for [110, 120, 130, 110, 120, 130] would appear flatter than [10, 20, 30, 10, 20, 30] even though the relative differences between the numbers is the same. As the numbers go higher (1000s), the line visually appears to be a straight line.

Please see the screenshot below for reference.
https://i.imgur.com/HMyqPU9.png

Sandbox with the change: https://codesandbox.io/p/sandbox/pedantic-hawking-hzwsgl?file=%2Fsrc%2Flib%2Fsparkline-svg.ts%3A29%2C9-32%2C10

prathamesh-gharat and others added 5 commits May 18, 2023 23:09
The code was considering 0 to be the base value for Y axis so the charts appeared to now show relative movements not as clearly as the numbers increased in value.
For example, the sparkline for `[110, 120, 130, 110, 120, 130]` would appear flatter than `[10, 20, 30, 10, 20, 30]` even though the relative differences between the numbers is the same. As the numbers go higher (1000s), the line visually appears to be a straight line.

Please see the screenshot below for reference.
https://i.imgur.com/HMyqPU9.png

Sandbox with the change: https://codesandbox.io/p/sandbox/pedantic-hawking-hzwsgl?file=%2Fsrc%2Flib%2Fsparkline-svg.ts%3A29%2C9-32%2C10
The horizontal line was appearing as 1px incorrectly even when stroke-width was set to 2; vertical or diagonal lines were appearing as 2px correctly.
More info at: https://stackoverflow.com/a/12502840/3577736

Other solutions on the stackoverflow thread did not work.
@prathamesh-gharat prathamesh-gharat changed the title fix: sparkline should be relative to values instead of zero fix: sparkline should be relative to values instead of zero; zero dividend/divisior issue; sub-pixel issue. May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant