]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
prevent taking vertical space for x labels more than once 1069/head
authorKuba Suder <jakub.suder@gmail.com>
Thu, 16 Apr 2015 20:23:17 +0000 (22:23 +0200)
committerKuba Suder <jakub.suder@gmail.com>
Thu, 16 Apr 2015 20:23:17 +0000 (22:23 +0200)
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

src/Chart.Core.js

index 296844ea2ecc5f863ce894bd66d900ddb2ecc810..15ed2147cc866f662c0876f55e54af07b1ebbc44 100755 (executable)
                        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;
 
                                // Only go through the xLabel loop again if the yLabel width has changed
                                if (cachedYLabelWidth < this.yLabelWidth){
+                                       this.endPoint = cachedEndPoint;
                                        this.calculateXLabelRotation();
                                }
                        }