Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Stacked Logarithmic axes with a 0 data point crashes page

Open NJLucyk opened this issue 9 years ago • 2 comments

Expected Behavior

Chart should not break page

Current Behavior

Chart breaks page

Possible Solution

Steps to Reproduce (for bugs)

Go to https://jsfiddle.net/kadeyuy/r190msc6/18/ and change the stacked from false to true and hit run and the page will crash.

Context

Trying to have a stacked logarithmic bar graph so that I can show how different data sets contribute to total number while also being able to see smaller data points.

Environment

  • Chart.js version: 2.6
  • Browser name and version: Chrome Version 59.0.3071.115 (Official Build) (64-bit)

NJLucyk avatar Jul 06 '17 22:07 NJLucyk

Looks like the problem is that minNotZero is not set. The code for that is at https://github.com/chartjs/Chart.js/blob/5d95280d7b9c910f944ed7e219193a904bb4425b/src/scales/scale.logarithmic.js#L50 which leaves me.minNotZero equal to null instead of setting it.

Adding

if (value !== 0 && (me.minNotZero === null || value < me.minNotZero)) {
    me.minNotZero = value;
}

To the bottom of the if clause appears to fix the problem.

NJLucyk avatar Jul 06 '17 23:07 NJLucyk

@etimberg This issue has been addressed through PR #4959.

jcopperfield avatar Dec 23 '17 10:12 jcopperfield