Skip to content

Commit 33c1638

Browse files
authored
Allow scale to auto-adjust it's min when stacked (#9045)
1 parent 7c3a412 commit 33c1638

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/scales/scale.linearbase.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,14 @@ export default class LinearScaleBase extends Scale {
168168

169169
handleTickRangeOptions() {
170170
const me = this;
171-
const {beginAtZero, stacked} = me.options;
171+
const {beginAtZero} = me.options;
172172
const {minDefined, maxDefined} = me.getUserBounds();
173173
let {min, max} = me;
174174

175175
const setMin = v => (min = minDefined ? min : v);
176176
const setMax = v => (max = maxDefined ? max : v);
177177

178-
if (beginAtZero || stacked) {
178+
if (beginAtZero) {
179179
const minSign = sign(min);
180180
const maxSign = sign(max);
181181

test/specs/scale.linear.tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ describe('Linear Scale', function() {
194194
chart.scales.y.options.stacked = true;
195195
chart.update();
196196

197+
expect(chart.scales.y.min).toBe(30);
198+
expect(chart.scales.y.max).toBe(90);
199+
200+
chart.scales.y.options.beginAtZero = true;
201+
chart.update();
202+
197203
expect(chart.scales.y.min).toBe(0);
198204
expect(chart.scales.y.max).toBe(90);
199205
});

0 commit comments

Comments
 (0)