-
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
[BUG] Use time.unit option to create default min/max for empty chart #5045
[BUG] Use time.unit option to create default min/max for empty chart #5045
Conversation
…ption, instead of default 'day'.
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.
I agree with @simonbrunel about a test. Other than that, looks great!
@simonbrunel I don't know what you are expecting the code to do in those 2 test situations. The PR sets the scale limits for |
It's not specific to auto generated timestamps but to all cases where there is no labels or data or explicit min/max to compute a valid data range. If it ('should correctly handle empty `data.labels` using `time.unit`', function() {
var chart = this.chart;
var scale = chart.scales.x;
var options = chart.options.scales.xAxes[0];
options.time.unit = 'year';
chart.data.labels = [];
chart.update();
expect(scale.min).toEqual(+moment().startOf('year'));
expect(scale.max).toEqual(+moment().endOf('year') + 1);
expect(getTicksLabels(scale)).toEqual([]);
}); We should also rename tests I linked for something more explicit, like: it ('should correctly handle empty `data.labels` using "day" if `time.unit` is undefined', ... |
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.
Thanks @jcopperfield
Currently the default
min/max
values for the time scale are create with theday
unit.If the user has set the
time.unit
option and has hidden all the datasets, the scale will be empty (no tick labels).Using the
time.unit
option will show the labels as selected.