Skip to content

Commit 9607382

Browse files
committed
Consolidate makeSelectedOptions
1 parent 7eeacb1 commit 9607382

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/traces/scattergl/index.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -387,30 +387,28 @@ function sceneOptions(container, subplot, trace, positions) {
387387

388388
if(hasMarkers) {
389389
markerOptions = makeMarkerOptions(markerOpts);
390+
selectedOptions = makeSelectedOptions(trace.selected, markerOpts);
391+
unselectedOptions = makeSelectedOptions(trace.unselected, markerOpts);
390392

391-
if(trace.selected.marker.symbol) {
392-
selectedOptions = makeMarkerOptions(extend({}, markerOpts, trace.selected.marker));
393-
}
394-
// shortcut simple selection logic
395-
else {
396-
selectedOptions = {};
397-
if(trace.selected.marker.size) selectedOptions.sizes = trace.selected.marker.size;
398-
if(trace.selected.marker.color) selectedOptions.colors = trace.selected.marker.color;
399-
if(trace.selected.marker.opacity !== undefined) selectedOptions.opacity = trace.selected.marker.opacity;
400-
}
393+
markerOptions.positions = positions;
394+
}
395+
396+
function makeSelectedOptions(selected, markerOpts) {
397+
var options = {};
401398

402-
if(trace.unselected.marker.symbol) {
403-
unselectedOptions = makeMarkerOptions(extend({}, markerOpts, trace.unselected.marker));
399+
if(selected.marker.symbol) {
400+
options = makeMarkerOptions(extend({}, markerOpts, selected.marker));
404401
}
402+
405403
// shortcut simple selection logic
406404
else {
407-
unselectedOptions = {};
408-
if(trace.unselected.marker.size) unselectedOptions.sizes = trace.unselected.marker.size;
409-
if(trace.unselected.marker.color) unselectedOptions.colors = trace.unselected.marker.color;
410-
if(trace.unselected.marker.opacity !== undefined) unselectedOptions.opacity = trace.unselected.marker.opacity;
405+
options = {};
406+
if(selected.marker.size) options.sizes = selected.marker.size;
407+
if(selected.marker.color) options.colors = selected.marker.color;
408+
if(selected.marker.opacity !== undefined) options.opacity = selected.marker.opacity;
411409
}
412410

413-
markerOptions.positions = positions;
411+
return options;
414412
}
415413

416414
function makeMarkerOptions(markerOpts) {

0 commit comments

Comments
 (0)