]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
This fixes #2584 (#2592)
authorhaschu <hagen.schulze@nextlabel.de>
Wed, 18 May 2016 22:20:06 +0000 (00:20 +0200)
committerEvert Timberg <evert.timberg+github@gmail.com>
Wed, 18 May 2016 22:20:06 +0000 (18:20 -0400)
Improve scale auto-skipper when labels are not rotated

src/core/core.scale.js

index 9861288cd33c93e2770351e2366416d9bd8ae3b0..cf145dc67c5e019599e1b7d8c1006f9b71b859b4 100644 (file)
@@ -506,8 +506,14 @@ module.exports = function(Chart) {
                                var yTickEnd = options.position === "bottom" ? this.top + tl : this.bottom;
                                skipRatio = false;
 
-                               if (((longestRotatedLabel / 2) + optionTicks.autoSkipPadding) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) {
-                                       skipRatio = 1 + Math.floor((((longestRotatedLabel / 2) + optionTicks.autoSkipPadding) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight)));
+                // Only calculate the skip ratio with the half width of longestRotateLabel if we got an actual rotation
+                // See #2584
+                if (isRotated) {
+                    longestRotatedLabel /= 2;
+                }
+
+                               if ((longestRotatedLabel + optionTicks.autoSkipPadding) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) {
+                                       skipRatio = 1 + Math.floor(((longestRotatedLabel + optionTicks.autoSkipPadding) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight)));
                                }
 
                                // if they defined a max number of optionTicks,