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 v2.13.1
2
+ * plotly.js v2.14.0
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -68,7 +68,7 @@ exports.topojson = saneTopojson;
68
68
  'use strict';
69
69
 
70
70
  // package version injected by `npm run preprocess`
71
- exports.version = '2.13.1';
71
+ exports.version = '2.14.0';
72
72
 
73
73
  },{}]},{},[16])(16)
74
74
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * plotly.js (geo) v2.13.1
2
+ * plotly.js (geo) v2.14.0
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -49888,6 +49888,10 @@ function draw(gd) {
49888
49888
  }
49889
49889
  }
49890
49890
 
49891
+ function couldHaveActiveSelection(gd) {
49892
+ return gd._context.editSelection;
49893
+ }
49894
+
49891
49895
  function drawOne(gd, index) {
49892
49896
  // remove the existing selection if there is one.
49893
49897
  // because indices can change, we need to look in all selection layers
@@ -49924,7 +49928,7 @@ function drawOne(gd, index) {
49924
49928
  lineDash = 'solid';
49925
49929
  }
49926
49930
 
49927
- var isActiveSelection =
49931
+ var isActiveSelection = couldHaveActiveSelection(gd) &&
49928
49932
  gd._fullLayout._activeSelectionIndex === index;
49929
49933
 
49930
49934
  if(isActiveSelection) {
@@ -49991,6 +49995,8 @@ function setClipPath(selectionPath, gd, selectionOptions) {
49991
49995
 
49992
49996
 
49993
49997
  function activateSelection(gd, path) {
49998
+ if(!couldHaveActiveSelection(gd)) return;
49999
+
49994
50000
  var element = path.node();
49995
50001
  var id = +element.getAttribute('data-index');
49996
50002
  if(id >= 0) {
@@ -50007,6 +50013,8 @@ function activateSelection(gd, path) {
50007
50013
  }
50008
50014
 
50009
50015
  function activateLastSelection(gd) {
50016
+ if(!couldHaveActiveSelection(gd)) return;
50017
+
50010
50018
  var id = gd._fullLayout.selections.length - 1;
50011
50019
  gd._fullLayout._activeSelectionIndex = id;
50012
50020
  gd._fullLayout._deactivateSelection = deactivateSelection;
@@ -50014,6 +50022,8 @@ function activateLastSelection(gd) {
50014
50022
  }
50015
50023
 
50016
50024
  function deactivateSelection(gd) {
50025
+ if(!couldHaveActiveSelection(gd)) return;
50026
+
50017
50027
  var id = gd._fullLayout._activeSelectionIndex;
50018
50028
  if(id >= 0) {
50019
50029
  clearOutlineControllers(gd);
@@ -50345,7 +50355,14 @@ var p2r = helpers.p2r;
50345
50355
  var axValue = helpers.axValue;
50346
50356
  var getTransform = helpers.getTransform;
50347
50357
 
50358
+ function hasSubplot(dragOptions) {
50359
+ // N.B. subplot may be falsy e.g zero sankey index!
50360
+ return dragOptions.subplot !== undefined;
50361
+ }
50362
+
50348
50363
  function prepSelect(evt, startX, startY, dragOptions, mode) {
50364
+ var isCartesian = !hasSubplot(dragOptions);
50365
+
50349
50366
  var isFreeMode = freeMode(mode);
50350
50367
  var isRectMode = rectMode(mode);
50351
50368
  var isOpenMode = openMode(mode);
@@ -50359,7 +50376,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50359
50376
  var gd = dragOptions.gd;
50360
50377
  var fullLayout = gd._fullLayout;
50361
50378
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
50362
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
50379
+ isCartesian; // N.B. only cartesian subplots have persistent selection
50363
50380
 
50364
50381
  var zoomLayer = fullLayout._zoomlayer;
50365
50382
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -50407,9 +50424,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50407
50424
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
50408
50425
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
50409
50426
  stroke: newStyle.line.color || (
50410
- dragOptions.subplot !== undefined ?
50411
- '#7f7f7f' : // non-cartesian subplot
50412
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
50427
+ isCartesian ?
50428
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
50429
+ '#7f7f7f' // non-cartesian subplot
50413
50430
  ),
50414
50431
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
50415
50432
  'stroke-width': newStyle.line.width + 'px',
@@ -50440,6 +50457,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50440
50457
 
50441
50458
  if(immediateSelect && !evt.shiftKey) {
50442
50459
  dragOptions._clearSubplotSelections = function() {
50460
+ if(!isCartesian) return;
50461
+
50443
50462
  var xRef = xAxis._id;
50444
50463
  var yRef = yAxis._id;
50445
50464
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -50460,6 +50479,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50460
50479
  }
50461
50480
 
50462
50481
  if(selectionErased) {
50482
+ gd._fullLayout._noEmitSelectedAtStart = true;
50483
+
50463
50484
  Registry.call('_guiRelayout', gd, {
50464
50485
  selections: list
50465
50486
  });
@@ -50601,10 +50622,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50601
50622
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
50602
50623
 
50603
50624
  if(isSelectMode) {
50604
- var _res = reselect(gd);
50625
+ var _res = reselect(gd, false);
50605
50626
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
50606
50627
 
50607
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
50628
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
50608
50629
  selectionTesters = _res.selectionTesters;
50609
50630
  eventData = _res.eventData;
50610
50631
 
@@ -50698,9 +50719,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50698
50719
  }
50699
50720
  }
50700
50721
 
50701
- Registry.call('_guiRelayout', gd, {
50702
- selections: subSelections
50703
- });
50722
+ if(subSelections.length < allSelections.length) {
50723
+ gd._fullLayout._noEmitSelectedAtStart = true;
50724
+
50725
+ Registry.call('_guiRelayout', gd, {
50726
+ selections: subSelections
50727
+ });
50728
+ }
50704
50729
  }
50705
50730
  }
50706
50731
  } else {
@@ -50746,7 +50771,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50746
50771
  dragOptions.doneFnCompleted(selection);
50747
50772
  }
50748
50773
 
50749
- emitSelected(gd, eventData);
50774
+ if(isSelectMode) {
50775
+ emitSelected(gd, eventData);
50776
+ }
50750
50777
  }).catch(Lib.error);
50751
50778
  };
50752
50779
  }
@@ -50968,15 +50995,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
50968
50995
  }
50969
50996
  }
50970
50997
 
50998
+ function hasActiveShape(gd) {
50999
+ return gd._fullLayout._activeShapeIndex >= 0;
51000
+ }
51001
+
51002
+ function hasActiveSelection(gd) {
51003
+ return gd._fullLayout._activeSelectionIndex >= 0;
51004
+ }
51005
+
50971
51006
  function clearSelectionsCache(dragOptions, immediateSelect) {
50972
51007
  var dragmode = dragOptions.dragmode;
50973
51008
  var plotinfo = dragOptions.plotinfo;
50974
51009
 
50975
51010
  var gd = dragOptions.gd;
50976
- if(gd._fullLayout._activeShapeIndex >= 0) {
51011
+ if(hasActiveShape(gd)) {
50977
51012
  gd._fullLayout._deactivateShape(gd);
50978
51013
  }
50979
- if(gd._fullLayout._activeSelectionIndex >= 0) {
51014
+ if(hasActiveSelection(gd)) {
50980
51015
  gd._fullLayout._deactivateSelection(gd);
50981
51016
  }
50982
51017
 
@@ -51004,11 +51039,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
51004
51039
  var selections;
51005
51040
  if(
51006
51041
  isSelectMode &&
51007
- !dragOptions.subplot // only allow cartesian - no mapbox for now
51042
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
51008
51043
  ) {
51009
51044
  selections = newSelections(outlines, dragOptions);
51010
51045
  }
51011
51046
  if(selections) {
51047
+ gd._fullLayout._noEmitSelectedAtStart = true;
51048
+
51012
51049
  Registry.call('_guiRelayout', gd, {
51013
51050
  selections: selections
51014
51051
  }).then(function() {
@@ -51043,7 +51080,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
51043
51080
 
51044
51081
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
51045
51082
 
51046
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
51083
+ if(
51084
+ hasSubplot({subplot: subplot}) &&
51085
+ (trace.subplot === subplot || trace.geo === subplot)
51086
+ ) {
51047
51087
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
51048
51088
  } else if(trace.type === 'splom') {
51049
51089
  // FIXME: make sure we don't have more than single axis for splom
@@ -51343,7 +51383,7 @@ function _doSelect(selectionTesters, searchTraces) {
51343
51383
  return allSelections;
51344
51384
  }
51345
51385
 
51346
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51386
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
51347
51387
  var hadSearchTraces = !!searchTraces;
51348
51388
  var plotinfo, xRef, yRef;
51349
51389
  if(dragOptions) {
@@ -51466,15 +51506,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51466
51506
  updateSelectedState(gd, allSearchTraces, eventData);
51467
51507
 
51468
51508
  var clickmode = fullLayout.clickmode;
51469
- var sendEvents = clickmode.indexOf('event') > -1;
51509
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
51470
51510
 
51471
51511
  if(
51472
51512
  !plotinfo && // get called from plot_api & plots
51473
- fullLayout._reselect
51513
+ mayEmitSelected
51474
51514
  ) {
51475
- if(sendEvents) {
51476
- var activePolygons = getLayoutPolygons(gd, true);
51515
+ var activePolygons = getLayoutPolygons(gd, true);
51477
51516
 
51517
+ if(activePolygons.length) {
51478
51518
  var xref = activePolygons[0].xref;
51479
51519
  var yref = activePolygons[0].yref;
51480
51520
  if(xref && yref) {
@@ -51487,8 +51527,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51487
51527
 
51488
51528
  fillRangeItems(eventData, poly);
51489
51529
  }
51530
+ }
51490
51531
 
51491
- emitSelected(gd, eventData);
51532
+ if(gd._fullLayout._noEmitSelectedAtStart) {
51533
+ gd._fullLayout._noEmitSelectedAtStart = false;
51534
+ } else {
51535
+ if(sendEvents) emitSelected(gd, eventData);
51492
51536
  }
51493
51537
 
51494
51538
  fullLayout._reselect = false;
@@ -51510,7 +51554,7 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51510
51554
  if(eventData.points.length) {
51511
51555
  emitSelected(gd, eventData);
51512
51556
  } else {
51513
- gd.emit('plotly_deselect', null);
51557
+ emitDeselect(gd);
51514
51558
  }
51515
51559
  }
51516
51560
 
@@ -51798,13 +51842,10 @@ function getFillRangeItems(dragOptions) {
51798
51842
  }
51799
51843
 
51800
51844
  function emitSelecting(gd, eventData) {
51801
- if(drawMode(gd._fullLayout.dragmode)) return;
51802
51845
  gd.emit('plotly_selecting', eventData);
51803
51846
  }
51804
51847
 
51805
51848
  function emitSelected(gd, eventData) {
51806
- if(drawMode(gd._fullLayout.dragmode)) return;
51807
-
51808
51849
  if(eventData) {
51809
51850
  eventData.selections = (gd.layout || {}).selections || [];
51810
51851
  }
@@ -51813,7 +51854,6 @@ function emitSelected(gd, eventData) {
51813
51854
  }
51814
51855
 
51815
51856
  function emitDeselect(gd) {
51816
- if(drawMode(gd._fullLayout.dragmode)) return;
51817
51857
  gd.emit('plotly_deselect', null);
51818
51858
  }
51819
51859
 
@@ -69769,6 +69809,11 @@ var configAttributes = {
69769
69809
  }
69770
69810
  },
69771
69811
 
69812
+ editSelection: {
69813
+ valType: 'boolean',
69814
+ dflt: true,
69815
+ },
69816
+
69772
69817
  autosizable: {
69773
69818
  valType: 'boolean',
69774
69819
  dflt: false,
@@ -90840,7 +90885,16 @@ plots.redrag = function(gd) {
90840
90885
  };
90841
90886
 
90842
90887
  plots.reselect = function(gd) {
90843
- Registry.getComponentMethod('selections', 'reselect')(gd);
90888
+ var fullLayout = gd._fullLayout;
90889
+
90890
+ var A = (gd.layout || {}).selections;
90891
+ var B = fullLayout._previousSelections;
90892
+ fullLayout._previousSelections = A;
90893
+
90894
+ var mayEmitSelected = fullLayout._reselect ||
90895
+ JSON.stringify(A) !== JSON.stringify(B);
90896
+
90897
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
90844
90898
  };
90845
90899
 
90846
90900
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -97416,7 +97470,7 @@ function getSortFunc(opts, d2c) {
97416
97470
  'use strict';
97417
97471
 
97418
97472
  // package version injected by `npm run preprocess`
97419
- exports.version = '2.13.1';
97473
+ exports.version = '2.14.0';
97420
97474
 
97421
97475
  },{}]},{},[8])(8)
97422
97476
  });