-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG] Chart.js grid lines and axes not working in v2.7.1 as they did in v2.4.0 #5017
Comments
Thanks for reporting this @seancclark. I looked at both fiddles and the canvas is the same size in both. The issue with the grid lines looks like it changed in v2.5.0. I think the change boils down to starting with v2.5, the step is incremented from the axis minimum value while in older versions it seems to have been centered around 0. I think a different, easier to use, mechanism needs to be created for specifying tick marks at certain values. @simonbrunel @benmccann how would you feel some of the following options:
|
Isn't it the same as the scale
What would be inputs/outputs of this function? Scriptable options are mapped to the dataset/data, doesn't really make sense for ticks. |
Yup, like options {
scales: {
yAxes: [{
ticks: {
values: [0, 19, 43, 50] // implies min == 0, max == 50
}
}]
}
} The function idea would take the data range and return the ticks. Ticks outside the range would be ignored. options {
scales: {
yAxes: [{
ticks: {
generator: function(range) {
return [0, 10, 20];
}
}
}]
}
} |
#4506 is about |
Yup! That would fix 2 issues at once 😄 |
@etimberg I think having different configuration options if (typeof values === 'function') {
values = values(generationOptions, dataRange);
}
if (!values) {
// generate default
} |
Agree with @jcopperfield, that's what we do with scriptable options. Though, I would keep the options {
scales: {
yAxes: [{
labels: [0,10,20],
// or
labels: function(context) {
// context: {chart, range?, ...)
return [...];
}
}]
}
} Actually, you might be right @etimberg, that could be a scriptable option with a scale specific context. |
@simonbrunel didn't know there scriptable options were already implemented. However wouldn't it be better to call the scriptable option function using |
Why would it be better? |
So that someone trying to override the function would get the same |
That would make the whole scriptable concept hard to understand and maintain because not consistent. I doubt there is any advantage to map the generators/formatters signatures with our options. The context object should be simple and the same for all options under In the case you want to write a custom generator/formatter, then it's easier to override/augment these methods directly (there is a ticket to make them public). If you want a very custom |
Appear to have found a bug (or something has changed between version 2.4.0 and v2.7.1).
Working example with v2.4.0: https://jsfiddle.net/juk94xpo/
However chart doesn't look as it should if you upgrade to v2.7.1: https://jsfiddle.net/1sqkztto/
It seems that v2.7.1 does not draw tick marks in the correct position and axes disappear. This worked correctly in v2.4.0.
The text was updated successfully, but these errors were encountered: