mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
Merge pull request #2017 from nnnick/fix/1884
When the last label would overlap with the previously shown label, skip the previously shown one
This commit is contained in:
commit
c3149a9400
@ -484,7 +484,9 @@ module.exports = function(Chart) {
|
|||||||
helpers.each(this.ticks, function(label, index) {
|
helpers.each(this.ticks, function(label, index) {
|
||||||
// Blank ticks
|
// Blank ticks
|
||||||
var isLastTick = this.ticks.length === index + 1;
|
var isLastTick = this.ticks.length === index + 1;
|
||||||
var shouldSkip = skipRatio > 1 && index % skipRatio > 0;
|
|
||||||
|
// Since we always show the last tick,we need may need to hide the last shown one before
|
||||||
|
var shouldSkip = (skipRatio > 1 && index % skipRatio > 0) || (index % skipRatio === 0 && index + skipRatio > this.ticks.length);
|
||||||
if (shouldSkip && !isLastTick || (label === undefined || label === null)) {
|
if (shouldSkip && !isLastTick || (label === undefined || label === null)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user