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
Fix chart crashing when max is defined but ticks are empty #9641
Conversation
The change looks fine. is it possible to write a test case for this? |
@etimberg I've pushed an update with a new spec. Without the code change, the following error is thrown when the spec is executing:
|
There seems to be another related case: var chart = window.acquireChart({
type: 'line',
data: {
datasets: [{
data: [200]
}],
},
options: {
scales: {
y: {
min: 250
}
}
}
});
expect(chart.scales.y.min).toBe(250);
Both cases are fixed by making sure // Make sure min <= max when only min or max is defined by user and the data is outside that range
min = maxDefined && min > max ? max : min;
max = minDefined && min > max ? min : max;
return {
min: finiteOrDefault(min, finiteOrDefault(max, min)),
max: finiteOrDefault(max, finiteOrDefault(min, max))
}; |
So, my question is, are you willing to fix the other case here too, or should it be handled separately? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kurkle had a good comment. I think it'd be good to address the two cases together
If tick size is 0, and a
max
is defined withoutmin
, Chart.js would crash with:This adds an extra check to prevent
ticks[ticks.length - 1]
from erroring.