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
@@ -106719,6 +106719,19 @@ function makeColorBarData(gd) {
106719
106719
  }
106720
106720
 
106721
106721
  function drawColorBar(g, opts, gd) {
106722
+ var len = opts.len;
106723
+ var lenmode = opts.lenmode;
106724
+ var thickness = opts.thickness;
106725
+ var thicknessmode = opts.thicknessmode;
106726
+ var outlinewidth = opts.outlinewidth;
106727
+ var borderwidth = opts.borderwidth;
106728
+ var xanchor = opts.xanchor;
106729
+ var yanchor = opts.yanchor;
106730
+ var xpad = opts.xpad;
106731
+ var ypad = opts.ypad;
106732
+ var optsX = opts.x;
106733
+ var optsY = opts.y;
106734
+
106722
106735
  var fullLayout = gd._fullLayout;
106723
106736
  var gs = fullLayout._size;
106724
106737
 
@@ -106748,42 +106761,41 @@ function drawColorBar(g, opts, gd) {
106748
106761
  // when the colorbar itself is pushing the margins.
106749
106762
  // but then the fractional size is calculated based on the
106750
106763
  // actual graph size, so that the axes will size correctly.
106751
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
106764
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
106752
106765
  var thickFrac = thickPx / gs.w;
106753
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
106766
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
106754
106767
  var lenFrac = lenPx / gs.h;
106755
- var xpadFrac = opts.xpad / gs.w;
106756
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
106757
- var ypadFrac = opts.ypad / gs.h;
106768
+ var xpadFrac = xpad / gs.w;
106769
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
106770
+ var ypadFrac = ypad / gs.h;
106758
106771
 
106759
106772
  // x positioning: do it initially just for left anchor,
106760
106773
  // then fix at the end (since we don't know the width yet)
106761
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
106774
+ var uPx = Math.round(optsX * gs.w + xpad);
106762
106775
  // for dragging... this is getting a little muddled...
106763
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
106776
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
106764
106777
 
106765
106778
  // y positioning we can do correctly from the start
106766
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
106767
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
106768
- var yTopPx = yBottomPx - lenPx;
106779
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
106780
+ var vPx = Math.round(gs.h * (1 - vFrac));
106769
106781
 
106770
106782
  // stash a few things for makeEditable
106771
106783
  opts._lenFrac = lenFrac;
106772
106784
  opts._thickFrac = thickFrac;
106773
- opts._xLeftFrac = xLeftFrac;
106774
- opts._yBottomFrac = yBottomFrac;
106785
+ opts._uFrac = uFrac;
106786
+ opts._vFrac = vFrac;
106775
106787
 
106776
106788
  // stash mocked axis for contour label formatting
106777
106789
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
106778
106790
 
106779
106791
  // position can't go in through supplyDefaults
106780
106792
  // because that restricts it to [0,1]
106781
- ax.position = opts.x + xpadFrac + thickFrac;
106793
+ ax.position = optsX + xpadFrac + thickFrac;
106782
106794
 
106783
106795
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
106784
106796
  ax.title.side = titleSide;
106785
- ax.titlex = opts.x + xpadFrac;
106786
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
106797
+ ax.titlex = optsX + xpadFrac;
106798
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
106787
106799
  }
106788
106800
 
106789
106801
  if(line.color && opts.tickmode === 'auto') {
@@ -106791,7 +106803,7 @@ function drawColorBar(g, opts, gd) {
106791
106803
  ax.tick0 = levelsIn.start;
106792
106804
  var dtick = levelsIn.size;
106793
106805
  // expand if too many contours, so we don't get too many ticks
106794
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
106806
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
106795
106807
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
106796
106808
  if(dtFactor > 1) {
106797
106809
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -106809,8 +106821,8 @@ function drawColorBar(g, opts, gd) {
106809
106821
  // set domain after init, because we may want to
106810
106822
  // allow it outside [0,1]
106811
106823
  ax.domain = [
106812
- yBottomFrac + ypadFrac,
106813
- yBottomFrac + lenFrac - ypadFrac
106824
+ vFrac + ypadFrac,
106825
+ vFrac + lenFrac - ypadFrac
106814
106826
  ];
106815
106827
 
106816
106828
  ax.setScale();
@@ -106851,15 +106863,15 @@ function drawColorBar(g, opts, gd) {
106851
106863
  // draw the title so we know how much room it needs
106852
106864
  // when we squish the axis. This one only applies to
106853
106865
  // top or bottom titles, not right side.
106854
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
106866
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
106855
106867
  var fontSize = ax.title.font.size;
106856
106868
  var y;
106857
106869
 
106858
106870
  if(titleSide === 'top') {
106859
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
106871
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
106860
106872
  gs.t + 3 + fontSize * 0.75;
106861
106873
  } else {
106862
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
106874
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
106863
106875
  gs.t - 3 - fontSize * 0.25;
106864
106876
  }
106865
106877
  drawTitle(ax._id + 'title', {
@@ -106898,7 +106910,7 @@ function drawColorBar(g, opts, gd) {
106898
106910
  // squish the axis top to make room for the title
106899
106911
  var titleGroup = g.select('.' + cn.cbtitle);
106900
106912
  var titleText = titleGroup.select('text');
106901
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
106913
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
106902
106914
  var mathJaxNode = titleGroup
106903
106915
  .select('.h' + ax._id + 'title-math-group')
106904
106916
  .node();
@@ -106970,7 +106982,7 @@ function drawColorBar(g, opts, gd) {
106970
106982
  // Colorbar cannot currently support opacities so we
106971
106983
  // use an opaque fill even when alpha channels present
106972
106984
  var fillEl = d3.select(this).attr({
106973
- x: xLeft,
106985
+ x: uPx,
106974
106986
  width: Math.max(thickPx, 2),
106975
106987
  y: d3.min(z),
106976
106988
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -106994,7 +107006,7 @@ function drawColorBar(g, opts, gd) {
106994
107006
  lines.exit().remove();
106995
107007
  lines.each(function(d) {
106996
107008
  d3.select(this)
106997
- .attr('d', 'M' + xLeft + ',' +
107009
+ .attr('d', 'M' + uPx + ',' +
106998
107010
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
106999
107011
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
107000
107012
  });
@@ -107002,8 +107014,8 @@ function drawColorBar(g, opts, gd) {
107002
107014
  // force full redraw of labels and ticks
107003
107015
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
107004
107016
 
107005
- var shift = xLeft + thickPx +
107006
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
107017
+ var shift = uPx + thickPx +
107018
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
107007
107019
 
107008
107020
  var vals = Axes.calcTicks(ax);
107009
107021
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -107028,9 +107040,9 @@ function drawColorBar(g, opts, gd) {
107028
107040
  // TODO: why are we redrawing multiple times now with this?
107029
107041
  // I guess autoMargin doesn't like being post-promise?
107030
107042
  function positionCB() {
107031
- var innerWidth = thickPx + opts.outlinewidth / 2;
107043
+ var innerThickness = thickPx + outlinewidth / 2;
107032
107044
  if(ax.ticklabelposition.indexOf('inside') === -1) {
107033
- innerWidth += Drawing.bBox(axLayer.node()).width;
107045
+ innerThickness += Drawing.bBox(axLayer.node()).width;
107034
107046
  }
107035
107047
 
107036
107048
  titleEl = titleCont.select('text');
@@ -107045,66 +107057,65 @@ function drawColorBar(g, opts, gd) {
107045
107057
  // (except for top/bottom mathjax, above)
107046
107058
  // but the weird gs.l is because the titleunshift
107047
107059
  // transform gets removed by Drawing.bBox
107048
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
107060
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
107049
107061
  }
107050
- innerWidth = Math.max(innerWidth, titleWidth);
107062
+ innerThickness = Math.max(innerThickness, titleWidth);
107051
107063
  }
107052
107064
 
107053
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
107054
- var outerheight = yBottomPx - yTopPx;
107065
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
107055
107066
 
107056
107067
  g.select('.' + cn.cbbg).attr({
107057
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
107058
- y: yTopPx - yExtraPx,
107059
- width: Math.max(outerwidth, 2),
107060
- height: Math.max(outerheight + 2 * yExtraPx, 2)
107068
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
107069
+ y: vPx - lenPx - yExtraPx,
107070
+ width: Math.max(outerThickness, 2),
107071
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
107061
107072
  })
107062
107073
  .call(Color.fill, opts.bgcolor)
107063
107074
  .call(Color.stroke, opts.bordercolor)
107064
- .style('stroke-width', opts.borderwidth);
107075
+ .style('stroke-width', borderwidth);
107065
107076
 
107066
107077
  g.selectAll('.' + cn.cboutline).attr({
107067
- x: xLeft,
107068
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
107078
+ x: uPx,
107079
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
107069
107080
  width: Math.max(thickPx, 2),
107070
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
107081
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
107071
107082
  })
107072
107083
  .call(Color.stroke, opts.outlinecolor)
107073
107084
  .style({
107074
107085
  fill: 'none',
107075
- 'stroke-width': opts.outlinewidth
107086
+ 'stroke-width': outlinewidth
107076
107087
  });
107077
107088
 
107078
107089
  // fix positioning for xanchor!='left'
107079
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
107090
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
107080
107091
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
107081
107092
 
107082
107093
  // auto margin adjustment
107083
107094
  var marginOpts = {};
107084
- var tFrac = FROM_TL[opts.yanchor];
107085
- var bFrac = FROM_BR[opts.yanchor];
107086
- if(opts.lenmode === 'pixels') {
107087
- marginOpts.y = opts.y;
107088
- marginOpts.t = outerheight * tFrac;
107089
- marginOpts.b = outerheight * bFrac;
107095
+ var tFrac = FROM_TL[yanchor];
107096
+ var bFrac = FROM_BR[yanchor];
107097
+ if(lenmode === 'pixels') {
107098
+ marginOpts.y = optsY;
107099
+ marginOpts.t = lenPx * tFrac;
107100
+ marginOpts.b = lenPx * bFrac;
107090
107101
  } else {
107091
107102
  marginOpts.t = marginOpts.b = 0;
107092
- marginOpts.yt = opts.y + opts.len * tFrac;
107093
- marginOpts.yb = opts.y - opts.len * bFrac;
107103
+ marginOpts.yt = optsY + len * tFrac;
107104
+ marginOpts.yb = optsY - len * bFrac;
107094
107105
  }
107095
107106
 
107096
- var lFrac = FROM_TL[opts.xanchor];
107097
- var rFrac = FROM_BR[opts.xanchor];
107098
- if(opts.thicknessmode === 'pixels') {
107099
- marginOpts.x = opts.x;
107100
- marginOpts.l = outerwidth * lFrac;
107101
- marginOpts.r = outerwidth * rFrac;
107107
+ var lFrac = FROM_TL[xanchor];
107108
+ var rFrac = FROM_BR[xanchor];
107109
+ if(thicknessmode === 'pixels') {
107110
+ marginOpts.x = optsX;
107111
+ marginOpts.l = outerThickness * lFrac;
107112
+ marginOpts.r = outerThickness * rFrac;
107102
107113
  } else {
107103
- var extraThickness = outerwidth - thickPx;
107114
+ var extraThickness = outerThickness - thickPx;
107104
107115
  marginOpts.l = extraThickness * lFrac;
107105
107116
  marginOpts.r = extraThickness * rFrac;
107106
- marginOpts.xl = opts.x - opts.thickness * lFrac;
107107
- marginOpts.xr = opts.x + opts.thickness * rFrac;
107117
+ marginOpts.xl = optsX - thickness * lFrac;
107118
+ marginOpts.xr = optsX + thickness * rFrac;
107108
107119
  }
107109
107120
 
107110
107121
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -107135,9 +107146,9 @@ function makeEditable(g, opts, gd) {
107135
107146
  moveFn: function(dx, dy) {
107136
107147
  g.attr('transform', t0 + strTranslate(dx, dy));
107137
107148
 
107138
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
107149
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
107139
107150
  0, 1, opts.xanchor);
107140
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
107151
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
107141
107152
  0, 1, opts.yanchor);
107142
107153
 
107143
107154
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -112025,11 +112036,13 @@ var cartesianScatterPoints = {
112025
112036
  // The actual rendering is done by private function _hover.
112026
112037
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
112027
112038
  gd = Lib.getGraphDiv(gd);
112028
-
112039
+ // The 'target' property changes when bubbling out of Shadow DOM.
112040
+ // Throttling can delay reading the target, so we save the current value.
112041
+ var eventTarget = evt.target;
112029
112042
  Lib.throttle(
112030
112043
  gd._fullLayout._uid + constants.HOVERID,
112031
112044
  constants.HOVERMINTIME,
112032
- function() { _hover(gd, evt, subplot, noHoverEvent); }
112045
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
112033
112046
  );
112034
112047
  };
112035
112048
 
@@ -112194,7 +112207,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
112194
112207
  };
112195
112208
 
112196
112209
  // The actual implementation is here:
112197
- function _hover(gd, evt, subplot, noHoverEvent) {
112210
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
112198
112211
  if(!subplot) subplot = 'xy';
112199
112212
 
112200
112213
  // if the user passed in an array of subplots,
@@ -112313,7 +112326,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
112313
112326
  // [x|y]px: the pixels (from top left) of the mouse location
112314
112327
  // on the currently selected plot area
112315
112328
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
112316
- var hasUserCalledHover = !evt.target;
112329
+ var hasUserCalledHover = !eventTarget;
112317
112330
  var xpx, ypx;
112318
112331
 
112319
112332
  if(hasUserCalledHover) {
@@ -112330,13 +112343,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
112330
112343
  return;
112331
112344
  }
112332
112345
 
112333
- // Discover event target, traversing open shadow roots.
112334
- var target = evt.composedPath && evt.composedPath()[0];
112335
- if(!target) {
112336
- // Fallback for browsers not supporting composedPath
112337
- target = evt.target;
112338
- }
112339
- var dbb = target.getBoundingClientRect();
112346
+ var dbb = eventTarget.getBoundingClientRect();
112340
112347
 
112341
112348
  xpx = evt.clientX - dbb.left;
112342
112349
  ypx = evt.clientY - dbb.top;
@@ -112784,15 +112791,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
112784
112791
  if(!helpers.isUnifiedHover(hovermode)) {
112785
112792
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
112786
112793
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
112787
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
112794
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
112788
112795
  // we should improve the "fx" API so other plots can use it without these hack.
112789
- if(evt.target && evt.target.tagName) {
112796
+ if(eventTarget && eventTarget.tagName) {
112790
112797
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
112791
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
112798
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
112792
112799
  }
112793
112800
 
112794
112801
  // don't emit events if called manually
112795
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
112802
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
112796
112803
 
112797
112804
  if(oldhoverdata) {
112798
112805
  gd.emit('plotly_unhover', {
@@ -229819,7 +229826,7 @@ function getSortFunc(opts, d2c) {
229819
229826
  'use strict';
229820
229827
 
229821
229828
  // package version injected by `npm run preprocess`
229822
- exports.version = '2.6.2';
229829
+ exports.version = '2.6.3';
229823
229830
 
229824
229831
  },{}],1119:[function(_dereq_,module,exports){
229825
229832
  (function (global){(function (){