plotly.js 2.13.1 → 2.13.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plotly.js",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
4
4
  "description": "The open source javascript graphing library that powers plotly",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",
@@ -50,7 +50,14 @@ var p2r = helpers.p2r;
50
50
  var axValue = helpers.axValue;
51
51
  var getTransform = helpers.getTransform;
52
52
 
53
+ function hasSubplot(dragOptions) {
54
+ // N.B. subplot may be falsy e.g zero sankey index!
55
+ return dragOptions.subplot !== undefined;
56
+ }
57
+
53
58
  function prepSelect(evt, startX, startY, dragOptions, mode) {
59
+ var isCartesian = !hasSubplot(dragOptions);
60
+
54
61
  var isFreeMode = freeMode(mode);
55
62
  var isRectMode = rectMode(mode);
56
63
  var isOpenMode = openMode(mode);
@@ -64,7 +71,7 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
64
71
  var gd = dragOptions.gd;
65
72
  var fullLayout = gd._fullLayout;
66
73
  var immediateSelect = isSelectMode && fullLayout.newselection.mode === 'immediate' &&
67
- !dragOptions.subplot; // N.B. only cartesian subplots have persistent selection
74
+ isCartesian; // N.B. only cartesian subplots have persistent selection
68
75
 
69
76
  var zoomLayer = fullLayout._zoomlayer;
70
77
  var dragBBox = dragOptions.element.getBoundingClientRect();
@@ -112,9 +119,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
112
119
  opacity: isDrawMode ? newStyle.opacity / 2 : 1,
113
120
  fill: (isDrawMode && !isOpenMode) ? newStyle.fillcolor : 'none',
114
121
  stroke: newStyle.line.color || (
115
- dragOptions.subplot !== undefined ?
116
- '#7f7f7f' : // non-cartesian subplot
117
- Color.contrast(gd._fullLayout.plot_bgcolor) // cartesian subplot
122
+ isCartesian ?
123
+ Color.contrast(gd._fullLayout.plot_bgcolor) :
124
+ '#7f7f7f' // non-cartesian subplot
118
125
  ),
119
126
  'stroke-dasharray': dashStyle(newStyle.line.dash, newStyle.line.width),
120
127
  'stroke-width': newStyle.line.width + 'px',
@@ -145,6 +152,8 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
145
152
 
146
153
  if(immediateSelect && !evt.shiftKey) {
147
154
  dragOptions._clearSubplotSelections = function() {
155
+ if(!isCartesian) return;
156
+
148
157
  var xRef = xAxis._id;
149
158
  var yRef = yAxis._id;
150
159
  deselectSubplot(gd, xRef, yRef, searchTraces);
@@ -451,7 +460,9 @@ function prepSelect(evt, startX, startY, dragOptions, mode) {
451
460
  dragOptions.doneFnCompleted(selection);
452
461
  }
453
462
 
454
- emitSelected(gd, eventData);
463
+ if(isSelectMode) {
464
+ emitSelected(gd, eventData);
465
+ }
455
466
  }).catch(Lib.error);
456
467
  };
457
468
  }
@@ -673,15 +684,23 @@ function coerceSelectionsCache(evt, gd, dragOptions) {
673
684
  }
674
685
  }
675
686
 
687
+ function hasActiveShape(gd) {
688
+ return gd._fullLayout._activeShapeIndex >= 0;
689
+ }
690
+
691
+ function hasActiveSelection(gd) {
692
+ return gd._fullLayout._activeSelectionIndex >= 0;
693
+ }
694
+
676
695
  function clearSelectionsCache(dragOptions, immediateSelect) {
677
696
  var dragmode = dragOptions.dragmode;
678
697
  var plotinfo = dragOptions.plotinfo;
679
698
 
680
699
  var gd = dragOptions.gd;
681
- if(gd._fullLayout._activeShapeIndex >= 0) {
700
+ if(hasActiveShape(gd)) {
682
701
  gd._fullLayout._deactivateShape(gd);
683
702
  }
684
- if(gd._fullLayout._activeSelectionIndex >= 0) {
703
+ if(hasActiveSelection(gd)) {
685
704
  gd._fullLayout._deactivateSelection(gd);
686
705
  }
687
706
 
@@ -709,7 +728,7 @@ function clearSelectionsCache(dragOptions, immediateSelect) {
709
728
  var selections;
710
729
  if(
711
730
  isSelectMode &&
712
- !dragOptions.subplot // only allow cartesian - no mapbox for now
731
+ !hasSubplot(dragOptions) // only allow cartesian - no mapbox for now
713
732
  ) {
714
733
  selections = newSelections(outlines, dragOptions);
715
734
  }
@@ -748,7 +767,10 @@ function determineSearchTraces(gd, xAxes, yAxes, subplot) {
748
767
 
749
768
  if(trace.visible !== true || !trace._module || !trace._module.selectPoints) continue;
750
769
 
751
- if(subplot && (trace.subplot === subplot || trace.geo === subplot)) {
770
+ if(
771
+ hasSubplot({subplot: subplot}) &&
772
+ (trace.subplot === subplot || trace.geo === subplot)
773
+ ) {
752
774
  searchTraces.push(createSearchInfo(trace._module, cd, xAxes[0], yAxes[0]));
753
775
  } else if(trace.type === 'splom') {
754
776
  // FIXME: make sure we don't have more than single axis for splom
@@ -1503,13 +1525,10 @@ function getFillRangeItems(dragOptions) {
1503
1525
  }
1504
1526
 
1505
1527
  function emitSelecting(gd, eventData) {
1506
- if(drawMode(gd._fullLayout.dragmode)) return;
1507
1528
  gd.emit('plotly_selecting', eventData);
1508
1529
  }
1509
1530
 
1510
1531
  function emitSelected(gd, eventData) {
1511
- if(drawMode(gd._fullLayout.dragmode)) return;
1512
-
1513
1532
  if(eventData) {
1514
1533
  eventData.selections = (gd.layout || {}).selections || [];
1515
1534
  }
@@ -1518,7 +1537,6 @@ function emitSelected(gd, eventData) {
1518
1537
  }
1519
1538
 
1520
1539
  function emitDeselect(gd) {
1521
- if(drawMode(gd._fullLayout.dragmode)) return;
1522
1540
  gd.emit('plotly_deselect', null);
1523
1541
  }
1524
1542
 
@@ -48,6 +48,7 @@ function subplotUpdateFx(gd, index) {
48
48
  var dragMode = fullLayout.dragmode;
49
49
  var cursor = fullLayout.dragmode === 'pan' ? 'move' : 'crosshair';
50
50
  var bgRect = trace._bgRect;
51
+ if(!bgRect) return;
51
52
 
52
53
  if(dragMode === 'pan' || dragMode === 'zoom') return;
53
54
 
package/src/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  'use strict';
2
2
 
3
3
  // package version injected by `npm run preprocess`
4
- exports.version = '2.13.1';
4
+ exports.version = '2.13.2';