Skip to content

Commit 117542f

Browse files
committed
array parts get the same replot type as the whole array
1 parent 2070279 commit 117542f

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/plot_api/plot_api.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,10 @@ function _restyle(gd, aobj, _traces) {
15991599
flags.docolorbars = true;
16001600
}
16011601

1602-
if(recalcAttrs.indexOf(ai) !== -1) {
1602+
var aiArrayStart = ai.indexOf('['),
1603+
aiAboveArray = aiArrayStart === -1 ? ai : ai.substr(0, aiArrayStart);
1604+
1605+
if(recalcAttrs.indexOf(aiAboveArray) !== -1) {
16031606
// major enough changes deserve autoscale, autobin, and
16041607
// non-reversed axes so people don't get confused
16051608
if(['orientation', 'type'].indexOf(ai) !== -1) {
@@ -1622,8 +1625,8 @@ function _restyle(gd, aobj, _traces) {
16221625
}
16231626
flags.docalc = true;
16241627
}
1625-
else if(replotAttrs.indexOf(ai) !== -1) flags.doplot = true;
1626-
else if(autorangeAttrs.indexOf(ai) !== -1) flags.docalcAutorange = true;
1628+
else if(replotAttrs.indexOf(aiAboveArray) !== -1) flags.doplot = true;
1629+
else if(autorangeAttrs.indexOf(aiAboveArray) !== -1) flags.docalcAutorange = true;
16271630
}
16281631

16291632
// do we need to force a recalc?

test/jasmine/tests/plot_api_test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,28 @@ describe('Test plot api', function() {
283283
expect(gd._fullData[1].marker.color).toBe(colorDflt[1]);
284284
});
285285

286+
it('should redo auto z/contour when editing z array', function() {
287+
var gd = {
288+
data: [{type: 'contour', z: [[1, 2], [3, 4]]}]
289+
};
290+
291+
mockDefaultsAndCalc(gd);
292+
293+
expect(gd.data[0].zauto).toBe(true);
294+
expect(gd.data[0].zmin).toBe(1);
295+
expect(gd.data[0].zmax).toBe(4);
296+
297+
expect(gd.data[0].autocontour).toBe(true);
298+
expect(gd.data[0].contours).toEqual({start: 0.5, end: 3.5, size: 0.5});
299+
300+
Plotly.restyle(gd, {'z[0][0]': 10});
301+
302+
expect(gd.data[0].zmin).toBe(2);
303+
expect(gd.data[0].zmax).toBe(10);
304+
305+
expect(gd.data[0].contours).toEqual({start: 3, end: 9, size: 1});
306+
});
307+
286308
});
287309

288310
describe('Plotly.deleteTraces', function() {

0 commit comments

Comments
 (0)