Skip to content

Commit

Permalink
Skip NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Jan 8, 2020
1 parent 9e6c90b commit e208bb9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/scales/scale.logarithmic.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const defaultConfig = {
class LogarithmicScale extends Scale {
_parse(raw, index) { // eslint-disable-line no-unused-vars
const value = LinearScaleBase.prototype._parse.apply(this, arguments);
if (value === 0) {
return null;
}
return isFinite(value) && value > 0 ? value : NaN;
}

Expand Down Expand Up @@ -133,7 +136,7 @@ class LogarithmicScale extends Scale {
}

getLabelForValue(value) {
return value || 0;
return value === null ? 0 : value;
}

getPixelForTick(index) {
Expand All @@ -156,7 +159,10 @@ class LogarithmicScale extends Scale {

getPixelForValue(value) {
const me = this;
return me.getPixelForDecimal((log10(value || me.min) - me._startValue) / me._valueRange);
if (value === null) {
value = me.min;
}
return me.getPixelForDecimal(log10(value - me._startValue) / me._valueRange);
}

getValueForPixel(pixel) {
Expand Down

0 comments on commit e208bb9

Please sign in to comment.