plotly.js 2.6.2 → 2.6.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.6.2
2
+ * plotly.js v2.6.3
3
3
  * Copyright 2012-2021, 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.6.2';
71
+ exports.version = '2.6.3';
72
72
 
73
73
  },{}]},{},[16])(16)
74
74
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * plotly.js (geo) v2.6.2
2
+ * plotly.js (geo) v2.6.3
3
3
  * Copyright 2012-2021, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -35716,6 +35716,19 @@ function makeColorBarData(gd) {
35716
35716
  }
35717
35717
 
35718
35718
  function drawColorBar(g, opts, gd) {
35719
+ var len = opts.len;
35720
+ var lenmode = opts.lenmode;
35721
+ var thickness = opts.thickness;
35722
+ var thicknessmode = opts.thicknessmode;
35723
+ var outlinewidth = opts.outlinewidth;
35724
+ var borderwidth = opts.borderwidth;
35725
+ var xanchor = opts.xanchor;
35726
+ var yanchor = opts.yanchor;
35727
+ var xpad = opts.xpad;
35728
+ var ypad = opts.ypad;
35729
+ var optsX = opts.x;
35730
+ var optsY = opts.y;
35731
+
35719
35732
  var fullLayout = gd._fullLayout;
35720
35733
  var gs = fullLayout._size;
35721
35734
 
@@ -35745,42 +35758,41 @@ function drawColorBar(g, opts, gd) {
35745
35758
  // when the colorbar itself is pushing the margins.
35746
35759
  // but then the fractional size is calculated based on the
35747
35760
  // actual graph size, so that the axes will size correctly.
35748
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
35761
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
35749
35762
  var thickFrac = thickPx / gs.w;
35750
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
35763
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
35751
35764
  var lenFrac = lenPx / gs.h;
35752
- var xpadFrac = opts.xpad / gs.w;
35753
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
35754
- var ypadFrac = opts.ypad / gs.h;
35765
+ var xpadFrac = xpad / gs.w;
35766
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
35767
+ var ypadFrac = ypad / gs.h;
35755
35768
 
35756
35769
  // x positioning: do it initially just for left anchor,
35757
35770
  // then fix at the end (since we don't know the width yet)
35758
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
35771
+ var uPx = Math.round(optsX * gs.w + xpad);
35759
35772
  // for dragging... this is getting a little muddled...
35760
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
35773
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
35761
35774
 
35762
35775
  // y positioning we can do correctly from the start
35763
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
35764
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
35765
- var yTopPx = yBottomPx - lenPx;
35776
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
35777
+ var vPx = Math.round(gs.h * (1 - vFrac));
35766
35778
 
35767
35779
  // stash a few things for makeEditable
35768
35780
  opts._lenFrac = lenFrac;
35769
35781
  opts._thickFrac = thickFrac;
35770
- opts._xLeftFrac = xLeftFrac;
35771
- opts._yBottomFrac = yBottomFrac;
35782
+ opts._uFrac = uFrac;
35783
+ opts._vFrac = vFrac;
35772
35784
 
35773
35785
  // stash mocked axis for contour label formatting
35774
35786
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
35775
35787
 
35776
35788
  // position can't go in through supplyDefaults
35777
35789
  // because that restricts it to [0,1]
35778
- ax.position = opts.x + xpadFrac + thickFrac;
35790
+ ax.position = optsX + xpadFrac + thickFrac;
35779
35791
 
35780
35792
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
35781
35793
  ax.title.side = titleSide;
35782
- ax.titlex = opts.x + xpadFrac;
35783
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
35794
+ ax.titlex = optsX + xpadFrac;
35795
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
35784
35796
  }
35785
35797
 
35786
35798
  if(line.color && opts.tickmode === 'auto') {
@@ -35788,7 +35800,7 @@ function drawColorBar(g, opts, gd) {
35788
35800
  ax.tick0 = levelsIn.start;
35789
35801
  var dtick = levelsIn.size;
35790
35802
  // expand if too many contours, so we don't get too many ticks
35791
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
35803
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
35792
35804
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
35793
35805
  if(dtFactor > 1) {
35794
35806
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -35806,8 +35818,8 @@ function drawColorBar(g, opts, gd) {
35806
35818
  // set domain after init, because we may want to
35807
35819
  // allow it outside [0,1]
35808
35820
  ax.domain = [
35809
- yBottomFrac + ypadFrac,
35810
- yBottomFrac + lenFrac - ypadFrac
35821
+ vFrac + ypadFrac,
35822
+ vFrac + lenFrac - ypadFrac
35811
35823
  ];
35812
35824
 
35813
35825
  ax.setScale();
@@ -35848,15 +35860,15 @@ function drawColorBar(g, opts, gd) {
35848
35860
  // draw the title so we know how much room it needs
35849
35861
  // when we squish the axis. This one only applies to
35850
35862
  // top or bottom titles, not right side.
35851
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
35863
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
35852
35864
  var fontSize = ax.title.font.size;
35853
35865
  var y;
35854
35866
 
35855
35867
  if(titleSide === 'top') {
35856
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
35868
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
35857
35869
  gs.t + 3 + fontSize * 0.75;
35858
35870
  } else {
35859
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
35871
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
35860
35872
  gs.t - 3 - fontSize * 0.25;
35861
35873
  }
35862
35874
  drawTitle(ax._id + 'title', {
@@ -35895,7 +35907,7 @@ function drawColorBar(g, opts, gd) {
35895
35907
  // squish the axis top to make room for the title
35896
35908
  var titleGroup = g.select('.' + cn.cbtitle);
35897
35909
  var titleText = titleGroup.select('text');
35898
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
35910
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
35899
35911
  var mathJaxNode = titleGroup
35900
35912
  .select('.h' + ax._id + 'title-math-group')
35901
35913
  .node();
@@ -35967,7 +35979,7 @@ function drawColorBar(g, opts, gd) {
35967
35979
  // Colorbar cannot currently support opacities so we
35968
35980
  // use an opaque fill even when alpha channels present
35969
35981
  var fillEl = d3.select(this).attr({
35970
- x: xLeft,
35982
+ x: uPx,
35971
35983
  width: Math.max(thickPx, 2),
35972
35984
  y: d3.min(z),
35973
35985
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -35991,7 +36003,7 @@ function drawColorBar(g, opts, gd) {
35991
36003
  lines.exit().remove();
35992
36004
  lines.each(function(d) {
35993
36005
  d3.select(this)
35994
- .attr('d', 'M' + xLeft + ',' +
36006
+ .attr('d', 'M' + uPx + ',' +
35995
36007
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
35996
36008
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
35997
36009
  });
@@ -35999,8 +36011,8 @@ function drawColorBar(g, opts, gd) {
35999
36011
  // force full redraw of labels and ticks
36000
36012
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
36001
36013
 
36002
- var shift = xLeft + thickPx +
36003
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
36014
+ var shift = uPx + thickPx +
36015
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
36004
36016
 
36005
36017
  var vals = Axes.calcTicks(ax);
36006
36018
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -36025,9 +36037,9 @@ function drawColorBar(g, opts, gd) {
36025
36037
  // TODO: why are we redrawing multiple times now with this?
36026
36038
  // I guess autoMargin doesn't like being post-promise?
36027
36039
  function positionCB() {
36028
- var innerWidth = thickPx + opts.outlinewidth / 2;
36040
+ var innerThickness = thickPx + outlinewidth / 2;
36029
36041
  if(ax.ticklabelposition.indexOf('inside') === -1) {
36030
- innerWidth += Drawing.bBox(axLayer.node()).width;
36042
+ innerThickness += Drawing.bBox(axLayer.node()).width;
36031
36043
  }
36032
36044
 
36033
36045
  titleEl = titleCont.select('text');
@@ -36042,66 +36054,65 @@ function drawColorBar(g, opts, gd) {
36042
36054
  // (except for top/bottom mathjax, above)
36043
36055
  // but the weird gs.l is because the titleunshift
36044
36056
  // transform gets removed by Drawing.bBox
36045
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
36057
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
36046
36058
  }
36047
- innerWidth = Math.max(innerWidth, titleWidth);
36059
+ innerThickness = Math.max(innerThickness, titleWidth);
36048
36060
  }
36049
36061
 
36050
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
36051
- var outerheight = yBottomPx - yTopPx;
36062
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
36052
36063
 
36053
36064
  g.select('.' + cn.cbbg).attr({
36054
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
36055
- y: yTopPx - yExtraPx,
36056
- width: Math.max(outerwidth, 2),
36057
- height: Math.max(outerheight + 2 * yExtraPx, 2)
36065
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
36066
+ y: vPx - lenPx - yExtraPx,
36067
+ width: Math.max(outerThickness, 2),
36068
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
36058
36069
  })
36059
36070
  .call(Color.fill, opts.bgcolor)
36060
36071
  .call(Color.stroke, opts.bordercolor)
36061
- .style('stroke-width', opts.borderwidth);
36072
+ .style('stroke-width', borderwidth);
36062
36073
 
36063
36074
  g.selectAll('.' + cn.cboutline).attr({
36064
- x: xLeft,
36065
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
36075
+ x: uPx,
36076
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
36066
36077
  width: Math.max(thickPx, 2),
36067
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
36078
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
36068
36079
  })
36069
36080
  .call(Color.stroke, opts.outlinecolor)
36070
36081
  .style({
36071
36082
  fill: 'none',
36072
- 'stroke-width': opts.outlinewidth
36083
+ 'stroke-width': outlinewidth
36073
36084
  });
36074
36085
 
36075
36086
  // fix positioning for xanchor!='left'
36076
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
36087
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
36077
36088
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
36078
36089
 
36079
36090
  // auto margin adjustment
36080
36091
  var marginOpts = {};
36081
- var tFrac = FROM_TL[opts.yanchor];
36082
- var bFrac = FROM_BR[opts.yanchor];
36083
- if(opts.lenmode === 'pixels') {
36084
- marginOpts.y = opts.y;
36085
- marginOpts.t = outerheight * tFrac;
36086
- marginOpts.b = outerheight * bFrac;
36092
+ var tFrac = FROM_TL[yanchor];
36093
+ var bFrac = FROM_BR[yanchor];
36094
+ if(lenmode === 'pixels') {
36095
+ marginOpts.y = optsY;
36096
+ marginOpts.t = lenPx * tFrac;
36097
+ marginOpts.b = lenPx * bFrac;
36087
36098
  } else {
36088
36099
  marginOpts.t = marginOpts.b = 0;
36089
- marginOpts.yt = opts.y + opts.len * tFrac;
36090
- marginOpts.yb = opts.y - opts.len * bFrac;
36100
+ marginOpts.yt = optsY + len * tFrac;
36101
+ marginOpts.yb = optsY - len * bFrac;
36091
36102
  }
36092
36103
 
36093
- var lFrac = FROM_TL[opts.xanchor];
36094
- var rFrac = FROM_BR[opts.xanchor];
36095
- if(opts.thicknessmode === 'pixels') {
36096
- marginOpts.x = opts.x;
36097
- marginOpts.l = outerwidth * lFrac;
36098
- marginOpts.r = outerwidth * rFrac;
36104
+ var lFrac = FROM_TL[xanchor];
36105
+ var rFrac = FROM_BR[xanchor];
36106
+ if(thicknessmode === 'pixels') {
36107
+ marginOpts.x = optsX;
36108
+ marginOpts.l = outerThickness * lFrac;
36109
+ marginOpts.r = outerThickness * rFrac;
36099
36110
  } else {
36100
- var extraThickness = outerwidth - thickPx;
36111
+ var extraThickness = outerThickness - thickPx;
36101
36112
  marginOpts.l = extraThickness * lFrac;
36102
36113
  marginOpts.r = extraThickness * rFrac;
36103
- marginOpts.xl = opts.x - opts.thickness * lFrac;
36104
- marginOpts.xr = opts.x + opts.thickness * rFrac;
36114
+ marginOpts.xl = optsX - thickness * lFrac;
36115
+ marginOpts.xr = optsX + thickness * rFrac;
36105
36116
  }
36106
36117
 
36107
36118
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -36132,9 +36143,9 @@ function makeEditable(g, opts, gd) {
36132
36143
  moveFn: function(dx, dy) {
36133
36144
  g.attr('transform', t0 + strTranslate(dx, dy));
36134
36145
 
36135
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
36146
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
36136
36147
  0, 1, opts.xanchor);
36137
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
36148
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
36138
36149
  0, 1, opts.yanchor);
36139
36150
 
36140
36151
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -40836,11 +40847,13 @@ var cartesianScatterPoints = {
40836
40847
  // The actual rendering is done by private function _hover.
40837
40848
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
40838
40849
  gd = Lib.getGraphDiv(gd);
40839
-
40850
+ // The 'target' property changes when bubbling out of Shadow DOM.
40851
+ // Throttling can delay reading the target, so we save the current value.
40852
+ var eventTarget = evt.target;
40840
40853
  Lib.throttle(
40841
40854
  gd._fullLayout._uid + constants.HOVERID,
40842
40855
  constants.HOVERMINTIME,
40843
- function() { _hover(gd, evt, subplot, noHoverEvent); }
40856
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
40844
40857
  );
40845
40858
  };
40846
40859
 
@@ -41005,7 +41018,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
41005
41018
  };
41006
41019
 
41007
41020
  // The actual implementation is here:
41008
- function _hover(gd, evt, subplot, noHoverEvent) {
41021
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
41009
41022
  if(!subplot) subplot = 'xy';
41010
41023
 
41011
41024
  // if the user passed in an array of subplots,
@@ -41124,7 +41137,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
41124
41137
  // [x|y]px: the pixels (from top left) of the mouse location
41125
41138
  // on the currently selected plot area
41126
41139
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
41127
- var hasUserCalledHover = !evt.target;
41140
+ var hasUserCalledHover = !eventTarget;
41128
41141
  var xpx, ypx;
41129
41142
 
41130
41143
  if(hasUserCalledHover) {
@@ -41141,13 +41154,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
41141
41154
  return;
41142
41155
  }
41143
41156
 
41144
- // Discover event target, traversing open shadow roots.
41145
- var target = evt.composedPath && evt.composedPath()[0];
41146
- if(!target) {
41147
- // Fallback for browsers not supporting composedPath
41148
- target = evt.target;
41149
- }
41150
- var dbb = target.getBoundingClientRect();
41157
+ var dbb = eventTarget.getBoundingClientRect();
41151
41158
 
41152
41159
  xpx = evt.clientX - dbb.left;
41153
41160
  ypx = evt.clientY - dbb.top;
@@ -41595,15 +41602,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
41595
41602
  if(!helpers.isUnifiedHover(hovermode)) {
41596
41603
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
41597
41604
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
41598
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
41605
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
41599
41606
  // we should improve the "fx" API so other plots can use it without these hack.
41600
- if(evt.target && evt.target.tagName) {
41607
+ if(eventTarget && eventTarget.tagName) {
41601
41608
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
41602
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
41609
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
41603
41610
  }
41604
41611
 
41605
41612
  // don't emit events if called manually
41606
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
41613
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
41607
41614
 
41608
41615
  if(oldhoverdata) {
41609
41616
  gd.emit('plotly_unhover', {
@@ -95037,7 +95044,7 @@ function getSortFunc(opts, d2c) {
95037
95044
  'use strict';
95038
95045
 
95039
95046
  // package version injected by `npm run preprocess`
95040
- exports.version = '2.6.2';
95047
+ exports.version = '2.6.3';
95041
95048
 
95042
95049
  },{}]},{},[8])(8)
95043
95050
  });