-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uneven distribution of xaxis time scale with 'autoSkip:true' and maxTicksLimit #3277
Comments
@nikitaagarwal-limetray do you have |
@etimberg https://jsfiddle.net/L3cng59w/ I think the problem is that if number of ticks greater than |
This still reproduces in v2.5.0 https://jsfiddle.net/z3qwrvds/ |
I have a quite similar issue. The x-axis is date but it does not distribute evenly. Here is my option setting: |
+1 Penultimate tick missing when reached the maxTicksLimit, should instead evenly space them. Using chartjs v2.6.0
|
We fixed a similar issue in 2.7.0 with the time scale but the |
@etimberg This problem also affects category scale, not just time scale. This bug is an "emergent behavior" of how the tick skipping is performed. If the number of plot points on the x axis is evenly divisible by the number of labels Chart.js decides to render, then the gap will not appear. A contributing factor is the insistence on always plotting the last tick mark. Perhaps this should be an option that can be disabled. What I would like is interpolation and nearest neighbor matching for tick placement. So, maybe there needs to be a config option like:
I was able to work around it and get a more aesthetically pleasing plot (in my opinion) by making the following change to Chart.js. // Since we always show the last tick,we need may need to hide the last shown one before
shouldSkip = (skipRatio > 1 && i % skipRatio > 0) || (i % skipRatio === 0 && i + skipRatio >= tickCount);
if (shouldSkip && i !== tickCount - 1 || helpers.isNullOrUndef(tick.label)) {
// leave tick in place but make sure it's not displayed (#4635)
delete tick.label;
}
result.push(tick); with // Last tick is only displayed if number of categories on axis is evenly divisible by skipRatio
shouldSkip = (skipRatio > 1 && i % skipRatio > 0);
if (shouldSkip || helpers.isNullOrUndef(tick.label)) {
// leave tick in place but make sure it's not displayed (#4635)
delete tick.label;
}
result.push(tick); |
I quite like the idea of the @heyrex think you could turn that workaround into a PR with the |
I'm not sure about |
@nikita-ag Hi there, I've experienced the same issue, I've been trying to play with the |
Hi there, i'm facing a similar issue (not with a time scale). Is there a way to show the penultimate tick and hide the last one? To prevent showing the gap between last interval values? |
Here initially gap is 5 days but at end it gets increased and data is cluttered at the end of the scale.
Data:
and options set are
The text was updated successfully, but these errors were encountered: