plotly.js 2.13.1 → 2.14.0

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.1
2
+ * plotly.js (gl3d) v2.14.0
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -36825,6 +36825,10 @@ function draw(gd) {
36825
36825
  }
36826
36826
  }
36827
36827
 
36828
+ function couldHaveActiveSelection(gd) {
36829
+ return gd._context.editSelection;
36830
+ }
36831
+
36828
36832
  function drawOne(gd, index) {
36829
36833
  // remove the existing selection if there is one.
36830
36834
  // because indices can change, we need to look in all selection layers
@@ -36861,7 +36865,7 @@ function drawOne(gd, index) {
36861
36865
  lineDash = 'solid';
36862
36866
  }
36863
36867
 
36864
- var isActiveSelection =
36868
+ var isActiveSelection = couldHaveActiveSelection(gd) &&
36865
36869
  gd._fullLayout._activeSelectionIndex === index;
36866
36870
 
36867
36871
  if(isActiveSelection) {
@@ -36928,6 +36932,8 @@ function setClipPath(selectionPath, gd, selectionOptions) {
36928
36932
 
36929
36933
 
36930
36934
  function activateSelection(gd, path) {
36935
+ if(!couldHaveActiveSelection(gd)) return;
36936
+
36931
36937
  var element = path.node();
36932
36938
  var id = +element.getAttribute('data-index');
36933
36939
  if(id >= 0) {
@@ -36944,6 +36950,8 @@ function activateSelection(gd, path) {
36944
36950
  }
36945
36951
 
36946
36952
  function activateLastSelection(gd) {
36953
+ if(!couldHaveActiveSelection(gd)) return;
36954
+
36947
36955
  var id = gd._fullLayout.selections.length - 1;
36948
36956
  gd._fullLayout._activeSelectionIndex = id;
36949
36957
  gd._fullLayout._deactivateSelection = deactivateSelection;
@@ -36951,6 +36959,8 @@ function activateLastSelection(gd) {
36951
36959
  }
36952
36960
 
36953
36961
  function deactivateSelection(gd) {
36962
+ if(!couldHaveActiveSelection(gd)) return;
36963
+
36954
36964
  var id = gd._fullLayout._activeSelectionIndex;
36955
36965
  if(id >= 0) {
36956
36966
  clearOutlineControllers(gd);
@@ -37282,7 +37292,14 @@ var p2r = helpers.p2r;
37282
37292
  var axValue = helpers.axValue;
37283
37293
  var getTransform = helpers.getTransform;
37284
37294
 
37295
+ function hasSubplot(dragOptions) {
37296
+ // N.B. subplot may be falsy e.g zero sankey index!
37297
+ return dragOptions.subplot !== undefined;
37298
+ }
37299
+
37285
37300
  function prepSelect(evt, startX, startY, dragOptions, mode) {
37301
+ var isCartesian = !hasSubplot(dragOptions);
37302
+
37286
37303
  var isFreeMode = freeMode(mode);
37287
37304
  var isRectMode = rectMode(mode);
37288
37305
  var isOpenMode = openMode(mode);
@@ -37296,7 +37313,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37296
37313
  var gd = dragOptions.gd;
37297
37314
  var fullLayout = gd._fullLayout;
37298
37315
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
37299
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
37316
+ isCartesian; // N.B. only cartesian subplots have persistent selection
37300
37317
 
37301
37318
  var zoomLayer = fullLayout._zoomlayer;
37302
37319
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -37344,9 +37361,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37344
37361
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
37345
37362
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
37346
37363
  stroke: newStyle.line.color || (
37347
- dragOptions.subplot !== undefined ?
37348
- '#7f7f7f' : // non-cartesian subplot
37349
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
37364
+ isCartesian ?
37365
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
37366
+ '#7f7f7f' // non-cartesian subplot
37350
37367
  ),
37351
37368
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
37352
37369
  'stroke-width': newStyle.line.width + 'px',
@@ -37377,6 +37394,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37377
37394
 
37378
37395
  if(immediateSelect && !evt.shiftKey) {
37379
37396
  dragOptions._clearSubplotSelections = function() {
37397
+ if(!isCartesian) return;
37398
+
37380
37399
  var xRef = xAxis._id;
37381
37400
  var yRef = yAxis._id;
37382
37401
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -37397,6 +37416,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37397
37416
  }
37398
37417
 
37399
37418
  if(selectionErased) {
37419
+ gd._fullLayout._noEmitSelectedAtStart = true;
37420
+
37400
37421
  Registry.call('_guiRelayout', gd, {
37401
37422
  selections: list
37402
37423
  });
@@ -37538,10 +37559,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37538
37559
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
37539
37560
 
37540
37561
  if(isSelectMode) {
37541
- var _res = reselect(gd);
37562
+ var _res = reselect(gd, false);
37542
37563
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
37543
37564
 
37544
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
37565
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
37545
37566
  selectionTesters = _res.selectionTesters;
37546
37567
  eventData = _res.eventData;
37547
37568
 
@@ -37635,9 +37656,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37635
37656
  }
37636
37657
  }
37637
37658
 
37638
- Registry.call('_guiRelayout', gd, {
37639
- selections: subSelections
37640
- });
37659
+ if(subSelections.length < allSelections.length) {
37660
+ gd._fullLayout._noEmitSelectedAtStart = true;
37661
+
37662
+ Registry.call('_guiRelayout', gd, {
37663
+ selections: subSelections
37664
+ });
37665
+ }
37641
37666
  }
37642
37667
  }
37643
37668
  } else {
@@ -37683,7 +37708,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
37683
37708
  dragOptions.doneFnCompleted(selection);
37684
37709
  }
37685
37710
 
37686
- emitSelected(gd, eventData);
37711
+ if(isSelectMode) {
37712
+ emitSelected(gd, eventData);
37713
+ }
37687
37714
  }).catch(Lib.error);
37688
37715
  };
37689
37716
  }
@@ -37905,15 +37932,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
37905
37932
  }
37906
37933
  }
37907
37934
 
37935
+ function hasActiveShape(gd) {
37936
+ return gd._fullLayout._activeShapeIndex >= 0;
37937
+ }
37938
+
37939
+ function hasActiveSelection(gd) {
37940
+ return gd._fullLayout._activeSelectionIndex >= 0;
37941
+ }
37942
+
37908
37943
  function clearSelectionsCache(dragOptions, immediateSelect) {
37909
37944
  var dragmode = dragOptions.dragmode;
37910
37945
  var plotinfo = dragOptions.plotinfo;
37911
37946
 
37912
37947
  var gd = dragOptions.gd;
37913
- if(gd._fullLayout._activeShapeIndex >= 0) {
37948
+ if(hasActiveShape(gd)) {
37914
37949
  gd._fullLayout._deactivateShape(gd);
37915
37950
  }
37916
- if(gd._fullLayout._activeSelectionIndex >= 0) {
37951
+ if(hasActiveSelection(gd)) {
37917
37952
  gd._fullLayout._deactivateSelection(gd);
37918
37953
  }
37919
37954
 
@@ -37941,11 +37976,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
37941
37976
  var selections;
37942
37977
  if(
37943
37978
  isSelectMode &&
37944
- !dragOptions.subplot // only allow cartesian - no mapbox for now
37979
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
37945
37980
  ) {
37946
37981
  selections = newSelections(outlines, dragOptions);
37947
37982
  }
37948
37983
  if(selections) {
37984
+ gd._fullLayout._noEmitSelectedAtStart = true;
37985
+
37949
37986
  Registry.call('_guiRelayout', gd, {
37950
37987
  selections: selections
37951
37988
  }).then(function() {
@@ -37980,7 +38017,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
37980
38017
 
37981
38018
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
37982
38019
 
37983
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
38020
+ if(
38021
+ hasSubplot({subplot: subplot}) &&
38022
+ (trace.subplot === subplot || trace.geo === subplot)
38023
+ ) {
37984
38024
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
37985
38025
  } else if(trace.type === 'splom') {
37986
38026
  // FIXME: make sure we don't have more than single axis for splom
@@ -38280,7 +38320,7 @@ function _doSelect(selectionTesters, searchTraces) {
38280
38320
  return allSelections;
38281
38321
  }
38282
38322
 
38283
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38323
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
38284
38324
  var hadSearchTraces = !!searchTraces;
38285
38325
  var plotinfo, xRef, yRef;
38286
38326
  if(dragOptions) {
@@ -38403,15 +38443,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38403
38443
  updateSelectedState(gd, allSearchTraces, eventData);
38404
38444
 
38405
38445
  var clickmode = fullLayout.clickmode;
38406
- var sendEvents = clickmode.indexOf('event') > -1;
38446
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
38407
38447
 
38408
38448
  if(
38409
38449
  !plotinfo && // get called from plot_api & plots
38410
- fullLayout._reselect
38450
+ mayEmitSelected
38411
38451
  ) {
38412
- if(sendEvents) {
38413
- var activePolygons = getLayoutPolygons(gd, true);
38452
+ var activePolygons = getLayoutPolygons(gd, true);
38414
38453
 
38454
+ if(activePolygons.length) {
38415
38455
  var xref = activePolygons[0].xref;
38416
38456
  var yref = activePolygons[0].yref;
38417
38457
  if(xref && yref) {
@@ -38424,8 +38464,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38424
38464
 
38425
38465
  fillRangeItems(eventData, poly);
38426
38466
  }
38467
+ }
38427
38468
 
38428
- emitSelected(gd, eventData);
38469
+ if(gd._fullLayout._noEmitSelectedAtStart) {
38470
+ gd._fullLayout._noEmitSelectedAtStart = false;
38471
+ } else {
38472
+ if(sendEvents) emitSelected(gd, eventData);
38429
38473
  }
38430
38474
 
38431
38475
  fullLayout._reselect = false;
@@ -38447,7 +38491,7 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
38447
38491
  if(eventData.points.length) {
38448
38492
  emitSelected(gd, eventData);
38449
38493
  } else {
38450
- gd.emit('plotly_deselect', null);
38494
+ emitDeselect(gd);
38451
38495
  }
38452
38496
  }
38453
38497
 
@@ -38735,13 +38779,10 @@ function getFillRangeItems(dragOptions) {
38735
38779
  }
38736
38780
 
38737
38781
  function emitSelecting(gd, eventData) {
38738
- if(drawMode(gd._fullLayout.dragmode)) return;
38739
38782
  gd.emit('plotly_selecting', eventData);
38740
38783
  }
38741
38784
 
38742
38785
  function emitSelected(gd, eventData) {
38743
- if(drawMode(gd._fullLayout.dragmode)) return;
38744
-
38745
38786
  if(eventData) {
38746
38787
  eventData.selections = (gd.layout || {}).selections || [];
38747
38788
  }
@@ -38750,7 +38791,6 @@ function emitSelected(gd, eventData) {
38750
38791
  }
38751
38792
 
38752
38793
  function emitDeselect(gd) {
38753
- if(drawMode(gd._fullLayout.dragmode)) return;
38754
38794
  gd.emit('plotly_deselect', null);
38755
38795
  }
38756
38796
 
@@ -56381,6 +56421,11 @@ var configAttributes = {
56381
56421
  }
56382
56422
  },
56383
56423
 
56424
+ editSelection: {
56425
+ valType: 'boolean',
56426
+ dflt: true,
56427
+ },
56428
+
56384
56429
  autosizable: {
56385
56430
  valType: 'boolean',
56386
56431
  dflt: false,
@@ -77420,7 +77465,16 @@ plots.redrag = function(gd) {
77420
77465
  };
77421
77466
 
77422
77467
  plots.reselect = function(gd) {
77423
- Registry.getComponentMethod('selections', 'reselect')(gd);
77468
+ var fullLayout = gd._fullLayout;
77469
+
77470
+ var A = (gd.layout || {}).selections;
77471
+ var B = fullLayout._previousSelections;
77472
+ fullLayout._previousSelections = A;
77473
+
77474
+ var mayEmitSelected = fullLayout._reselect ||
77475
+ JSON.stringify(A) !== JSON.stringify(B);
77476
+
77477
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
77424
77478
  };
77425
77479
 
77426
77480
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -88325,7 +88379,7 @@ function getSortFunc(opts, d2c) {
88325
88379
  'use strict';
88326
88380
 
88327
88381
  // package version injected by `npm run preprocess`
88328
- exports.version = '2.13.1';
88382
+ exports.version = '2.14.0';
88329
88383
 
88330
88384
  },{}],444:[function(_dereq_,module,exports){
88331
88385
  (function (global){(function (){