Skip to content

Fix errors from zero-dimension scales#544

Merged
kurkle merged 1 commit intochartjs:masterfrom
joshkel:pan-nan
Jun 21, 2021
Merged

Fix errors from zero-dimension scales#544
kurkle merged 1 commit intochartjs:masterfrom
joshkel:pan-nan

Conversation

@joshkel
Copy link
Copy Markdown
Contributor

@joshkel joshkel commented Jun 13, 2021

Trying to pan a zero-dimension linear scale results in a RangeError: minimumFractionDigits value is out of range when LinearBaseScale tries to format its ticks.

This can happen a couple of ways:

  • If a scale is configured with an identical min and max - that seems like a misconfiguration, but Chart.js by itself at least attempts to handle it.
  • If the browser window is shrunk enough for the chart area to have 0 dimensions

The problem occurs because panNumericalScale calculates a newMin and newMax of NaN here. This, in turn, is because getDecimalForPixel (used by getValueForPixel) and getPixelForValue return NaN for 0-dimension scales.

Fixes #543

Trying to pan a zero-dimension linear scale results in a `RangeError: minimumFractionDigits value is out of range` when LinearBaseScale tries to format its ticks.

This can happen a couple of ways:

* If a scale is configured with an identical min and max - that seems like a misconfiguration, but Chart.js by itself at least attempts to handle it.
* If the browser window is shrunk enough for the chart area to have 0 dimensions

The problem occurs because panNumericalScale calculates a newMin and newMax of NaN here. This, in turn, is because getDecimalForPixel (used by getValueForPixel) and getPixelForValue return NaN for 0-dimension scales.

Fixes chartjs#543
@kurkle kurkle added the bug label Jun 21, 2021
@kurkle kurkle merged commit 2cb5f93 into chartjs:master Jun 21, 2021
@joshkel joshkel deleted the pan-nan branch June 21, 2021 11:30
@kurkle kurkle added this to the 1.1.0 milestone Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Errors from zero-dimension scales

2 participants