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 (gl2d) v2.13.0
2
+ * plotly.js (gl2d) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -50060,7 +50060,14 @@ var p2r = helpers.p2r;
50060
50060
  var axValue = helpers.axValue;
50061
50061
  var getTransform = helpers.getTransform;
50062
50062
 
50063
+ function hasSubplot(dragOptions) {
50064
+ // N.B. subplot may be falsy e.g zero sankey index!
50065
+ return dragOptions.subplot !== undefined;
50066
+ }
50067
+
50063
50068
  function prepSelect(evt, startX, startY, dragOptions, mode) {
50069
+ var isCartesian = !hasSubplot(dragOptions);
50070
+
50064
50071
  var isFreeMode = freeMode(mode);
50065
50072
  var isRectMode = rectMode(mode);
50066
50073
  var isOpenMode = openMode(mode);
@@ -50074,7 +50081,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50074
50081
  var gd = dragOptions.gd;
50075
50082
  var fullLayout = gd._fullLayout;
50076
50083
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
50077
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
50084
+ isCartesian; // N.B. only cartesian subplots have persistent selection
50078
50085
 
50079
50086
  var zoomLayer = fullLayout._zoomlayer;
50080
50087
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -50122,9 +50129,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50122
50129
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
50123
50130
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
50124
50131
  stroke: newStyle.line.color || (
50125
- dragOptions.subplot !== undefined ?
50126
- '#7f7f7f' : // non-cartesian subplot
50127
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
50132
+ isCartesian ?
50133
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
50134
+ '#7f7f7f' // non-cartesian subplot
50128
50135
  ),
50129
50136
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
50130
50137
  'stroke-width': newStyle.line.width + 'px',
@@ -50155,6 +50162,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50155
50162
 
50156
50163
  if(immediateSelect && !evt.shiftKey) {
50157
50164
  dragOptions._clearSubplotSelections = function() {
50165
+ if(!isCartesian) return;
50166
+
50158
50167
  var xRef = xAxis._id;
50159
50168
  var yRef = yAxis._id;
50160
50169
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -50175,6 +50184,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50175
50184
  }
50176
50185
 
50177
50186
  if(selectionErased) {
50187
+ gd._fullLayout._noEmitSelectedAtStart = true;
50188
+
50178
50189
  Registry.call('_guiRelayout', gd, {
50179
50190
  selections: list
50180
50191
  });
@@ -50316,10 +50327,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50316
50327
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
50317
50328
 
50318
50329
  if(isSelectMode) {
50319
- var _res = reselect(gd);
50330
+ var _res = reselect(gd, false);
50320
50331
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
50321
50332
 
50322
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
50333
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
50323
50334
  selectionTesters = _res.selectionTesters;
50324
50335
  eventData = _res.eventData;
50325
50336
 
@@ -50413,9 +50424,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50413
50424
  }
50414
50425
  }
50415
50426
 
50416
- Registry.call('_guiRelayout', gd, {
50417
- selections: subSelections
50418
- });
50427
+ if(subSelections.length < allSelections.length) {
50428
+ gd._fullLayout._noEmitSelectedAtStart = true;
50429
+
50430
+ Registry.call('_guiRelayout', gd, {
50431
+ selections: subSelections
50432
+ });
50433
+ }
50419
50434
  }
50420
50435
  }
50421
50436
  } else {
@@ -50461,8 +50476,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50461
50476
  dragOptions.doneFnCompleted(selection);
50462
50477
  }
50463
50478
 
50464
- eventData.selections = gd.layout.selections;
50465
- emitSelected(gd, eventData);
50479
+ if(isSelectMode) {
50480
+ emitSelected(gd, eventData);
50481
+ }
50466
50482
  }).catch(Lib.error);
50467
50483
  };
50468
50484
  }
@@ -50540,7 +50556,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
50540
50556
  }
50541
50557
 
50542
50558
  if(sendEvents) {
50543
- eventData.selections = gd.layout.selections;
50544
50559
  emitSelected(gd, eventData);
50545
50560
  }
50546
50561
  }
@@ -50685,15 +50700,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
50685
50700
  }
50686
50701
  }
50687
50702
 
50703
+ function hasActiveShape(gd) {
50704
+ return gd._fullLayout._activeShapeIndex >= 0;
50705
+ }
50706
+
50707
+ function hasActiveSelection(gd) {
50708
+ return gd._fullLayout._activeSelectionIndex >= 0;
50709
+ }
50710
+
50688
50711
  function clearSelectionsCache(dragOptions, immediateSelect) {
50689
50712
  var dragmode = dragOptions.dragmode;
50690
50713
  var plotinfo = dragOptions.plotinfo;
50691
50714
 
50692
50715
  var gd = dragOptions.gd;
50693
- if(gd._fullLayout._activeShapeIndex >= 0) {
50716
+ if(hasActiveShape(gd)) {
50694
50717
  gd._fullLayout._deactivateShape(gd);
50695
50718
  }
50696
- if(gd._fullLayout._activeSelectionIndex >= 0) {
50719
+ if(hasActiveSelection(gd)) {
50697
50720
  gd._fullLayout._deactivateSelection(gd);
50698
50721
  }
50699
50722
 
@@ -50721,11 +50744,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
50721
50744
  var selections;
50722
50745
  if(
50723
50746
  isSelectMode &&
50724
- !dragOptions.subplot // only allow cartesian - no mapbox for now
50747
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
50725
50748
  ) {
50726
50749
  selections = newSelections(outlines, dragOptions);
50727
50750
  }
50728
50751
  if(selections) {
50752
+ gd._fullLayout._noEmitSelectedAtStart = true;
50753
+
50729
50754
  Registry.call('_guiRelayout', gd, {
50730
50755
  selections: selections
50731
50756
  }).then(function() {
@@ -50760,7 +50785,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
50760
50785
 
50761
50786
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
50762
50787
 
50763
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
50788
+ if(
50789
+ hasSubplot({subplot: subplot}) &&
50790
+ (trace.subplot === subplot || trace.geo === subplot)
50791
+ ) {
50764
50792
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
50765
50793
  } else if(trace.type === 'splom') {
50766
50794
  // FIXME: make sure we don't have more than single axis for splom
@@ -51060,7 +51088,7 @@ function _doSelect(selectionTesters, searchTraces) {
51060
51088
  return allSelections;
51061
51089
  }
51062
51090
 
51063
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51091
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
51064
51092
  var hadSearchTraces = !!searchTraces;
51065
51093
  var plotinfo, xRef, yRef;
51066
51094
  if(dragOptions) {
@@ -51183,15 +51211,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51183
51211
  updateSelectedState(gd, allSearchTraces, eventData);
51184
51212
 
51185
51213
  var clickmode = fullLayout.clickmode;
51186
- var sendEvents = clickmode.indexOf('event') > -1;
51214
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
51187
51215
 
51188
51216
  if(
51189
51217
  !plotinfo && // get called from plot_api & plots
51190
- fullLayout._reselect
51218
+ mayEmitSelected
51191
51219
  ) {
51192
- if(sendEvents) {
51193
- var activePolygons = getLayoutPolygons(gd, true);
51220
+ var activePolygons = getLayoutPolygons(gd, true);
51194
51221
 
51222
+ if(activePolygons.length) {
51195
51223
  var xref = activePolygons[0].xref;
51196
51224
  var yref = activePolygons[0].yref;
51197
51225
  if(xref && yref) {
@@ -51204,9 +51232,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51204
51232
 
51205
51233
  fillRangeItems(eventData, poly);
51206
51234
  }
51235
+ }
51207
51236
 
51208
- eventData.selections = gd.layout.selections;
51209
- emitSelected(gd, eventData);
51237
+ if(gd._fullLayout._noEmitSelectedAtStart) {
51238
+ gd._fullLayout._noEmitSelectedAtStart = false;
51239
+ } else {
51240
+ if(sendEvents) emitSelected(gd, eventData);
51210
51241
  }
51211
51242
 
51212
51243
  fullLayout._reselect = false;
@@ -51226,10 +51257,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51226
51257
 
51227
51258
  if(sendEvents) {
51228
51259
  if(eventData.points.length) {
51229
- eventData.selections = gd.layout.selections;
51230
51260
  emitSelected(gd, eventData);
51231
51261
  } else {
51232
- gd.emit('plotly_deselect', null);
51262
+ emitDeselect(gd);
51233
51263
  }
51234
51264
  }
51235
51265
 
@@ -51521,6 +51551,10 @@ function emitSelecting(gd, eventData) {
51521
51551
  }
51522
51552
 
51523
51553
  function emitSelected(gd, eventData) {
51554
+ if(eventData) {
51555
+ eventData.selections = (gd.layout || {}).selections || [];
51556
+ }
51557
+
51524
51558
  gd.emit('plotly_selected', eventData);
51525
51559
  }
51526
51560
 
@@ -89604,7 +89638,16 @@ plots.redrag = function(gd) {
89604
89638
  };
89605
89639
 
89606
89640
  plots.reselect = function(gd) {
89607
- Registry.getComponentMethod('selections', 'reselect')(gd);
89641
+ var fullLayout = gd._fullLayout;
89642
+
89643
+ var A = (gd.layout || {}).selections;
89644
+ var B = fullLayout._previousSelections;
89645
+ fullLayout._previousSelections = A;
89646
+
89647
+ var mayEmitSelected = fullLayout._reselect ||
89648
+ JSON.stringify(A) !== JSON.stringify(B);
89649
+
89650
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
89608
89651
  };
89609
89652
 
89610
89653
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -103010,7 +103053,7 @@ function getSortFunc(opts, d2c) {
103010
103053
  'use strict';
103011
103054
 
103012
103055
  // package version injected by `npm run preprocess`
103013
- exports.version = '2.13.0';
103056
+ exports.version = '2.13.3';
103014
103057
 
103015
103058
  },{}],600:[function(_dereq_,module,exports){
103016
103059
  (function (global){(function (){