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 (cartesian) v2.13.1
2
+ * plotly.js (cartesian) v2.14.0
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -45305,6 +45305,10 @@ function draw(gd) {
45305
45305
  }
45306
45306
  }
45307
45307
 
45308
+ function couldHaveActiveSelection(gd) {
45309
+ return gd._context.editSelection;
45310
+ }
45311
+
45308
45312
  function drawOne(gd, index) {
45309
45313
  // remove the existing selection if there is one.
45310
45314
  // because indices can change, we need to look in all selection layers
@@ -45341,7 +45345,7 @@ function drawOne(gd, index) {
45341
45345
  lineDash = 'solid';
45342
45346
  }
45343
45347
 
45344
- var isActiveSelection =
45348
+ var isActiveSelection = couldHaveActiveSelection(gd) &&
45345
45349
  gd._fullLayout._activeSelectionIndex === index;
45346
45350
 
45347
45351
  if(isActiveSelection) {
@@ -45408,6 +45412,8 @@ function setClipPath(selectionPath, gd, selectionOptions) {
45408
45412
 
45409
45413
 
45410
45414
  function activateSelection(gd, path) {
45415
+ if(!couldHaveActiveSelection(gd)) return;
45416
+
45411
45417
  var element = path.node();
45412
45418
  var id = +element.getAttribute('data-index');
45413
45419
  if(id >= 0) {
@@ -45424,6 +45430,8 @@ function activateSelection(gd, path) {
45424
45430
  }
45425
45431
 
45426
45432
  function activateLastSelection(gd) {
45433
+ if(!couldHaveActiveSelection(gd)) return;
45434
+
45427
45435
  var id = gd._fullLayout.selections.length - 1;
45428
45436
  gd._fullLayout._activeSelectionIndex = id;
45429
45437
  gd._fullLayout._deactivateSelection = deactivateSelection;
@@ -45431,6 +45439,8 @@ function activateLastSelection(gd) {
45431
45439
  }
45432
45440
 
45433
45441
  function deactivateSelection(gd) {
45442
+ if(!couldHaveActiveSelection(gd)) return;
45443
+
45434
45444
  var id = gd._fullLayout._activeSelectionIndex;
45435
45445
  if(id >= 0) {
45436
45446
  clearOutlineControllers(gd);
@@ -45762,7 +45772,14 @@ var p2r = helpers.p2r;
45762
45772
  var axValue = helpers.axValue;
45763
45773
  var getTransform = helpers.getTransform;
45764
45774
 
45775
+ function hasSubplot(dragOptions) {
45776
+ // N.B. subplot may be falsy e.g zero sankey index!
45777
+ return dragOptions.subplot !== undefined;
45778
+ }
45779
+
45765
45780
  function prepSelect(evt, startX, startY, dragOptions, mode) {
45781
+ var isCartesian = !hasSubplot(dragOptions);
45782
+
45766
45783
  var isFreeMode = freeMode(mode);
45767
45784
  var isRectMode = rectMode(mode);
45768
45785
  var isOpenMode = openMode(mode);
@@ -45776,7 +45793,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45776
45793
  var gd = dragOptions.gd;
45777
45794
  var fullLayout = gd._fullLayout;
45778
45795
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
45779
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
45796
+ isCartesian; // N.B. only cartesian subplots have persistent selection
45780
45797
 
45781
45798
  var zoomLayer = fullLayout._zoomlayer;
45782
45799
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -45824,9 +45841,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45824
45841
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
45825
45842
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
45826
45843
  stroke: newStyle.line.color || (
45827
- dragOptions.subplot !== undefined ?
45828
- '#7f7f7f' : // non-cartesian subplot
45829
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
45844
+ isCartesian ?
45845
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
45846
+ '#7f7f7f' // non-cartesian subplot
45830
45847
  ),
45831
45848
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
45832
45849
  'stroke-width': newStyle.line.width + 'px',
@@ -45857,6 +45874,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45857
45874
 
45858
45875
  if(immediateSelect && !evt.shiftKey) {
45859
45876
  dragOptions._clearSubplotSelections = function() {
45877
+ if(!isCartesian) return;
45878
+
45860
45879
  var xRef = xAxis._id;
45861
45880
  var yRef = yAxis._id;
45862
45881
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -45877,6 +45896,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
45877
45896
  }
45878
45897
 
45879
45898
  if(selectionErased) {
45899
+ gd._fullLayout._noEmitSelectedAtStart = true;
45900
+
45880
45901
  Registry.call('_guiRelayout', gd, {
45881
45902
  selections: list
45882
45903
  });
@@ -46018,10 +46039,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46018
46039
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
46019
46040
 
46020
46041
  if(isSelectMode) {
46021
- var _res = reselect(gd);
46042
+ var _res = reselect(gd, false);
46022
46043
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
46023
46044
 
46024
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
46045
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
46025
46046
  selectionTesters = _res.selectionTesters;
46026
46047
  eventData = _res.eventData;
46027
46048
 
@@ -46115,9 +46136,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46115
46136
  }
46116
46137
  }
46117
46138
 
46118
- Registry.call('_guiRelayout', gd, {
46119
- selections: subSelections
46120
- });
46139
+ if(subSelections.length < allSelections.length) {
46140
+ gd._fullLayout._noEmitSelectedAtStart = true;
46141
+
46142
+ Registry.call('_guiRelayout', gd, {
46143
+ selections: subSelections
46144
+ });
46145
+ }
46121
46146
  }
46122
46147
  }
46123
46148
  } else {
@@ -46163,7 +46188,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
46163
46188
  dragOptions.doneFnCompleted(selection);
46164
46189
  }
46165
46190
 
46166
- emitSelected(gd, eventData);
46191
+ if(isSelectMode) {
46192
+ emitSelected(gd, eventData);
46193
+ }
46167
46194
  }).catch(Lib.error);
46168
46195
  };
46169
46196
  }
@@ -46385,15 +46412,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
46385
46412
  }
46386
46413
  }
46387
46414
 
46415
+ function hasActiveShape(gd) {
46416
+ return gd._fullLayout._activeShapeIndex >= 0;
46417
+ }
46418
+
46419
+ function hasActiveSelection(gd) {
46420
+ return gd._fullLayout._activeSelectionIndex >= 0;
46421
+ }
46422
+
46388
46423
  function clearSelectionsCache(dragOptions, immediateSelect) {
46389
46424
  var dragmode = dragOptions.dragmode;
46390
46425
  var plotinfo = dragOptions.plotinfo;
46391
46426
 
46392
46427
  var gd = dragOptions.gd;
46393
- if(gd._fullLayout._activeShapeIndex >= 0) {
46428
+ if(hasActiveShape(gd)) {
46394
46429
  gd._fullLayout._deactivateShape(gd);
46395
46430
  }
46396
- if(gd._fullLayout._activeSelectionIndex >= 0) {
46431
+ if(hasActiveSelection(gd)) {
46397
46432
  gd._fullLayout._deactivateSelection(gd);
46398
46433
  }
46399
46434
 
@@ -46421,11 +46456,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
46421
46456
  var selections;
46422
46457
  if(
46423
46458
  isSelectMode &&
46424
- !dragOptions.subplot // only allow cartesian - no mapbox for now
46459
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
46425
46460
  ) {
46426
46461
  selections = newSelections(outlines, dragOptions);
46427
46462
  }
46428
46463
  if(selections) {
46464
+ gd._fullLayout._noEmitSelectedAtStart = true;
46465
+
46429
46466
  Registry.call('_guiRelayout', gd, {
46430
46467
  selections: selections
46431
46468
  }).then(function() {
@@ -46460,7 +46497,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
46460
46497
 
46461
46498
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
46462
46499
 
46463
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
46500
+ if(
46501
+ hasSubplot({subplot: subplot}) &&
46502
+ (trace.subplot === subplot || trace.geo === subplot)
46503
+ ) {
46464
46504
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
46465
46505
  } else if(trace.type === 'splom') {
46466
46506
  // FIXME: make sure we don't have more than single axis for splom
@@ -46760,7 +46800,7 @@ function _doSelect(selectionTesters, searchTraces) {
46760
46800
  return allSelections;
46761
46801
  }
46762
46802
 
46763
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46803
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
46764
46804
  var hadSearchTraces = !!searchTraces;
46765
46805
  var plotinfo, xRef, yRef;
46766
46806
  if(dragOptions) {
@@ -46883,15 +46923,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46883
46923
  updateSelectedState(gd, allSearchTraces, eventData);
46884
46924
 
46885
46925
  var clickmode = fullLayout.clickmode;
46886
- var sendEvents = clickmode.indexOf('event') > -1;
46926
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
46887
46927
 
46888
46928
  if(
46889
46929
  !plotinfo && // get called from plot_api & plots
46890
- fullLayout._reselect
46930
+ mayEmitSelected
46891
46931
  ) {
46892
- if(sendEvents) {
46893
- var activePolygons = getLayoutPolygons(gd, true);
46932
+ var activePolygons = getLayoutPolygons(gd, true);
46894
46933
 
46934
+ if(activePolygons.length) {
46895
46935
  var xref = activePolygons[0].xref;
46896
46936
  var yref = activePolygons[0].yref;
46897
46937
  if(xref && yref) {
@@ -46904,8 +46944,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46904
46944
 
46905
46945
  fillRangeItems(eventData, poly);
46906
46946
  }
46947
+ }
46907
46948
 
46908
- emitSelected(gd, eventData);
46949
+ if(gd._fullLayout._noEmitSelectedAtStart) {
46950
+ gd._fullLayout._noEmitSelectedAtStart = false;
46951
+ } else {
46952
+ if(sendEvents) emitSelected(gd, eventData);
46909
46953
  }
46910
46954
 
46911
46955
  fullLayout._reselect = false;
@@ -46927,7 +46971,7 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
46927
46971
  if(eventData.points.length) {
46928
46972
  emitSelected(gd, eventData);
46929
46973
  } else {
46930
- gd.emit('plotly_deselect', null);
46974
+ emitDeselect(gd);
46931
46975
  }
46932
46976
  }
46933
46977
 
@@ -47215,13 +47259,10 @@ function getFillRangeItems(dragOptions) {
47215
47259
  }
47216
47260
 
47217
47261
  function emitSelecting(gd, eventData) {
47218
- if(drawMode(gd._fullLayout.dragmode)) return;
47219
47262
  gd.emit('plotly_selecting', eventData);
47220
47263
  }
47221
47264
 
47222
47265
  function emitSelected(gd, eventData) {
47223
- if(drawMode(gd._fullLayout.dragmode)) return;
47224
-
47225
47266
  if(eventData) {
47226
47267
  eventData.selections = (gd.layout || {}).selections || [];
47227
47268
  }
@@ -47230,7 +47271,6 @@ function emitSelected(gd, eventData) {
47230
47271
  }
47231
47272
 
47232
47273
  function emitDeselect(gd) {
47233
- if(drawMode(gd._fullLayout.dragmode)) return;
47234
47274
  gd.emit('plotly_deselect', null);
47235
47275
  }
47236
47276
 
@@ -64675,6 +64715,11 @@ var configAttributes = {
64675
64715
  }
64676
64716
  },
64677
64717
 
64718
+ editSelection: {
64719
+ valType: 'boolean',
64720
+ dflt: true,
64721
+ },
64722
+
64678
64723
  autosizable: {
64679
64724
  valType: 'boolean',
64680
64725
  dflt: false,
@@ -83678,7 +83723,16 @@ plots.redrag = function(gd) {
83678
83723
  };
83679
83724
 
83680
83725
  plots.reselect = function(gd) {
83681
- Registry.getComponentMethod('selections', 'reselect')(gd);
83726
+ var fullLayout = gd._fullLayout;
83727
+
83728
+ var A = (gd.layout || {}).selections;
83729
+ var B = fullLayout._previousSelections;
83730
+ fullLayout._previousSelections = A;
83731
+
83732
+ var mayEmitSelected = fullLayout._reselect ||
83733
+ JSON.stringify(A) !== JSON.stringify(B);
83734
+
83735
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
83682
83736
  };
83683
83737
 
83684
83738
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -104895,7 +104949,7 @@ function getSortFunc(opts, d2c) {
104895
104949
  'use strict';
104896
104950
 
104897
104951
  // package version injected by `npm run preprocess`
104898
- exports.version = '2.13.1';
104952
+ exports.version = '2.14.0';
104899
104953
 
104900
104954
  },{}]},{},[15])(15)
104901
104955
  });