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 (finance) v2.13.0
2
+ * plotly.js (finance) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -37812,7 +37812,14 @@ var p2r = helpers.p2r;
37812
37812
  var axValue = helpers.axValue;
37813
37813
  var getTransform = helpers.getTransform;
37814
37814
 
37815
+ function hasSubplot(dragOptions) {
37816
+ // N.B. subplot may be falsy e.g zero sankey index!
37817
+ return dragOptions.subplot !== undefined;
37818
+ }
37819
+
37815
37820
  function prepSelect(evt, startX, startY, dragOptions, mode) {
37821
+ var isCartesian = !hasSubplot(dragOptions);
37822
+
37816
37823
  var isFreeMode = freeMode(mode);
37817
37824
  var isRectMode = rectMode(mode);
37818
37825
  var isOpenMode = openMode(mode);
@@ -37826,7 +37833,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37826
37833
  var gd = dragOptions.gd;
37827
37834
  var fullLayout = gd._fullLayout;
37828
37835
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
37829
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
37836
+ isCartesian; // N.B. only cartesian subplots have persistent selection
37830
37837
 
37831
37838
  var zoomLayer = fullLayout._zoomlayer;
37832
37839
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -37874,9 +37881,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37874
37881
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
37875
37882
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
37876
37883
  stroke: newStyle.line.color || (
37877
- dragOptions.subplot !== undefined ?
37878
- '#7f7f7f' : // non-cartesian subplot
37879
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
37884
+ isCartesian ?
37885
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
37886
+ '#7f7f7f' // non-cartesian subplot
37880
37887
  ),
37881
37888
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
37882
37889
  'stroke-width': newStyle.line.width + 'px',
@@ -37907,6 +37914,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37907
37914
 
37908
37915
  if(immediateSelect && !evt.shiftKey) {
37909
37916
  dragOptions._clearSubplotSelections = function() {
37917
+ if(!isCartesian) return;
37918
+
37910
37919
  var xRef = xAxis._id;
37911
37920
  var yRef = yAxis._id;
37912
37921
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -37927,6 +37936,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37927
37936
  }
37928
37937
 
37929
37938
  if(selectionErased) {
37939
+ gd._fullLayout._noEmitSelectedAtStart = true;
37940
+
37930
37941
  Registry.call('_guiRelayout', gd, {
37931
37942
  selections: list
37932
37943
  });
@@ -38068,10 +38079,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
38068
38079
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
38069
38080
 
38070
38081
  if(isSelectMode) {
38071
- var _res = reselect(gd);
38082
+ var _res = reselect(gd, false);
38072
38083
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
38073
38084
 
38074
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
38085
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
38075
38086
  selectionTesters = _res.selectionTesters;
38076
38087
  eventData = _res.eventData;
38077
38088
 
@@ -38165,9 +38176,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
38165
38176
  }
38166
38177
  }
38167
38178
 
38168
- Registry.call('_guiRelayout', gd, {
38169
- selections: subSelections
38170
- });
38179
+ if(subSelections.length < allSelections.length) {
38180
+ gd._fullLayout._noEmitSelectedAtStart = true;
38181
+
38182
+ Registry.call('_guiRelayout', gd, {
38183
+ selections: subSelections
38184
+ });
38185
+ }
38171
38186
  }
38172
38187
  }
38173
38188
  } else {
@@ -38213,8 +38228,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
38213
38228
  dragOptions.doneFnCompleted(selection);
38214
38229
  }
38215
38230
 
38216
- eventData.selections = gd.layout.selections;
38217
- emitSelected(gd, eventData);
38231
+ if(isSelectMode) {
38232
+ emitSelected(gd, eventData);
38233
+ }
38218
38234
  }).catch(Lib.error);
38219
38235
  };
38220
38236
  }
@@ -38292,7 +38308,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
38292
38308
  }
38293
38309
 
38294
38310
  if(sendEvents) {
38295
- eventData.selections = gd.layout.selections;
38296
38311
  emitSelected(gd, eventData);
38297
38312
  }
38298
38313
  }
@@ -38437,15 +38452,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
38437
38452
  }
38438
38453
  }
38439
38454
 
38455
+ function hasActiveShape(gd) {
38456
+ return gd._fullLayout._activeShapeIndex >= 0;
38457
+ }
38458
+
38459
+ function hasActiveSelection(gd) {
38460
+ return gd._fullLayout._activeSelectionIndex >= 0;
38461
+ }
38462
+
38440
38463
  function clearSelectionsCache(dragOptions, immediateSelect) {
38441
38464
  var dragmode = dragOptions.dragmode;
38442
38465
  var plotinfo = dragOptions.plotinfo;
38443
38466
 
38444
38467
  var gd = dragOptions.gd;
38445
- if(gd._fullLayout._activeShapeIndex >= 0) {
38468
+ if(hasActiveShape(gd)) {
38446
38469
  gd._fullLayout._deactivateShape(gd);
38447
38470
  }
38448
- if(gd._fullLayout._activeSelectionIndex >= 0) {
38471
+ if(hasActiveSelection(gd)) {
38449
38472
  gd._fullLayout._deactivateSelection(gd);
38450
38473
  }
38451
38474
 
@@ -38473,11 +38496,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
38473
38496
  var selections;
38474
38497
  if(
38475
38498
  isSelectMode &&
38476
- !dragOptions.subplot // only allow cartesian - no mapbox for now
38499
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
38477
38500
  ) {
38478
38501
  selections = newSelections(outlines, dragOptions);
38479
38502
  }
38480
38503
  if(selections) {
38504
+ gd._fullLayout._noEmitSelectedAtStart = true;
38505
+
38481
38506
  Registry.call('_guiRelayout', gd, {
38482
38507
  selections: selections
38483
38508
  }).then(function() {
@@ -38512,7 +38537,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
38512
38537
 
38513
38538
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
38514
38539
 
38515
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
38540
+ if(
38541
+ hasSubplot({subplot: subplot}) &&
38542
+ (trace.subplot === subplot || trace.geo === subplot)
38543
+ ) {
38516
38544
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
38517
38545
  } else if(trace.type === 'splom') {
38518
38546
  // FIXME: make sure we don't have more than single axis for splom
@@ -38812,7 +38840,7 @@ function _doSelect(selectionTesters, searchTraces) {
38812
38840
  return allSelections;
38813
38841
  }
38814
38842
 
38815
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38843
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
38816
38844
  var hadSearchTraces = !!searchTraces;
38817
38845
  var plotinfo, xRef, yRef;
38818
38846
  if(dragOptions) {
@@ -38935,15 +38963,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38935
38963
  updateSelectedState(gd, allSearchTraces, eventData);
38936
38964
 
38937
38965
  var clickmode = fullLayout.clickmode;
38938
- var sendEvents = clickmode.indexOf('event') > -1;
38966
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
38939
38967
 
38940
38968
  if(
38941
38969
  !plotinfo && // get called from plot_api & plots
38942
- fullLayout._reselect
38970
+ mayEmitSelected
38943
38971
  ) {
38944
- if(sendEvents) {
38945
- var activePolygons = getLayoutPolygons(gd, true);
38972
+ var activePolygons = getLayoutPolygons(gd, true);
38946
38973
 
38974
+ if(activePolygons.length) {
38947
38975
  var xref = activePolygons[0].xref;
38948
38976
  var yref = activePolygons[0].yref;
38949
38977
  if(xref && yref) {
@@ -38956,9 +38984,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38956
38984
 
38957
38985
  fillRangeItems(eventData, poly);
38958
38986
  }
38987
+ }
38959
38988
 
38960
- eventData.selections = gd.layout.selections;
38961
- emitSelected(gd, eventData);
38989
+ if(gd._fullLayout._noEmitSelectedAtStart) {
38990
+ gd._fullLayout._noEmitSelectedAtStart = false;
38991
+ } else {
38992
+ if(sendEvents) emitSelected(gd, eventData);
38962
38993
  }
38963
38994
 
38964
38995
  fullLayout._reselect = false;
@@ -38978,10 +39009,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38978
39009
 
38979
39010
  if(sendEvents) {
38980
39011
  if(eventData.points.length) {
38981
- eventData.selections = gd.layout.selections;
38982
39012
  emitSelected(gd, eventData);
38983
39013
  } else {
38984
- gd.emit('plotly_deselect', null);
39014
+ emitDeselect(gd);
38985
39015
  }
38986
39016
  }
38987
39017
 
@@ -39273,6 +39303,10 @@ function emitSelecting(gd, eventData) {
39273
39303
  }
39274
39304
 
39275
39305
  function emitSelected(gd, eventData) {
39306
+ if(eventData) {
39307
+ eventData.selections = (gd.layout || {}).selections || [];
39308
+ }
39309
+
39276
39310
  gd.emit('plotly_selected', eventData);
39277
39311
  }
39278
39312
 
@@ -75738,7 +75772,16 @@ plots.redrag = function(gd) {
75738
75772
  };
75739
75773
 
75740
75774
  plots.reselect = function(gd) {
75741
- Registry.getComponentMethod('selections', 'reselect')(gd);
75775
+ var fullLayout = gd._fullLayout;
75776
+
75777
+ var A = (gd.layout || {}).selections;
75778
+ var B = fullLayout._previousSelections;
75779
+ fullLayout._previousSelections = A;
75780
+
75781
+ var mayEmitSelected = fullLayout._reselect ||
75782
+ JSON.stringify(A) !== JSON.stringify(B);
75783
+
75784
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
75742
75785
  };
75743
75786
 
75744
75787
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -92669,7 +92712,7 @@ function getSortFunc(opts, d2c) {
92669
92712
  'use strict';
92670
92713
 
92671
92714
  // package version injected by `npm run preprocess`
92672
- exports.version = '2.13.0';
92715
+ exports.version = '2.13.3';
92673
92716
 
92674
92717
  },{}]},{},[12])(12)
92675
92718
  });