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 (strict) v2.13.0
2
+ * plotly.js (strict) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -121036,7 +121036,14 @@ var p2r = helpers.p2r;
121036
121036
  var axValue = helpers.axValue;
121037
121037
  var getTransform = helpers.getTransform;
121038
121038
 
121039
+ function hasSubplot(dragOptions) {
121040
+ // N.B. subplot may be falsy e.g zero sankey index!
121041
+ return dragOptions.subplot !== undefined;
121042
+ }
121043
+
121039
121044
  function prepSelect(evt, startX, startY, dragOptions, mode) {
121045
+ var isCartesian = !hasSubplot(dragOptions);
121046
+
121040
121047
  var isFreeMode = freeMode(mode);
121041
121048
  var isRectMode = rectMode(mode);
121042
121049
  var isOpenMode = openMode(mode);
@@ -121050,7 +121057,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121050
121057
  var gd = dragOptions.gd;
121051
121058
  var fullLayout = gd._fullLayout;
121052
121059
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
121053
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
121060
+ isCartesian; // N.B. only cartesian subplots have persistent selection
121054
121061
 
121055
121062
  var zoomLayer = fullLayout._zoomlayer;
121056
121063
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -121098,9 +121105,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121098
121105
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
121099
121106
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
121100
121107
  stroke: newStyle.line.color || (
121101
- dragOptions.subplot !== undefined ?
121102
- '#7f7f7f' : // non-cartesian subplot
121103
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
121108
+ isCartesian ?
121109
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
121110
+ '#7f7f7f' // non-cartesian subplot
121104
121111
  ),
121105
121112
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
121106
121113
  'stroke-width': newStyle.line.width + 'px',
@@ -121131,6 +121138,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121131
121138
 
121132
121139
  if(immediateSelect && !evt.shiftKey) {
121133
121140
  dragOptions._clearSubplotSelections = function() {
121141
+ if(!isCartesian) return;
121142
+
121134
121143
  var xRef = xAxis._id;
121135
121144
  var yRef = yAxis._id;
121136
121145
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -121151,6 +121160,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121151
121160
  }
121152
121161
 
121153
121162
  if(selectionErased) {
121163
+ gd._fullLayout._noEmitSelectedAtStart = true;
121164
+
121154
121165
  Registry.call('_guiRelayout', gd, {
121155
121166
  selections: list
121156
121167
  });
@@ -121292,10 +121303,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121292
121303
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
121293
121304
 
121294
121305
  if(isSelectMode) {
121295
- var _res = reselect(gd);
121306
+ var _res = reselect(gd, false);
121296
121307
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
121297
121308
 
121298
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
121309
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
121299
121310
  selectionTesters = _res.selectionTesters;
121300
121311
  eventData = _res.eventData;
121301
121312
 
@@ -121389,9 +121400,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121389
121400
  }
121390
121401
  }
121391
121402
 
121392
- Registry.call('_guiRelayout', gd, {
121393
- selections: subSelections
121394
- });
121403
+ if(subSelections.length < allSelections.length) {
121404
+ gd._fullLayout._noEmitSelectedAtStart = true;
121405
+
121406
+ Registry.call('_guiRelayout', gd, {
121407
+ selections: subSelections
121408
+ });
121409
+ }
121395
121410
  }
121396
121411
  }
121397
121412
  } else {
@@ -121437,8 +121452,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
121437
121452
  dragOptions.doneFnCompleted(selection);
121438
121453
  }
121439
121454
 
121440
- eventData.selections = gd.layout.selections;
121441
- emitSelected(gd, eventData);
121455
+ if(isSelectMode) {
121456
+ emitSelected(gd, eventData);
121457
+ }
121442
121458
  }).catch(Lib.error);
121443
121459
  };
121444
121460
  }
@@ -121516,7 +121532,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
121516
121532
  }
121517
121533
 
121518
121534
  if(sendEvents) {
121519
- eventData.selections = gd.layout.selections;
121520
121535
  emitSelected(gd, eventData);
121521
121536
  }
121522
121537
  }
@@ -121661,15 +121676,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
121661
121676
  }
121662
121677
  }
121663
121678
 
121679
+ function hasActiveShape(gd) {
121680
+ return gd._fullLayout._activeShapeIndex >= 0;
121681
+ }
121682
+
121683
+ function hasActiveSelection(gd) {
121684
+ return gd._fullLayout._activeSelectionIndex >= 0;
121685
+ }
121686
+
121664
121687
  function clearSelectionsCache(dragOptions, immediateSelect) {
121665
121688
  var dragmode = dragOptions.dragmode;
121666
121689
  var plotinfo = dragOptions.plotinfo;
121667
121690
 
121668
121691
  var gd = dragOptions.gd;
121669
- if(gd._fullLayout._activeShapeIndex >= 0) {
121692
+ if(hasActiveShape(gd)) {
121670
121693
  gd._fullLayout._deactivateShape(gd);
121671
121694
  }
121672
- if(gd._fullLayout._activeSelectionIndex >= 0) {
121695
+ if(hasActiveSelection(gd)) {
121673
121696
  gd._fullLayout._deactivateSelection(gd);
121674
121697
  }
121675
121698
 
@@ -121697,11 +121720,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
121697
121720
  var selections;
121698
121721
  if(
121699
121722
  isSelectMode &&
121700
- !dragOptions.subplot // only allow cartesian - no mapbox for now
121723
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
121701
121724
  ) {
121702
121725
  selections = newSelections(outlines, dragOptions);
121703
121726
  }
121704
121727
  if(selections) {
121728
+ gd._fullLayout._noEmitSelectedAtStart = true;
121729
+
121705
121730
  Registry.call('_guiRelayout', gd, {
121706
121731
  selections: selections
121707
121732
  }).then(function() {
@@ -121736,7 +121761,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
121736
121761
 
121737
121762
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
121738
121763
 
121739
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
121764
+ if(
121765
+ hasSubplot({subplot: subplot}) &&
121766
+ (trace.subplot === subplot || trace.geo === subplot)
121767
+ ) {
121740
121768
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
121741
121769
  } else if(trace.type === 'splom') {
121742
121770
  // FIXME: make sure we don't have more than single axis for splom
@@ -122036,7 +122064,7 @@ function _doSelect(selectionTesters, searchTraces) {
122036
122064
  return allSelections;
122037
122065
  }
122038
122066
 
122039
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
122067
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
122040
122068
  var hadSearchTraces = !!searchTraces;
122041
122069
  var plotinfo, xRef, yRef;
122042
122070
  if(dragOptions) {
@@ -122159,15 +122187,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
122159
122187
  updateSelectedState(gd, allSearchTraces, eventData);
122160
122188
 
122161
122189
  var clickmode = fullLayout.clickmode;
122162
- var sendEvents = clickmode.indexOf('event') > -1;
122190
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
122163
122191
 
122164
122192
  if(
122165
122193
  !plotinfo && // get called from plot_api & plots
122166
- fullLayout._reselect
122194
+ mayEmitSelected
122167
122195
  ) {
122168
- if(sendEvents) {
122169
- var activePolygons = getLayoutPolygons(gd, true);
122196
+ var activePolygons = getLayoutPolygons(gd, true);
122170
122197
 
122198
+ if(activePolygons.length) {
122171
122199
  var xref = activePolygons[0].xref;
122172
122200
  var yref = activePolygons[0].yref;
122173
122201
  if(xref && yref) {
@@ -122180,9 +122208,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
122180
122208
 
122181
122209
  fillRangeItems(eventData, poly);
122182
122210
  }
122211
+ }
122183
122212
 
122184
- eventData.selections = gd.layout.selections;
122185
- emitSelected(gd, eventData);
122213
+ if(gd._fullLayout._noEmitSelectedAtStart) {
122214
+ gd._fullLayout._noEmitSelectedAtStart = false;
122215
+ } else {
122216
+ if(sendEvents) emitSelected(gd, eventData);
122186
122217
  }
122187
122218
 
122188
122219
  fullLayout._reselect = false;
@@ -122202,10 +122233,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
122202
122233
 
122203
122234
  if(sendEvents) {
122204
122235
  if(eventData.points.length) {
122205
- eventData.selections = gd.layout.selections;
122206
122236
  emitSelected(gd, eventData);
122207
122237
  } else {
122208
- gd.emit('plotly_deselect', null);
122238
+ emitDeselect(gd);
122209
122239
  }
122210
122240
  }
122211
122241
 
@@ -122497,6 +122527,10 @@ function emitSelecting(gd, eventData) {
122497
122527
  }
122498
122528
 
122499
122529
  function emitSelected(gd, eventData) {
122530
+ if(eventData) {
122531
+ eventData.selections = (gd.layout || {}).selections || [];
122532
+ }
122533
+
122500
122534
  gd.emit('plotly_selected', eventData);
122501
122535
  }
122502
122536
 
@@ -190144,7 +190178,16 @@ plots.redrag = function(gd) {
190144
190178
  };
190145
190179
 
190146
190180
  plots.reselect = function(gd) {
190147
- Registry.getComponentMethod('selections', 'reselect')(gd);
190181
+ var fullLayout = gd._fullLayout;
190182
+
190183
+ var A = (gd.layout || {}).selections;
190184
+ var B = fullLayout._previousSelections;
190185
+ fullLayout._previousSelections = A;
190186
+
190187
+ var mayEmitSelected = fullLayout._reselect ||
190188
+ JSON.stringify(A) !== JSON.stringify(B);
190189
+
190190
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
190148
190191
  };
190149
190192
 
190150
190193
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -227515,6 +227558,7 @@ function subplotUpdateFx(gd, index) {
227515
227558
  var dragMode = fullLayout.dragmode;
227516
227559
  var cursor = fullLayout.dragmode === 'pan' ? 'move' : 'crosshair';
227517
227560
  var bgRect = trace._bgRect;
227561
+ if(!bgRect) return;
227518
227562
 
227519
227563
  if(dragMode === 'pan' || dragMode === 'zoom') return;
227520
227564
 
@@ -249311,7 +249355,7 @@ function getSortFunc(opts, d2c) {
249311
249355
  'use strict';
249312
249356
 
249313
249357
  // package version injected by `npm run preprocess`
249314
- exports.version = '2.13.0';
249358
+ exports.version = '2.13.3';
249315
249359
 
249316
249360
  },{}],1151:[function(_dereq_,module,exports){
249317
249361
  (function (global){(function (){