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 v2.13.0
2
+ * plotly.js v2.13.3
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.0';
71
+ exports.version = '2.13.3';
72
72
 
73
73
  },{}]},{},[16])(16)
74
74
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * plotly.js (geo) v2.13.0
2
+ * plotly.js (geo) v2.13.3
3
3
  * Copyright 2012-2022, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -50345,7 +50345,14 @@ var p2r = helpers.p2r;
50345
50345
  var axValue = helpers.axValue;
50346
50346
  var getTransform = helpers.getTransform;
50347
50347
 
50348
+ function hasSubplot(dragOptions) {
50349
+ // N.B. subplot may be falsy e.g zero sankey index!
50350
+ return dragOptions.subplot !== undefined;
50351
+ }
50352
+
50348
50353
  function prepSelect(evt, startX, startY, dragOptions, mode) {
50354
+ var isCartesian = !hasSubplot(dragOptions);
50355
+
50349
50356
  var isFreeMode = freeMode(mode);
50350
50357
  var isRectMode = rectMode(mode);
50351
50358
  var isOpenMode = openMode(mode);
@@ -50359,7 +50366,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50359
50366
  var gd = dragOptions.gd;
50360
50367
  var fullLayout = gd._fullLayout;
50361
50368
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
50362
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
50369
+ isCartesian; // N.B. only cartesian subplots have persistent selection
50363
50370
 
50364
50371
  var zoomLayer = fullLayout._zoomlayer;
50365
50372
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -50407,9 +50414,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50407
50414
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
50408
50415
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
50409
50416
  stroke: newStyle.line.color || (
50410
- dragOptions.subplot !== undefined ?
50411
- '#7f7f7f' : // non-cartesian subplot
50412
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
50417
+ isCartesian ?
50418
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
50419
+ '#7f7f7f' // non-cartesian subplot
50413
50420
  ),
50414
50421
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
50415
50422
  'stroke-width': newStyle.line.width + 'px',
@@ -50440,6 +50447,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50440
50447
 
50441
50448
  if(immediateSelect && !evt.shiftKey) {
50442
50449
  dragOptions._clearSubplotSelections = function() {
50450
+ if(!isCartesian) return;
50451
+
50443
50452
  var xRef = xAxis._id;
50444
50453
  var yRef = yAxis._id;
50445
50454
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -50460,6 +50469,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50460
50469
  }
50461
50470
 
50462
50471
  if(selectionErased) {
50472
+ gd._fullLayout._noEmitSelectedAtStart = true;
50473
+
50463
50474
  Registry.call('_guiRelayout', gd, {
50464
50475
  selections: list
50465
50476
  });
@@ -50601,10 +50612,10 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50601
50612
  displayOutlines(convertPoly(mergedPolygons, isOpenMode), outlines, dragOptions);
50602
50613
 
50603
50614
  if(isSelectMode) {
50604
- var _res = reselect(gd);
50615
+ var _res = reselect(gd, false);
50605
50616
  var extraPoints = _res.eventData ? _res.eventData.points.slice() : [];
50606
50617
 
50607
- _res = reselect(gd, selectionTesters, searchTraces, dragOptions);
50618
+ _res = reselect(gd, false, selectionTesters, searchTraces, dragOptions);
50608
50619
  selectionTesters = _res.selectionTesters;
50609
50620
  eventData = _res.eventData;
50610
50621
 
@@ -50698,9 +50709,13 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50698
50709
  }
50699
50710
  }
50700
50711
 
50701
- Registry.call('_guiRelayout', gd, {
50702
- selections: subSelections
50703
- });
50712
+ if(subSelections.length < allSelections.length) {
50713
+ gd._fullLayout._noEmitSelectedAtStart = true;
50714
+
50715
+ Registry.call('_guiRelayout', gd, {
50716
+ selections: subSelections
50717
+ });
50718
+ }
50704
50719
  }
50705
50720
  }
50706
50721
  } else {
@@ -50746,8 +50761,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
50746
50761
  dragOptions.doneFnCompleted(selection);
50747
50762
  }
50748
50763
 
50749
- eventData.selections = gd.layout.selections;
50750
- emitSelected(gd, eventData);
50764
+ if(isSelectMode) {
50765
+ emitSelected(gd, eventData);
50766
+ }
50751
50767
  }).catch(Lib.error);
50752
50768
  };
50753
50769
  }
@@ -50825,7 +50841,6 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli
50825
50841
  }
50826
50842
 
50827
50843
  if(sendEvents) {
50828
- eventData.selections = gd.layout.selections;
50829
50844
  emitSelected(gd, eventData);
50830
50845
  }
50831
50846
  }
@@ -50970,15 +50985,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
50970
50985
  }
50971
50986
  }
50972
50987
 
50988
+ function hasActiveShape(gd) {
50989
+ return gd._fullLayout._activeShapeIndex >= 0;
50990
+ }
50991
+
50992
+ function hasActiveSelection(gd) {
50993
+ return gd._fullLayout._activeSelectionIndex >= 0;
50994
+ }
50995
+
50973
50996
  function clearSelectionsCache(dragOptions, immediateSelect) {
50974
50997
  var dragmode = dragOptions.dragmode;
50975
50998
  var plotinfo = dragOptions.plotinfo;
50976
50999
 
50977
51000
  var gd = dragOptions.gd;
50978
- if(gd._fullLayout._activeShapeIndex >= 0) {
51001
+ if(hasActiveShape(gd)) {
50979
51002
  gd._fullLayout._deactivateShape(gd);
50980
51003
  }
50981
- if(gd._fullLayout._activeSelectionIndex >= 0) {
51004
+ if(hasActiveSelection(gd)) {
50982
51005
  gd._fullLayout._deactivateSelection(gd);
50983
51006
  }
50984
51007
 
@@ -51006,11 +51029,13 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
51006
51029
  var selections;
51007
51030
  if(
51008
51031
  isSelectMode &&
51009
- !dragOptions.subplot // only allow cartesian - no mapbox for now
51032
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
51010
51033
  ) {
51011
51034
  selections = newSelections(outlines, dragOptions);
51012
51035
  }
51013
51036
  if(selections) {
51037
+ gd._fullLayout._noEmitSelectedAtStart = true;
51038
+
51014
51039
  Registry.call('_guiRelayout', gd, {
51015
51040
  selections: selections
51016
51041
  }).then(function() {
@@ -51045,7 +51070,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
51045
51070
 
51046
51071
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
51047
51072
 
51048
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
51073
+ if(
51074
+ hasSubplot({subplot: subplot}) &&
51075
+ (trace.subplot === subplot || trace.geo === subplot)
51076
+ ) {
51049
51077
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
51050
51078
  } else if(trace.type === 'splom') {
51051
51079
  // FIXME: make sure we don't have more than single axis for splom
@@ -51345,7 +51373,7 @@ function _doSelect(selectionTesters, searchTraces) {
51345
51373
  return allSelections;
51346
51374
  }
51347
51375
 
51348
- function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51376
+ function reselect(gd, mayEmitSelected, selectionTesters, searchTraces, dragOptions) {
51349
51377
  var hadSearchTraces = !!searchTraces;
51350
51378
  var plotinfo, xRef, yRef;
51351
51379
  if(dragOptions) {
@@ -51468,15 +51496,15 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51468
51496
  updateSelectedState(gd, allSearchTraces, eventData);
51469
51497
 
51470
51498
  var clickmode = fullLayout.clickmode;
51471
- var sendEvents = clickmode.indexOf('event') > -1;
51499
+ var sendEvents = clickmode.indexOf('event') > -1 && mayEmitSelected;
51472
51500
 
51473
51501
  if(
51474
51502
  !plotinfo && // get called from plot_api & plots
51475
- fullLayout._reselect
51503
+ mayEmitSelected
51476
51504
  ) {
51477
- if(sendEvents) {
51478
- var activePolygons = getLayoutPolygons(gd, true);
51505
+ var activePolygons = getLayoutPolygons(gd, true);
51479
51506
 
51507
+ if(activePolygons.length) {
51480
51508
  var xref = activePolygons[0].xref;
51481
51509
  var yref = activePolygons[0].yref;
51482
51510
  if(xref && yref) {
@@ -51489,9 +51517,12 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51489
51517
 
51490
51518
  fillRangeItems(eventData, poly);
51491
51519
  }
51520
+ }
51492
51521
 
51493
- eventData.selections = gd.layout.selections;
51494
- emitSelected(gd, eventData);
51522
+ if(gd._fullLayout._noEmitSelectedAtStart) {
51523
+ gd._fullLayout._noEmitSelectedAtStart = false;
51524
+ } else {
51525
+ if(sendEvents) emitSelected(gd, eventData);
51495
51526
  }
51496
51527
 
51497
51528
  fullLayout._reselect = false;
@@ -51511,10 +51542,9 @@ function reselect(gd, selectionTesters, searchTraces, dragOptions) {
51511
51542
 
51512
51543
  if(sendEvents) {
51513
51544
  if(eventData.points.length) {
51514
- eventData.selections = gd.layout.selections;
51515
51545
  emitSelected(gd, eventData);
51516
51546
  } else {
51517
- gd.emit('plotly_deselect', null);
51547
+ emitDeselect(gd);
51518
51548
  }
51519
51549
  }
51520
51550
 
@@ -51806,6 +51836,10 @@ function emitSelecting(gd, eventData) {
51806
51836
  }
51807
51837
 
51808
51838
  function emitSelected(gd, eventData) {
51839
+ if(eventData) {
51840
+ eventData.selections = (gd.layout || {}).selections || [];
51841
+ }
51842
+
51809
51843
  gd.emit('plotly_selected', eventData);
51810
51844
  }
51811
51845
 
@@ -90836,7 +90870,16 @@ plots.redrag = function(gd) {
90836
90870
  };
90837
90871
 
90838
90872
  plots.reselect = function(gd) {
90839
- Registry.getComponentMethod('selections', 'reselect')(gd);
90873
+ var fullLayout = gd._fullLayout;
90874
+
90875
+ var A = (gd.layout || {}).selections;
90876
+ var B = fullLayout._previousSelections;
90877
+ fullLayout._previousSelections = A;
90878
+
90879
+ var mayEmitSelected = fullLayout._reselect ||
90880
+ JSON.stringify(A) !== JSON.stringify(B);
90881
+
90882
+ Registry.getComponentMethod('selections', 'reselect')(gd, mayEmitSelected);
90840
90883
  };
90841
90884
 
90842
90885
  plots.generalUpdatePerTraceModule = function(gd, subplot, subplotCalcData, subplotLayout) {
@@ -97412,7 +97455,7 @@ function getSortFunc(opts, d2c) {
97412
97455
  'use strict';
97413
97456
 
97414
97457
  // package version injected by `npm run preprocess`
97415
- exports.version = '2.13.0';
97458
+ exports.version = '2.13.3';
97416
97459
 
97417
97460
  },{}]},{},[8])(8)
97418
97461
  });