Conversation
|
I agree that this definitely fixes the issue you are seeing. Not sure if we want to stick with a new boolean option or have some other kind of more generic option. @simonbrunel thoughts? |
|
If that option only applies to the auto skipper and there is no use cases where we want to preserve other tick (e.g. Actually, the only thing I'm thinking is if we are going to have more and more options to control the auto skipper, then maybe we should start to gather them under the autoSkip: false; // disabled
autoSkip: true; // enabled with default options
autoSkip: { // enabled with custom options
keepLast: true,
padding: ... // deprecates autoSkipPadding
}An idea that could make this feature more generic: instead of include: function(tick, index, count) {
return index === count-1;
}I don't know if that would be useful, neither if that's the best function signature. Any thoughts? |
|
@simonbrunel I like the idea of nesting these options underneath the I like the idea of a function that can override the default decision. Maybe we'd also want to provide a function that can do the measuring as well (right now we just use I wonder if we could refactor the autoSkip logic out into an internal plugin. #4117 refactored grid line drawing to a plugin so it should be possible. |
|
I'm going to rewrite the Could be a good improvement to export the auto skip logic in a separate plugin, I don't know if that's easily and cleanly possible. |
|
I like the idea of moving autoskip into an internal plugin. I'll give it a shot. |
|
Agreed about the use case of changing the lengths. It was just a thought I had. |
|
How about something like this: 'use strict';
module.exports = function(Chart) {
var helpers = Chart.helpers;
return {
id: 'tickAutoSkip',
beforeDraw: function(chart, options) {
helpers.each(chart.scales, function(scale) {
var scaleOptions = scale.options;
if (scaleOptions.display && scale.isHorizontal()) {
scale.tickSkip = [1, 3, 5, 7];
}
});
},
};
};Then in core.scale.js: helpers.each(me.ticks, function(tick, index) {
// Don't draw skipped ticks
if (me.tickSkip && me.tickSkip.indexOf(index) !== -1) {
return;
} |
|
Not sure about if (me.tickSkip && me.tickSkip.indexOf(index) !== -1) {
return;
}if |
|
Agree but also I'm not sure about a plugin accessing (private) members of scales. I think scales should provide all options that allows the user to fully customize ticks (e.g. a filter callback, etc.). Then the auto skip plugin would simply override these options. Could require some substantial changes, so maybe we should first implement the feature of this PR directly in scale and work on the plugin refactor in another PR? |
|
Doesn't seem like this is needed anymore with the changes to master. |

We are currently using the category scale to show dates in a combo bar/line chart and would rather not have a large tick gap with inconsistent spacing between ticks.
Default functionality:
https://codepen.io/anon/pen/GEEqpr
AutoSkipLast disabled:
https://codepen.io/anon/pen/pwwbex