]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Refactored skipRatio to use the longest label text for calculation.
authorTore Lervik <tore@lervik.com>
Mon, 21 Dec 2015 22:30:40 +0000 (23:30 +0100)
committerTore Lervik <tore@lervik.com>
Mon, 21 Dec 2015 22:32:52 +0000 (23:32 +0100)
src/core/core.scale.js

index 3269fe11876184d2d3e0add0d0b2f6dc211ebee3..2ef412ba306299e9f765143922b0984f12f0dfa5 100644 (file)
                                        var yTickEnd = this.options.position === "bottom" ? this.top + 10 : this.bottom;
                                        skipRatio = false;
 
-                                       if ((this.options.ticks.fontSize + 4) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) {
-                                               skipRatio = 1 + Math.floor(((this.options.ticks.fontSize + 4) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight)));
+                                       if ((this.options.ticks.fontSize * maxLength) * this.ticks.length > (this.width - (this.paddingLeft + this.paddingRight))) {
+                                           skipRatio = 1 + Math.floor((((this.options.ticks.fontSize * maxLength / 2) + (this.options.ticks.autoSkipPadding || 20)) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight)));
                                        }
 
                                        if (!useAutoskipper) {