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 (cartesian) v2.13.0
2
+ * plotly.js (cartesian) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -45762,7 +45762,14 @@ var p2r = helpers.p2r;
45762
45762
  var axValue = helpers.axValue;
45763
45763
  var getTransform = helpers.getTransform;
45764
45764
 
45765
+ function hasSubplot(dragOptions) {
45766
+ // N.B. subplot may be falsy e.g zero sankey index!
45767
+ return dragOptions.subplot !== undefined;
45768
+ }
45769
+
45765
45770
  function prepSelect(evt, startX, startY, dragOptions, mode) {
45771
+ var isCartesian = !hasSubplot(dragOptions);
45772
+
45766
45773
  var isFreeMode = freeMode(mode);
45767
45774
  var isRectMode = rectMode(mode);
45768
45775
  var isOpenMode = openMode(mode);
@@ -45776,7 +45783,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45776
45783
  var gd = dragOptions.gd;
45777
45784
  var fullLayout = gd._fullLayout;
45778
45785
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
45779
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
45786
+ isCartesian; // N.B. only cartesian subplots have persistent selection
45780
45787
 
45781
45788
  var zoomLayer = fullLayout._zoomlayer;
45782
45789
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -45824,9 +45831,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45824
45831
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
45825
45832
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
45826
45833
  stroke: newStyle.line.color || (
45827
- dragOptions.subplot !== undefined ?
45828
- '#7f7f7f' : // non-cartesian subplot
45829
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
45834
+ isCartesian ?
45835
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
45836
+ '#7f7f7f' // non-cartesian subplot
45830
45837
  ),
45831
45838
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
45832
45839
  'stroke-width': newStyle.line.width + 'px',
@@ -45857,6 +45864,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45857
45864
 
45858
45865
  if(immediateSelect && !evt.shiftKey) {
45859
45866
  dragOptions._clearSubplotSelections = function() {
45867
+ if(!isCartesian) return;
45868
+
45860
45869
  var xRef = xAxis._id;
45861
45870
  var yRef = yAxis._id;
45862
45871
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -45877,6 +45886,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45877
45886
  }
45878
45887
 
45879
45888
  if(selectionErased) {
45889
+ gd._fullLayout._noEmitSelectedAtStart = true;
45890
+
45880
45891
  Registry.call('_guiRelayout', gd, {
45881
45892
  selections: list
45882
45893
  });
@@ -46018,10 +46029,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46018
46029
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
46019
46030
 
46020
46031
  if(isSelectMode) {
46021
- var _res = reselect(gd);
46032
+ var _res = reselect(gd, false);
46022
46033
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
46023
46034
 
46024
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
46035
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
46025
46036
  selectionTesters = _res.selectionTesters;
46026
46037
  eventData = _res.eventData;
46027
46038
 
@@ -46115,9 +46126,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46115
46126
  }
46116
46127
  }
46117
46128
 
46118
- Registry.call('_guiRelayout', gd, {
46119
- selections: subSelections
46120
- });
46129
+ if(subSelections.length < allSelections.length) {
46130
+ gd._fullLayout._noEmitSelectedAtStart = true;
46131
+
46132
+ Registry.call('_guiRelayout', gd, {
46133
+ selections: subSelections
46134
+ });
46135
+ }
46121
46136
  }
46122
46137
  }
46123
46138
  } else {
@@ -46163,8 +46178,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46163
46178
  dragOptions.doneFnCompleted(selection);
46164
46179
  }
46165
46180
 
46166
- eventData.selections = gd.layout.selections;
46167
- emitSelected(gd, eventData);
46181
+ if(isSelectMode) {
46182
+ emitSelected(gd, eventData);
46183
+ }
46168
46184
  }).catch(Lib.error);
46169
46185
  };
46170
46186
  }
@@ -46242,7 +46258,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
46242
46258
  }
46243
46259
 
46244
46260
  if(sendEvents) {
46245
- eventData.selections = gd.layout.selections;
46246
46261
  emitSelected(gd, eventData);
46247
46262
  }
46248
46263
  }
@@ -46387,15 +46402,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
46387
46402
  }
46388
46403
  }
46389
46404
 
46405
+ function hasActiveShape(gd) {
46406
+ return gd._fullLayout._activeShapeIndex >= 0;
46407
+ }
46408
+
46409
+ function hasActiveSelection(gd) {
46410
+ return gd._fullLayout._activeSelectionIndex >= 0;
46411
+ }
46412
+
46390
46413
  function clearSelectionsCache(dragOptions, immediateSelect) {
46391
46414
  var dragmode = dragOptions.dragmode;
46392
46415
  var plotinfo = dragOptions.plotinfo;
46393
46416
 
46394
46417
  var gd = dragOptions.gd;
46395
- if(gd._fullLayout._activeShapeIndex >= 0) {
46418
+ if(hasActiveShape(gd)) {
46396
46419
  gd._fullLayout._deactivateShape(gd);
46397
46420
  }
46398
- if(gd._fullLayout._activeSelectionIndex >= 0) {
46421
+ if(hasActiveSelection(gd)) {
46399
46422
  gd._fullLayout._deactivateSelection(gd);
46400
46423
  }
46401
46424
 
@@ -46423,11 +46446,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
46423
46446
  var selections;
46424
46447
  if(
46425
46448
  isSelectMode &&
46426
- !dragOptions.subplot // only allow cartesian - no mapbox for now
46449
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
46427
46450
  ) {
46428
46451
  selections = newSelections(outlines, dragOptions);
46429
46452
  }
46430
46453
  if(selections) {
46454
+ gd._fullLayout._noEmitSelectedAtStart = true;
46455
+
46431
46456
  Registry.call('_guiRelayout', gd, {
46432
46457
  selections: selections
46433
46458
  }).then(function() {
@@ -46462,7 +46487,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
46462
46487
 
46463
46488
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
46464
46489
 
46465
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
46490
+ if(
46491
+ hasSubplot({subplot: subplot}) &&
46492
+ (trace.subplot === subplot || trace.geo === subplot)
46493
+ ) {
46466
46494
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
46467
46495
  } else if(trace.type === 'splom') {
46468
46496
  // FIXME: make sure we don't have more than single axis for splom
@@ -46762,7 +46790,7 @@ function _doSelect(selectionTesters, searchTraces) {
46762
46790
  return allSelections;
46763
46791
  }
46764
46792
 
46765
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46793
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
46766
46794
  var hadSearchTraces = !!searchTraces;
46767
46795
  var plotinfo, xRef, yRef;
46768
46796
  if(dragOptions) {
@@ -46885,15 +46913,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46885
46913
  updateSelectedState(gd, allSearchTraces, eventData);
46886
46914
 
46887
46915
  var clickmode = fullLayout.clickmode;
46888
- var sendEvents = clickmode.indexOf('event') > -1;
46916
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
46889
46917
 
46890
46918
  if(
46891
46919
  !plotinfo && // get called from plot_api & plots
46892
- fullLayout._reselect
46920
+ mayEmitSelected
46893
46921
  ) {
46894
- if(sendEvents) {
46895
- var activePolygons = getLayoutPolygons(gd, true);
46922
+ var activePolygons = getLayoutPolygons(gd, true);
46896
46923
 
46924
+ if(activePolygons.length) {
46897
46925
  var xref = activePolygons[0].xref;
46898
46926
  var yref = activePolygons[0].yref;
46899
46927
  if(xref && yref) {
@@ -46906,9 +46934,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46906
46934
 
46907
46935
  fillRangeItems(eventData, poly);
46908
46936
  }
46937
+ }
46909
46938
 
46910
- eventData.selections = gd.layout.selections;
46911
- emitSelected(gd, eventData);
46939
+ if(gd._fullLayout._noEmitSelectedAtStart) {
46940
+ gd._fullLayout._noEmitSelectedAtStart = false;
46941
+ } else {
46942
+ if(sendEvents) emitSelected(gd, eventData);
46912
46943
  }
46913
46944
 
46914
46945
  fullLayout._reselect = false;
@@ -46928,10 +46959,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46928
46959
 
46929
46960
  if(sendEvents) {
46930
46961
  if(eventData.points.length) {
46931
- eventData.selections = gd.layout.selections;
46932
46962
  emitSelected(gd, eventData);
46933
46963
  } else {
46934
- gd.emit('plotly_deselect', null);
46964
+ emitDeselect(gd);
46935
46965
  }
46936
46966
  }
46937
46967
 
@@ -47223,6 +47253,10 @@ function emitSelecting(gd, eventData) {
47223
47253
  }
47224
47254
 
47225
47255
  function emitSelected(gd, eventData) {
47256
+ if(eventData) {
47257
+ eventData.selections = (gd.layout || {}).selections || [];
47258
+ }
47259
+
47226
47260
  gd.emit('plotly_selected', eventData);
47227
47261
  }
47228
47262
 
@@ -83674,7 +83708,16 @@ plots.redrag = function(gd) {
83674
83708
  };
83675
83709
 
83676
83710
  plots.reselect = function(gd) {
83677
- Registry.getComponentMethod('selections', 'reselect')(gd);
83711
+ var fullLayout = gd._fullLayout;
83712
+
83713
+ var A = (gd.layout || {}).selections;
83714
+ var B = fullLayout._previousSelections;
83715
+ fullLayout._previousSelections = A;
83716
+
83717
+ var mayEmitSelected = fullLayout._reselect ||
83718
+ JSON.stringify(A) !== JSON.stringify(B);
83719
+
83720
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
83678
83721
  };
83679
83722
 
83680
83723
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -104891,7 +104934,7 @@ function getSortFunc(opts, d2c) {
104891
104934
  'use strict';
104892
104935
 
104893
104936
  // package version injected by `npm run preprocess`
104894
- exports.version = '2.13.0';
104937
+ exports.version = '2.13.3';
104895
104938
 
104896
104939
  },{}]},{},[15])(15)
104897
104940
  });