From: haschu Date: Wed, 18 May 2016 22:20:06 +0000 (+0200) Subject: This fixes #2584 (#2592) X-Git-Tag: v2.1.4~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=393db2a6090dd7b07608e5d3b59185f000a9476b;p=thirdparty%2FChart.js.git This fixes #2584 (#2592) Improve scale auto-skipper when labels are not rotated --- diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 9861288cd..cf145dc67 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -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,