plotly.js 2.13.0 → 2.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * plotly.js (mapbox) v2.13.0
2
+ * plotly.js (mapbox) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -83855,7 +83855,14 @@ var p2r = helpers.p2r;
83855
83855
  var axValue = helpers.axValue;
83856
83856
  var getTransform = helpers.getTransform;
83857
83857
 
83858
+ function hasSubplot(dragOptions) {
83859
+ // N.B. subplot may be falsy e.g zero sankey index!
83860
+ return dragOptions.subplot !== undefined;
83861
+ }
83862
+
83858
83863
  function prepSelect(evt, startX, startY, dragOptions, mode) {
83864
+ var isCartesian = !hasSubplot(dragOptions);
83865
+
83859
83866
  var isFreeMode = freeMode(mode);
83860
83867
  var isRectMode = rectMode(mode);
83861
83868
  var isOpenMode = openMode(mode);
@@ -83869,7 +83876,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
83869
83876
  var gd = dragOptions.gd;
83870
83877
  var fullLayout = gd._fullLayout;
83871
83878
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
83872
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
83879
+ isCartesian; // N.B. only cartesian subplots have persistent selection
83873
83880
 
83874
83881
  var zoomLayer = fullLayout._zoomlayer;
83875
83882
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -83917,9 +83924,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
83917
83924
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
83918
83925
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
83919
83926
  stroke: newStyle.line.color || (
83920
- dragOptions.subplot !== undefined ?
83921
- '#7f7f7f' : // non-cartesian subplot
83922
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
83927
+ isCartesian ?
83928
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
83929
+ '#7f7f7f' // non-cartesian subplot
83923
83930
  ),
83924
83931
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
83925
83932
  'stroke-width': newStyle.line.width + 'px',
@@ -83950,6 +83957,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
83950
83957
 
83951
83958
  if(immediateSelect && !evt.shiftKey) {
83952
83959
  dragOptions._clearSubplotSelections = function() {
83960
+ if(!isCartesian) return;
83961
+
83953
83962
  var xRef = xAxis._id;
83954
83963
  var yRef = yAxis._id;
83955
83964
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -83970,6 +83979,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
83970
83979
  }
83971
83980
 
83972
83981
  if(selectionErased) {
83982
+ gd._fullLayout._noEmitSelectedAtStart = true;
83983
+
83973
83984
  Registry.call('_guiRelayout', gd, {
83974
83985
  selections: list
83975
83986
  });
@@ -84111,10 +84122,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
84111
84122
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
84112
84123
 
84113
84124
  if(isSelectMode) {
84114
- var _res = reselect(gd);
84125
+ var _res = reselect(gd, false);
84115
84126
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
84116
84127
 
84117
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
84128
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
84118
84129
  selectionTesters = _res.selectionTesters;
84119
84130
  eventData = _res.eventData;
84120
84131
 
@@ -84208,9 +84219,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
84208
84219
  }
84209
84220
  }
84210
84221
 
84211
- Registry.call('_guiRelayout', gd, {
84212
- selections: subSelections
84213
- });
84222
+ if(subSelections.length < allSelections.length) {
84223
+ gd._fullLayout._noEmitSelectedAtStart = true;
84224
+
84225
+ Registry.call('_guiRelayout', gd, {
84226
+ selections: subSelections
84227
+ });
84228
+ }
84214
84229
  }
84215
84230
  }
84216
84231
  } else {
@@ -84256,8 +84271,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
84256
84271
  dragOptions.doneFnCompleted(selection);
84257
84272
  }
84258
84273
 
84259
- eventData.selections = gd.layout.selections;
84260
- emitSelected(gd, eventData);
84274
+ if(isSelectMode) {
84275
+ emitSelected(gd, eventData);
84276
+ }
84261
84277
  }).catch(Lib.error);
84262
84278
  };
84263
84279
  }
@@ -84335,7 +84351,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
84335
84351
  }
84336
84352
 
84337
84353
  if(sendEvents) {
84338
- eventData.selections = gd.layout.selections;
84339
84354
  emitSelected(gd, eventData);
84340
84355
  }
84341
84356
  }
@@ -84480,15 +84495,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
84480
84495
  }
84481
84496
  }
84482
84497
 
84498
+ function hasActiveShape(gd) {
84499
+ return gd._fullLayout._activeShapeIndex >= 0;
84500
+ }
84501
+
84502
+ function hasActiveSelection(gd) {
84503
+ return gd._fullLayout._activeSelectionIndex >= 0;
84504
+ }
84505
+
84483
84506
  function clearSelectionsCache(dragOptions, immediateSelect) {
84484
84507
  var dragmode = dragOptions.dragmode;
84485
84508
  var plotinfo = dragOptions.plotinfo;
84486
84509
 
84487
84510
  var gd = dragOptions.gd;
84488
- if(gd._fullLayout._activeShapeIndex >= 0) {
84511
+ if(hasActiveShape(gd)) {
84489
84512
  gd._fullLayout._deactivateShape(gd);
84490
84513
  }
84491
- if(gd._fullLayout._activeSelectionIndex >= 0) {
84514
+ if(hasActiveSelection(gd)) {
84492
84515
  gd._fullLayout._deactivateSelection(gd);
84493
84516
  }
84494
84517
 
@@ -84516,11 +84539,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
84516
84539
  var selections;
84517
84540
  if(
84518
84541
  isSelectMode &&
84519
- !dragOptions.subplot // only allow cartesian - no mapbox for now
84542
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
84520
84543
  ) {
84521
84544
  selections = newSelections(outlines, dragOptions);
84522
84545
  }
84523
84546
  if(selections) {
84547
+ gd._fullLayout._noEmitSelectedAtStart = true;
84548
+
84524
84549
  Registry.call('_guiRelayout', gd, {
84525
84550
  selections: selections
84526
84551
  }).then(function() {
@@ -84555,7 +84580,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
84555
84580
 
84556
84581
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
84557
84582
 
84558
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
84583
+ if(
84584
+ hasSubplot({subplot: subplot}) &&
84585
+ (trace.subplot === subplot || trace.geo === subplot)
84586
+ ) {
84559
84587
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
84560
84588
  } else if(trace.type === 'splom') {
84561
84589
  // FIXME: make sure we don't have more than single axis for splom
@@ -84855,7 +84883,7 @@ function _doSelect(selectionTesters, searchTraces) {
84855
84883
  return allSelections;
84856
84884
  }
84857
84885
 
84858
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
84886
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
84859
84887
  var hadSearchTraces = !!searchTraces;
84860
84888
  var plotinfo, xRef, yRef;
84861
84889
  if(dragOptions) {
@@ -84978,15 +85006,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
84978
85006
  updateSelectedState(gd, allSearchTraces, eventData);
84979
85007
 
84980
85008
  var clickmode = fullLayout.clickmode;
84981
- var sendEvents = clickmode.indexOf('event') > -1;
85009
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
84982
85010
 
84983
85011
  if(
84984
85012
  !plotinfo && // get called from plot_api & plots
84985
- fullLayout._reselect
85013
+ mayEmitSelected
84986
85014
  ) {
84987
- if(sendEvents) {
84988
- var activePolygons = getLayoutPolygons(gd, true);
85015
+ var activePolygons = getLayoutPolygons(gd, true);
84989
85016
 
85017
+ if(activePolygons.length) {
84990
85018
  var xref = activePolygons[0].xref;
84991
85019
  var yref = activePolygons[0].yref;
84992
85020
  if(xref && yref) {
@@ -84999,9 +85027,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
84999
85027
 
85000
85028
  fillRangeItems(eventData, poly);
85001
85029
  }
85030
+ }
85002
85031
 
85003
- eventData.selections = gd.layout.selections;
85004
- emitSelected(gd, eventData);
85032
+ if(gd._fullLayout._noEmitSelectedAtStart) {
85033
+ gd._fullLayout._noEmitSelectedAtStart = false;
85034
+ } else {
85035
+ if(sendEvents) emitSelected(gd, eventData);
85005
85036
  }
85006
85037
 
85007
85038
  fullLayout._reselect = false;
@@ -85021,10 +85052,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
85021
85052
 
85022
85053
  if(sendEvents) {
85023
85054
  if(eventData.points.length) {
85024
- eventData.selections = gd.layout.selections;
85025
85055
  emitSelected(gd, eventData);
85026
85056
  } else {
85027
- gd.emit('plotly_deselect', null);
85057
+ emitDeselect(gd);
85028
85058
  }
85029
85059
  }
85030
85060
 
@@ -85316,6 +85346,10 @@ function emitSelecting(gd, eventData) {
85316
85346
  }
85317
85347
 
85318
85348
  function emitSelected(gd, eventData) {
85349
+ if(eventData) {
85350
+ eventData.selections = (gd.layout || {}).selections || [];
85351
+ }
85352
+
85319
85353
  gd.emit('plotly_selected', eventData);
85320
85354
  }
85321
85355
 
@@ -124219,7 +124253,16 @@ plots.redrag = function(gd) {
124219
124253
  };
124220
124254
 
124221
124255
  plots.reselect = function(gd) {
124222
- Registry.getComponentMethod('selections', 'reselect')(gd);
124256
+ var fullLayout = gd._fullLayout;
124257
+
124258
+ var A = (gd.layout || {}).selections;
124259
+ var B = fullLayout._previousSelections;
124260
+ fullLayout._previousSelections = A;
124261
+
124262
+ var mayEmitSelected = fullLayout._reselect ||
124263
+ JSON.stringify(A) !== JSON.stringify(B);
124264
+
124265
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
124223
124266
  };
124224
124267
 
124225
124268
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -131871,7 +131914,7 @@ function getSortFunc(opts, d2c) {
131871
131914
  'use strict';
131872
131915
 
131873
131916
  // package version injected by `npm run preprocess`
131874
- exports.version = '2.13.0';
131917
+ exports.version = '2.13.3';
131875
131918
 
131876
131919
  },{}]},{},[9])(9)
131877
131920
  });