From: Kuba Suder Date: Thu, 16 Apr 2015 20:23:17 +0000 (+0200) Subject: prevent taking vertical space for x labels more than once X-Git-Tag: v2.0-alpha~41^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1069%2Fhead;p=thirdparty%2FChart.js.git prevent taking vertical space for x labels more than once calculateXLabelRotation() subtracts space needed for x labels from this.endPoint, but if this block is called more than once then the space is subtracted more than once and the chart gets smaller and smaller with every iteration --- diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 296844ea2..15ed2147c 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1554,6 +1554,9 @@ this.startPoint += this.padding; this.endPoint -= this.padding; + // Cache the starting endpoint, excluding the space for x labels + var cachedEndPoint = this.endPoint; + // Cache the starting height, so can determine if we need to recalculate the scale yAxis var cachedHeight = this.endPoint - this.startPoint, cachedYLabelWidth; @@ -1585,6 +1588,7 @@ // Only go through the xLabel loop again if the yLabel width has changed if (cachedYLabelWidth < this.yLabelWidth){ + this.endPoint = cachedEndPoint; this.calculateXLabelRotation(); } }