From: Evert Timberg Date: Tue, 27 Jan 2015 23:31:03 +0000 (-0500) Subject: Fix a divide by 0 error when there is only 1 label X-Git-Tag: v1.0.2~6^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F898%2Fhead;p=thirdparty%2FChart.js.git Fix a divide by 0 error when there is only 1 label --- diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 7cea99535..eb34c871c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1575,7 +1575,7 @@ var isRotated = (this.xLabelRotation > 0), // innerWidth = (this.offsetGridLines) ? this.width - offsetLeft - this.padding : this.width - (offsetLeft + halfLabelWidth * 2) - this.padding, innerWidth = this.width - (this.xScalePaddingLeft + this.xScalePaddingRight), - valueWidth = innerWidth/(this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), + valueWidth = innerWidth/Math.max((this.valuesCount - ((this.offsetGridLines) ? 0 : 1)), 1), valueOffset = (valueWidth * index) + this.xScalePaddingLeft; if (this.offsetGridLines){