Skip to content

Commit 4e8ff28

Browse files
committed
🔒 marker.size calc + autorange edit behavior
1 parent 6e19c6e commit 4e8ff28

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

src/traces/scatter/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ module.exports = {
273273
dflt: 6,
274274
arrayOk: true,
275275
role: 'style',
276-
editType: 'calcIfAutorange',
276+
editType: 'calc',
277277
description: 'Sets the marker size (in px).'
278278
},
279279
maxdisplayed: {

test/jasmine/tests/scatter_test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,50 @@ describe('end-to-end scatter tests', function() {
878878
.catch(failTest)
879879
.then(done);
880880
});
881+
882+
it('should update axis range accordingly on marker.size edits', function(done) {
883+
function _assert(msg, xrng, yrng) {
884+
var fullLayout = gd._fullLayout;
885+
expect(fullLayout.xaxis.range).toBeCloseToArray(xrng, 2, msg + ' xrng');
886+
expect(fullLayout.yaxis.range).toBeCloseToArray(yrng, 2, msg + ' yrng');
887+
}
888+
889+
// edit types are important to this test
890+
var schema = Plotly.PlotSchema.get();
891+
expect(schema.traces.scatter.attributes.marker.size.editType)
892+
.toBe('calc', 'marker.size editType');
893+
expect(schema.layout.layoutAttributes.xaxis.autorange.editType)
894+
.toBe('plot', 'ax autorange editType');
895+
896+
Plotly.plot(gd, [{ y: [1, 2, 1] }])
897+
.then(function() {
898+
_assert('auto rng / base marker.size', [-0.13, 2.13], [0.93, 2.07]);
899+
return Plotly.relayout(gd, {
900+
'xaxis.range': [0, 2],
901+
'yaxis.range': [0, 2]
902+
});
903+
})
904+
.then(function() {
905+
_assert('set rng / base marker.size', [0, 2], [0, 2]);
906+
return Plotly.restyle(gd, 'marker.size', 50);
907+
})
908+
.then(function() {
909+
_assert('set rng / big marker.size', [0, 2], [0, 2]);
910+
return Plotly.relayout(gd, {
911+
'xaxis.autorange': true,
912+
'yaxis.autorange': true
913+
});
914+
})
915+
.then(function() {
916+
_assert('auto rng / big marker.size', [-0.28, 2.28], [0.75, 2.25]);
917+
return Plotly.restyle(gd, 'marker.size', null);
918+
})
919+
.then(function() {
920+
_assert('auto rng / base marker.size', [-0.13, 2.13], [0.93, 2.07]);
921+
})
922+
.catch(failTest)
923+
.then(done);
924+
});
881925
});
882926

883927
describe('scatter hoverPoints', function() {

0 commit comments

Comments
 (0)