@@ -19,6 +19,7 @@ var shapeHelpers = require('../shapes/helpers');
19
19
var shapeConstants = require ( '../shapes/constants' ) ;
20
20
21
21
var displayOutlines = require ( '../shapes/display_outlines' ) ;
22
+ var clearOutline = require ( '../shapes/handle_outline' ) . clearOutline ;
22
23
23
24
var newShapeHelpers = require ( '../shapes/draw_newshape/helpers' ) ;
24
25
var handleEllipse = newShapeHelpers . handleEllipse ;
@@ -44,8 +45,6 @@ var MINSELECT = constants.MINSELECT;
44
45
var filteredPolygon = polygon . filter ;
45
46
var polygonTester = polygon . tester ;
46
47
47
- var clearOutline = require ( '../shapes/handle_outline' ) . clearOutline ;
48
-
49
48
var helpers = require ( './helpers' ) ;
50
49
var p2r = helpers . p2r ;
51
50
var axValue = helpers . axValue ;
@@ -144,9 +143,43 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
144
143
var searchTraces = determineSearchTraces ( gd , dragOptions . xaxes ,
145
144
dragOptions . yaxes , dragOptions . subplot ) ;
146
145
146
+ if ( immediateSelect && ! evt . shiftKey ) {
147
+ dragOptions . _clearSubplotSelections = function ( ) {
148
+ var xRef = xAxis . _id ;
149
+ var yRef = yAxis . _id ;
150
+ deselectSubplot ( gd , xRef , yRef , searchTraces ) ;
151
+
152
+ var selections = ( gd . layout || { } ) . selections || [ ] ;
153
+ var list = [ ] ;
154
+ var selectionErased = false ;
155
+ for ( var q = 0 ; q < selections . length ; q ++ ) {
156
+ var s = fullLayout . selections [ q ] ;
157
+ if (
158
+ s . xref !== xRef ||
159
+ s . yref !== yRef
160
+ ) {
161
+ list . push ( selections [ q ] ) ;
162
+ } else {
163
+ selectionErased = true ;
164
+ }
165
+ }
166
+
167
+ if ( selectionErased ) {
168
+ Registry . call ( '_guiRelayout' , gd , {
169
+ selections : list
170
+ } ) ;
171
+ }
172
+ } ;
173
+ }
174
+
147
175
var fillRangeItems = getFillRangeItems ( dragOptions ) ;
148
176
149
177
dragOptions . moveFn = function ( dx0 , dy0 ) {
178
+ if ( dragOptions . _clearSubplotSelections ) {
179
+ dragOptions . _clearSubplotSelections ( ) ;
180
+ dragOptions . _clearSubplotSelections = undefined ;
181
+ }
182
+
150
183
x1 = Math . max ( 0 , Math . min ( pw , scaleX * dx0 + x0 ) ) ;
151
184
y1 = Math . max ( 0 , Math . min ( ph , scaleY * dy0 + y0 ) ) ;
152
185
@@ -1176,34 +1209,8 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
1176
1209
xRef = deselect . xref ;
1177
1210
yRef = deselect . yref ;
1178
1211
1179
- var foundSubplot = false ;
1180
- for ( var q = 0 ; q < allSearchTraces . length ; q ++ ) {
1181
- var a = allSearchTraces [ q ] ;
1182
- if (
1183
- ( a . xaxis && a . xaxis . _id === xRef ) &&
1184
- ( a . yaxis && a . yaxis . _id === yRef )
1185
- ) {
1186
- foundSubplot = true ;
1187
- break ;
1188
- }
1189
- }
1190
-
1191
- if ( ! foundSubplot ) {
1192
- // deselect traces in this subplot
1193
-
1194
- searchTraces = determineSearchTraces (
1195
- gd ,
1196
- [ getFromId ( gd , xRef , 'x' ) ] ,
1197
- [ getFromId ( gd , yRef , 'y' ) ] ,
1198
- xRef + yRef
1199
- ) ;
1200
-
1201
- for ( var k = 0 ; k < searchTraces . length ; k ++ ) {
1202
- var searchInfo = searchTraces [ k ] ;
1203
- searchInfo . _module . selectPoints ( searchInfo , false ) ;
1204
- }
1205
-
1206
- updateSelectedState ( gd , searchTraces ) ;
1212
+ if ( ! subplotSelected ( xRef , yRef , allSearchTraces ) ) {
1213
+ deselectSubplot ( gd , xRef , yRef , searchTraces ) ;
1207
1214
}
1208
1215
1209
1216
if ( sendEvents ) {
@@ -1240,6 +1247,35 @@ function epmtySplomSelectionBatch(gd) {
1240
1247
}
1241
1248
}
1242
1249
1250
+ function subplotSelected ( xRef , yRef , searchTraces ) {
1251
+ for ( var i = 0 ; i < searchTraces . length ; i ++ ) {
1252
+ var s = searchTraces [ i ] ;
1253
+ if (
1254
+ ( s . xaxis && s . xaxis . _id === xRef ) &&
1255
+ ( s . yaxis && s . yaxis . _id === yRef )
1256
+ ) {
1257
+ return true ;
1258
+ }
1259
+ }
1260
+ return false ;
1261
+ }
1262
+
1263
+ function deselectSubplot ( gd , xRef , yRef , searchTraces ) {
1264
+ searchTraces = determineSearchTraces (
1265
+ gd ,
1266
+ [ getFromId ( gd , xRef , 'x' ) ] ,
1267
+ [ getFromId ( gd , yRef , 'y' ) ] ,
1268
+ xRef + yRef
1269
+ ) ;
1270
+
1271
+ for ( var k = 0 ; k < searchTraces . length ; k ++ ) {
1272
+ var searchInfo = searchTraces [ k ] ;
1273
+ searchInfo . _module . selectPoints ( searchInfo , false ) ;
1274
+ }
1275
+
1276
+ updateSelectedState ( gd , searchTraces ) ;
1277
+ }
1278
+
1243
1279
function addTester ( layoutPolygons , xRef , yRef , selectionTesters ) {
1244
1280
var mergedPolygons ;
1245
1281
0 commit comments