Merge pull request #1816 from hallatore/Bug_AutoSkip

Refactored skipRatio to use the longest label text for calculation.
This commit is contained in:
Evert Timberg
2015-12-22 08:19:25 -05:00
7 changed files with 17 additions and 9 deletions

View File

@@ -47,6 +47,7 @@
reverse: false,
display: true,
autoSkip: true,
autoSkipPadding: 20,
callback: function(value) {
return '' + value;
},
@@ -454,8 +455,8 @@
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) * this.ticks.length) / (this.width - (this.paddingLeft + this.paddingRight)));
}
if (!useAutoskipper) {

View File

@@ -244,7 +244,8 @@ describe('Core helper tests', function() {
reverse: false,
display: true,
callback: merged.scales.yAxes[1].ticks.callback, // make it nicer, then check explicitly below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
},
type: 'linear'
}, {
@@ -281,7 +282,8 @@ describe('Core helper tests', function() {
reverse: false,
display: true,
callback: merged.scales.yAxes[2].ticks.callback, // make it nicer, then check explicitly below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
},
type: 'linear'
}]

View File

@@ -43,7 +43,8 @@ describe('Category scale tests', function() {
reverse: false,
display: true,
callback: defaultConfig.ticks.callback, // make this nicer, then check explicitly below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
}
});

View File

@@ -42,7 +42,8 @@ describe('Linear Scale', function() {
reverse: false,
display: true,
callback: defaultConfig.ticks.callback, // make this work nicer, then check below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
}
});

View File

@@ -41,7 +41,8 @@ describe('Logarithmic Scale tests', function() {
reverse: false,
display: true,
callback: defaultConfig.ticks.callback, // make this nicer, then check explicitly below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
},
});

View File

@@ -58,7 +58,8 @@ describe('Test the radial linear scale', function() {
showLabelBackdrop: true,
display: true,
callback: defaultConfig.ticks.callback, // make this nicer, then check explicitly below
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
},
});

View File

@@ -46,7 +46,8 @@ describe('Time scale tests', function() {
reverse: false,
display: true,
callback: defaultConfig.ticks.callback, // make this nicer, then check explicitly below,
autoSkip: true
autoSkip: true,
autoSkipPadding: 20
},
time: {
format: false,