Skip to content

Commit

Permalink
Fix destructuring, add test to catch
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Nov 7, 2019
1 parent 713cc57 commit f9b72ef
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/core.datasetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ helpers.extend(DatasetController.prototype, {
var stacked = canStack && meta._stacked;
var indices = getSortedDatasetIndices(chart, true);
var otherScale = this._getOtherScale(scale);
var {otherMin, otherMax} = getUserBounds(otherScale);
var {min: otherMin, max: otherMax} = getUserBounds(otherScale);
var i, item, value, parsed, stack, min, minPositive, otherValue;

min = minPositive = Number.POSITIVE_INFINITY;
Expand Down
36 changes: 36 additions & 0 deletions test/specs/core.scale.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,40 @@ describe('Core.scale', function() {
});

});

describe('min and max', function() {
it('should be limited to visible data', function() {
var chart = window.acquireChart({
type: 'scatter',
data: {
datasets: [{
data: [{x: 100, y: 100}, {x: -100, y: -100}]
}, {
data: [{x: 10, y: 10}, {x: -10, y: -10}]
}]
},
options: {
scales: {
xAxes: [{
id: 'x',
type: 'linear',
ticks: {
min: -20,
max: 20
}
}],
yAxes: [{
id: 'y',
type: 'linear'
}]
}
}
});

expect(chart.scales.x.min).toEqual(-20);
expect(chart.scales.x.max).toEqual(20);
expect(chart.scales.y.min).toEqual(-10);
expect(chart.scales.y.max).toEqual(10);
});
});
});

0 comments on commit f9b72ef

Please sign in to comment.