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

"When using log, line ChartJS empty / null values doesn't break the line" #8035

Closed
wolwemaan opened this issue Nov 10, 2020 · 3 comments · Fixed by #8781
Closed

"When using log, line ChartJS empty / null values doesn't break the line" #8035

wolwemaan opened this issue Nov 10, 2020 · 3 comments · Fixed by #8781

Comments

@wolwemaan
Copy link

Expected Behavior

When encountering NaN / empty / null values the ChartJS line should be broken similar as when a non logarithmic type is selected.

Current Behavior

When using the logarithmic type in chart, the ChartJS line doesn't get broken as expected when encountering NaN / empty / null values, instead it is defaulted to 0

Possible Solution

Version 3 may provide a fix but at the moment a suggestion to resolve for version 2.9.4 is required,

Steps to Reproduce

https://codepen.io/wolwemaan/pen/ZEOmJdz

Context

Switching the y axis to type logarithmic causes the empty values to be charted as 0

Environment

  • Chart.js version: 2.9.4
  • Browser name and version: Chromium Version 86.0.4240.183 (Official Build) snap (64-bit)
  • Link to your project:
@wolwemaan
Copy link
Author

https://pasteboard.co/JzLUj2S.png

Attaching an image highlighting the unexpected 0's that is being charted

@wolwemaan
Copy link
Author

I got a non-ideal workaround by skipping NaN values altogether. Non-ideal since it results in the x-bar being updated accordingly

@etimberg
Copy link
Member

V3 will skip the NaNs by default, but that still causes X axis problems. The root cause of NaNs being skipped is the check for isNaN(otherValue) in https://github.com/chartjs/Chart.js/blob/master/src/core/core.datasetController.js#L609. The simplest solution would be to add an explicit max to the x axis.

https://codepen.io/etimberg/pen/QWGwgGQ?editors=1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants