Skip to content

Commit 145cad3

Browse files
committed
try implementing a fast 'markerSize' editType
- marker.size is hard to edit fast, as in general it can change the axis ranges
1 parent 3eb91c0 commit 145cad3

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

src/plot_api/edit_types.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var isPlainObject = Lib.isPlainObject;
1515
var traceOpts = {
1616
valType: 'flaglist',
1717
extras: ['none'],
18-
flags: ['calc', 'clearAxisTypes', 'plot', 'style', 'colorbars'],
18+
flags: ['calc', 'clearAxisTypes', 'plot', 'style', 'markerSize', 'colorbars'],
1919
description: [
2020
'trace attributes should include an `editType` string matching this flaglist.',
2121
'*calc* is the most extensive: a full `Plotly.plot` starting by clearing `gd.calcdata`',
@@ -24,7 +24,8 @@ var traceOpts = {
2424
'cause the automatic axis type detection to change. Log type will not be cleared, as that',
2525
'is never automatically chosen so must have been user-specified.',
2626
'*plot* calls `Plotly.plot` but without first clearing `gd.calcdata`.',
27-
'*style* only calls `module.style` for all trace modules and redraws the legend.',
27+
'*style* only calls `module.style` (or module.editStyle) for all trace modules and redraws the legend.',
28+
'*markerSize* is like *style*, but propagate axis-range changes due to scatter `marker.size`',
2829
'*colorbars* only redraws colorbars.'
2930
].join(' ')
3031
};

src/plot_api/plot_api.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,8 +1344,21 @@ exports.restyle = function restyle(gd, astr, val, _traces) {
13441344
} else {
13451345
seq.push(Plots.previousPromises);
13461346

1347+
// maybe only call Plots.supplyDataDefaults in the splom case,
1348+
// to skip over long and slow axes defaults
13471349
Plots.supplyDefaults(gd);
13481350

1351+
if(flags.markerSize) {
1352+
Plots.doCalcdata(gd);
1353+
addAxRangeSequence(seq);
1354+
1355+
// TODO
1356+
// if all axes have autorange:false, then
1357+
// proceed to subroutines.doTraceStyle(),
1358+
// otherwise we must go through addAxRangeSequence,
1359+
// which in general must redraws 'all' axes
1360+
}
1361+
13491362
if(flags.style) seq.push(subroutines.doTraceStyle);
13501363
if(flags.colorbars) seq.push(subroutines.doColorBars);
13511364

src/traces/splom/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104

105105
marker: extendFlat({}, colorAttrs('marker'), {
106106
symbol: scatterMarkerAttrs.symbol,
107-
size: scatterMarkerAttrs.size,
107+
size: extendFlat({}, scatterMarkerAttrs.size, {editType: 'markerSize'}),
108108
sizeref: scatterMarkerAttrs.sizeref,
109109
sizemin: scatterMarkerAttrs.sizemin,
110110
sizemode: scatterMarkerAttrs.sizemode,

test/jasmine/tests/splom_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,40 @@ describe('Test splom update switchboard:', function() {
922922

923923
return Plotly.restyle(gd, 'marker.size', 20);
924924
})
925+
.then(function() {
926+
var msg = 'after scalar marker.size restyle';
927+
928+
assertSpies(msg, [
929+
['supplyDefaults', 1],
930+
['doCalcdata', 1],
931+
['doTicks', 1],
932+
['regl clear', 1],
933+
['update', 1],
934+
['draw', 1]
935+
]);
936+
937+
expect(scene.matrixOptions.size).toBe(10, msg);
938+
expect(gd._fullLayout.xaxis.range)
939+
.toBeCloseToArray([0.753, 3.246], 1, 'xrng ' + msg);
940+
941+
return Plotly.restyle(gd, 'marker.size', [[4, 10, 20]]);
942+
})
943+
.then(function() {
944+
var msg = 'after scalar marker.size restyle';
945+
946+
assertSpies(msg, [
947+
['supplyDefaults', 1],
948+
['doCalcdata', 1],
949+
['doTicks', 1],
950+
['regl clear', 1],
951+
['update', 1],
952+
['draw', 1]
953+
]);
954+
955+
expect(scene.matrixOptions.sizes).toBeCloseToArray([2, 5, 10], 1, msg);
956+
expect(gd._fullLayout.xaxis.range)
957+
.toBeCloseToArray([0.853, 3.235], 1, 'xrng ' + msg);
958+
})
925959
.catch(failTest)
926960
.then(done);
927961
});

0 commit comments

Comments
 (0)