mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
Improve scale auto-skipper when labels are not rotated
This commit is contained in:
parent
f24dddeda7
commit
393db2a609
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user