Skip to content
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 #4216 when dataset empty, set scale min max to default if null #4258

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 3 additions & 20 deletions src/scales/scale.linearbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ module.exports = function(Chart) {
}
}

var setMin = tickOpts.min !== undefined || tickOpts.suggestedMin !== undefined;
var setMax = tickOpts.max !== undefined || tickOpts.suggestedMax !== undefined;

if (tickOpts.min !== undefined) {
me.min = tickOpts.min;
} else if (tickOpts.suggestedMin !== undefined) {
Expand All @@ -50,24 +47,10 @@ module.exports = function(Chart) {
}
}

if (setMin !== setMax) {
// We set the min or the max but not both.
// So ensure that our range is good
// Inverted or 0 length range can happen when
// ticks.min is set, and no datasets are visible
if (me.min >= me.max) {
if (setMin) {
me.max = me.min + 1;
} else {
me.min = me.max - 1;
}
}
}

if (me.min === me.max) {
me.max++;
if (me.min >= me.max) {
me.max = me.min + 1;

if (!tickOpts.beginAtZero) {
if (tickOpts.min === undefined && !tickOpts.beginAtZero) {
me.min--;
}
}
Expand Down