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 (gl3d) v2.13.0
2
+ * plotly.js (gl3d) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -37282,7 +37282,14 @@ var p2r = helpers.p2r;
37282
37282
  var axValue = helpers.axValue;
37283
37283
  var getTransform = helpers.getTransform;
37284
37284
 
37285
+ function hasSubplot(dragOptions) {
37286
+ // N.B. subplot may be falsy e.g zero sankey index!
37287
+ return dragOptions.subplot !== undefined;
37288
+ }
37289
+
37285
37290
  function prepSelect(evt, startX, startY, dragOptions, mode) {
37291
+ var isCartesian = !hasSubplot(dragOptions);
37292
+
37286
37293
  var isFreeMode = freeMode(mode);
37287
37294
  var isRectMode = rectMode(mode);
37288
37295
  var isOpenMode = openMode(mode);
@@ -37296,7 +37303,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37296
37303
  var gd = dragOptions.gd;
37297
37304
  var fullLayout = gd._fullLayout;
37298
37305
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
37299
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
37306
+ isCartesian; // N.B. only cartesian subplots have persistent selection
37300
37307
 
37301
37308
  var zoomLayer = fullLayout._zoomlayer;
37302
37309
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -37344,9 +37351,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37344
37351
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
37345
37352
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
37346
37353
  stroke: newStyle.line.color || (
37347
- dragOptions.subplot !== undefined ?
37348
- '#7f7f7f' : // non-cartesian subplot
37349
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
37354
+ isCartesian ?
37355
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
37356
+ '#7f7f7f' // non-cartesian subplot
37350
37357
  ),
37351
37358
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
37352
37359
  'stroke-width': newStyle.line.width + 'px',
@@ -37377,6 +37384,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37377
37384
 
37378
37385
  if(immediateSelect && !evt.shiftKey) {
37379
37386
  dragOptions._clearSubplotSelections = function() {
37387
+ if(!isCartesian) return;
37388
+
37380
37389
  var xRef = xAxis._id;
37381
37390
  var yRef = yAxis._id;
37382
37391
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -37397,6 +37406,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37397
37406
  }
37398
37407
 
37399
37408
  if(selectionErased) {
37409
+ gd._fullLayout._noEmitSelectedAtStart = true;
37410
+
37400
37411
  Registry.call('_guiRelayout', gd, {
37401
37412
  selections: list
37402
37413
  });
@@ -37538,10 +37549,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37538
37549
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
37539
37550
 
37540
37551
  if(isSelectMode) {
37541
- var _res = reselect(gd);
37552
+ var _res = reselect(gd, false);
37542
37553
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
37543
37554
 
37544
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
37555
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
37545
37556
  selectionTesters = _res.selectionTesters;
37546
37557
  eventData = _res.eventData;
37547
37558
 
@@ -37635,9 +37646,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37635
37646
  }
37636
37647
  }
37637
37648
 
37638
- Registry.call('_guiRelayout', gd, {
37639
- selections: subSelections
37640
- });
37649
+ if(subSelections.length < allSelections.length) {
37650
+ gd._fullLayout._noEmitSelectedAtStart = true;
37651
+
37652
+ Registry.call('_guiRelayout', gd, {
37653
+ selections: subSelections
37654
+ });
37655
+ }
37641
37656
  }
37642
37657
  }
37643
37658
  } else {
@@ -37683,8 +37698,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37683
37698
  dragOptions.doneFnCompleted(selection);
37684
37699
  }
37685
37700
 
37686
- eventData.selections = gd.layout.selections;
37687
- emitSelected(gd, eventData);
37701
+ if(isSelectMode) {
37702
+ emitSelected(gd, eventData);
37703
+ }
37688
37704
  }).catch(Lib.error);
37689
37705
  };
37690
37706
  }
@@ -37762,7 +37778,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
37762
37778
  }
37763
37779
 
37764
37780
  if(sendEvents) {
37765
- eventData.selections = gd.layout.selections;
37766
37781
  emitSelected(gd, eventData);
37767
37782
  }
37768
37783
  }
@@ -37907,15 +37922,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
37907
37922
  }
37908
37923
  }
37909
37924
 
37925
+ function hasActiveShape(gd) {
37926
+ return gd._fullLayout._activeShapeIndex >= 0;
37927
+ }
37928
+
37929
+ function hasActiveSelection(gd) {
37930
+ return gd._fullLayout._activeSelectionIndex >= 0;
37931
+ }
37932
+
37910
37933
  function clearSelectionsCache(dragOptions, immediateSelect) {
37911
37934
  var dragmode = dragOptions.dragmode;
37912
37935
  var plotinfo = dragOptions.plotinfo;
37913
37936
 
37914
37937
  var gd = dragOptions.gd;
37915
- if(gd._fullLayout._activeShapeIndex >= 0) {
37938
+ if(hasActiveShape(gd)) {
37916
37939
  gd._fullLayout._deactivateShape(gd);
37917
37940
  }
37918
- if(gd._fullLayout._activeSelectionIndex >= 0) {
37941
+ if(hasActiveSelection(gd)) {
37919
37942
  gd._fullLayout._deactivateSelection(gd);
37920
37943
  }
37921
37944
 
@@ -37943,11 +37966,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
37943
37966
  var selections;
37944
37967
  if(
37945
37968
  isSelectMode &&
37946
- !dragOptions.subplot // only allow cartesian - no mapbox for now
37969
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
37947
37970
  ) {
37948
37971
  selections = newSelections(outlines, dragOptions);
37949
37972
  }
37950
37973
  if(selections) {
37974
+ gd._fullLayout._noEmitSelectedAtStart = true;
37975
+
37951
37976
  Registry.call('_guiRelayout', gd, {
37952
37977
  selections: selections
37953
37978
  }).then(function() {
@@ -37982,7 +38007,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
37982
38007
 
37983
38008
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
37984
38009
 
37985
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
38010
+ if(
38011
+ hasSubplot({subplot: subplot}) &&
38012
+ (trace.subplot === subplot || trace.geo === subplot)
38013
+ ) {
37986
38014
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
37987
38015
  } else if(trace.type === 'splom') {
37988
38016
  // FIXME: make sure we don't have more than single axis for splom
@@ -38282,7 +38310,7 @@ function _doSelect(selectionTesters, searchTraces) {
38282
38310
  return allSelections;
38283
38311
  }
38284
38312
 
38285
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38313
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
38286
38314
  var hadSearchTraces = !!searchTraces;
38287
38315
  var plotinfo, xRef, yRef;
38288
38316
  if(dragOptions) {
@@ -38405,15 +38433,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38405
38433
  updateSelectedState(gd, allSearchTraces, eventData);
38406
38434
 
38407
38435
  var clickmode = fullLayout.clickmode;
38408
- var sendEvents = clickmode.indexOf('event') > -1;
38436
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
38409
38437
 
38410
38438
  if(
38411
38439
  !plotinfo && // get called from plot_api & plots
38412
- fullLayout._reselect
38440
+ mayEmitSelected
38413
38441
  ) {
38414
- if(sendEvents) {
38415
- var activePolygons = getLayoutPolygons(gd, true);
38442
+ var activePolygons = getLayoutPolygons(gd, true);
38416
38443
 
38444
+ if(activePolygons.length) {
38417
38445
  var xref = activePolygons[0].xref;
38418
38446
  var yref = activePolygons[0].yref;
38419
38447
  if(xref && yref) {
@@ -38426,9 +38454,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38426
38454
 
38427
38455
  fillRangeItems(eventData, poly);
38428
38456
  }
38457
+ }
38429
38458
 
38430
- eventData.selections = gd.layout.selections;
38431
- emitSelected(gd, eventData);
38459
+ if(gd._fullLayout._noEmitSelectedAtStart) {
38460
+ gd._fullLayout._noEmitSelectedAtStart = false;
38461
+ } else {
38462
+ if(sendEvents) emitSelected(gd, eventData);
38432
38463
  }
38433
38464
 
38434
38465
  fullLayout._reselect = false;
@@ -38448,10 +38479,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38448
38479
 
38449
38480
  if(sendEvents) {
38450
38481
  if(eventData.points.length) {
38451
- eventData.selections = gd.layout.selections;
38452
38482
  emitSelected(gd, eventData);
38453
38483
  } else {
38454
- gd.emit('plotly_deselect', null);
38484
+ emitDeselect(gd);
38455
38485
  }
38456
38486
  }
38457
38487
 
@@ -38743,6 +38773,10 @@ function emitSelecting(gd, eventData) {
38743
38773
  }
38744
38774
 
38745
38775
  function emitSelected(gd, eventData) {
38776
+ if(eventData) {
38777
+ eventData.selections = (gd.layout || {}).selections || [];
38778
+ }
38779
+
38746
38780
  gd.emit('plotly_selected', eventData);
38747
38781
  }
38748
38782
 
@@ -77416,7 +77450,16 @@ plots.redrag = function(gd) {
77416
77450
  };
77417
77451
 
77418
77452
  plots.reselect = function(gd) {
77419
- Registry.getComponentMethod('selections', 'reselect')(gd);
77453
+ var fullLayout = gd._fullLayout;
77454
+
77455
+ var A = (gd.layout || {}).selections;
77456
+ var B = fullLayout._previousSelections;
77457
+ fullLayout._previousSelections = A;
77458
+
77459
+ var mayEmitSelected = fullLayout._reselect ||
77460
+ JSON.stringify(A) !== JSON.stringify(B);
77461
+
77462
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
77420
77463
  };
77421
77464
 
77422
77465
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -88321,7 +88364,7 @@ function getSortFunc(opts, d2c) {
88321
88364
  'use strict';
88322
88365
 
88323
88366
  // package version injected by `npm run preprocess`
88324
- exports.version = '2.13.0';
88367
+ exports.version = '2.13.3';
88325
88368
 
88326
88369
  },{}],444:[function(_dereq_,module,exports){
88327
88370
  (function (global){(function (){