@@ -50,7 +50,14 @@ var p2r = helpers.p2r;
5050var axValue = helpers . axValue ;
5151var getTransform = helpers . getTransform ;
5252
53+ function hasSubplot ( dragOptions ) {
54+ // N.B. subplot may be falsy e.g zero sankey index!
55+ return dragOptions . subplot !== undefined ;
56+ }
57+
5358function prepSelect ( evt , startX , startY , dragOptions , mode ) {
59+ var isCartesian = ! hasSubplot ( dragOptions ) ;
60+
5461 var isFreeMode = freeMode ( mode ) ;
5562 var isRectMode = rectMode ( mode ) ;
5663 var isOpenMode = openMode ( mode ) ;
@@ -64,7 +71,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
6471 var gd = dragOptions . gd ;
6572 var fullLayout = gd . _fullLayout ;
6673 var immediateSelect = isSelectMode && fullLayout . newselection . mode === 'immediate' &&
67- ! dragOptions . subplot ; // N.B. only cartesian subplots have persistent selection
74+ isCartesian ; // N.B. only cartesian subplots have persistent selection
6875
6976 var zoomLayer = fullLayout . _zoomlayer ;
7077 var dragBBox = dragOptions . element . getBoundingClientRect ( ) ;
@@ -112,9 +119,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
112119 opacity : isDrawMode ? newStyle . opacity / 2 : 1 ,
113120 fill : ( isDrawMode && ! isOpenMode ) ? newStyle . fillcolor : 'none' ,
114121 stroke : newStyle . line . color || (
115- dragOptions . subplot !== undefined ?
116- '#7f7f7f' : // non-cartesian subplot
117- Color . contrast ( gd . _fullLayout . plot_bgcolor ) // cartesian subplot
122+ isCartesian ?
123+ Color . contrast ( gd . _fullLayout . plot_bgcolor ) :
124+ '#7f7f7f' // non- cartesian subplot
118125 ) ,
119126 'stroke-dasharray' : dashStyle ( newStyle . line . dash , newStyle . line . width ) ,
120127 'stroke-width' : newStyle . line . width + 'px' ,
@@ -145,6 +152,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
145152
146153 if ( immediateSelect && ! evt . shiftKey ) {
147154 dragOptions . _clearSubplotSelections = function ( ) {
155+ if ( ! isCartesian ) return ;
156+
148157 var xRef = xAxis . _id ;
149158 var yRef = yAxis . _id ;
150159 deselectSubplot ( gd , xRef , yRef , searchTraces ) ;
@@ -719,7 +728,7 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
719728 var selections ;
720729 if (
721730 isSelectMode &&
722- ! dragOptions . subplot // only allow cartesian - no mapbox for now
731+ ! hasSubplot ( dragOptions ) // only allow cartesian - no mapbox for now
723732 ) {
724733 selections = newSelections ( outlines , dragOptions ) ;
725734 }
@@ -758,7 +767,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
758767
759768 if ( trace . visible !== true || ! trace . _module || ! trace . _module . selectPoints ) continue ;
760769
761- if ( subplot && ( trace . subplot === subplot || trace . geo === subplot ) ) {
770+ if (
771+ hasSubplot ( { subplot : subplot } ) &&
772+ ( trace . subplot === subplot || trace . geo === subplot )
773+ ) {
762774 searchTraces . push ( createSearchInfo ( trace . _module , cd , xAxes [ 0 ] , yAxes [ 0 ] ) ) ;
763775 } else if ( trace . type === 'splom' ) {
764776 // FIXME: make sure we don't have more than single axis for splom
0 commit comments