Skip to content

Commit 4c250c3

Browse files
committed
setPositions even when recalc===false
1 parent 424f4a6 commit 4c250c3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/plot_api/plot_api.js

+1
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ exports.plot = function(gd, data, layout, config) {
288288

289289
function positionAndAutorange() {
290290
if(!recalc) {
291+
Plots.doSetPositions(gd);
291292
doAutoRangeAndConstraints();
292293
return;
293294
}

test/jasmine/tests/bar_test.js

+44
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,50 @@ describe('A bar plot', function() {
13311331
.catch(failTest)
13321332
.then(done);
13331333
});
1334+
1335+
it('should update axis range according to visible edits', function(done) {
1336+
var schema = Plotly.PlotSchema.get();
1337+
expect(schema.traces.bar.attributes.visible.editType)
1338+
.toBe('plot', 'visible editType');
1339+
1340+
function _assert(msg, xrng, yrng, calls) {
1341+
var fullLayout = gd._fullLayout;
1342+
expect(fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg + ' xrng');
1343+
expect(fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg + ' yrng');
1344+
1345+
var setPositions = gd._fullData[0]._module.setPositions;
1346+
expect(setPositions).toHaveBeenCalledTimes(calls);
1347+
setPositions.calls.reset();
1348+
}
1349+
1350+
Plotly.plot(gd, [
1351+
{type: 'bar', x: [1, 2, 3], y: [1, 2, 1]},
1352+
{type: 'bar', x: [1, 2, 3], y: [-1, -2, -1]}
1353+
])
1354+
.then(function() {
1355+
spyOn(gd._fullData[0]._module, 'setPositions').and.callThrough();
1356+
1357+
_assert('base', [0.5, 3.5], [-2.222, 2.222], 0);
1358+
return Plotly.restyle(gd, 'visible', false, [1]);
1359+
})
1360+
.then(function() {
1361+
_assert('visible [true,false]', [0.5, 3.5], [0, 2.105], 1);
1362+
return Plotly.restyle(gd, 'visible', false, [0]);
1363+
})
1364+
.then(function() {
1365+
_assert('both invisible', [0.5, 3.5], [0, 2.105], 0);
1366+
return Plotly.restyle(gd, 'visible', true, [1]);
1367+
})
1368+
.then(function() {
1369+
_assert('visible [false,true]', [0.5, 3.5], [-2.105, 0], 1);
1370+
return Plotly.restyle(gd, 'visible', true);
1371+
})
1372+
.then(function() {
1373+
_assert('back to both visible', [0.5, 3.5], [-2.222, 2.222], 1);
1374+
})
1375+
.catch(failTest)
1376+
.then(done);
1377+
});
13341378
});
13351379

13361380
describe('bar hover', function() {

0 commit comments

Comments
 (0)