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.
package/dist/plotly.js CHANGED
@@ -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
@@ -106410,6 +106410,19 @@ function makeColorBarData(gd) {
106410
106410
  }
106411
106411
 
106412
106412
  function drawColorBar(g, opts, gd) {
106413
+ var len = opts.len;
106414
+ var lenmode = opts.lenmode;
106415
+ var thickness = opts.thickness;
106416
+ var thicknessmode = opts.thicknessmode;
106417
+ var outlinewidth = opts.outlinewidth;
106418
+ var borderwidth = opts.borderwidth;
106419
+ var xanchor = opts.xanchor;
106420
+ var yanchor = opts.yanchor;
106421
+ var xpad = opts.xpad;
106422
+ var ypad = opts.ypad;
106423
+ var optsX = opts.x;
106424
+ var optsY = opts.y;
106425
+
106413
106426
  var fullLayout = gd._fullLayout;
106414
106427
  var gs = fullLayout._size;
106415
106428
 
@@ -106439,42 +106452,41 @@ function drawColorBar(g, opts, gd) {
106439
106452
  // when the colorbar itself is pushing the margins.
106440
106453
  // but then the fractional size is calculated based on the
106441
106454
  // actual graph size, so that the axes will size correctly.
106442
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
106455
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
106443
106456
  var thickFrac = thickPx / gs.w;
106444
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
106457
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
106445
106458
  var lenFrac = lenPx / gs.h;
106446
- var xpadFrac = opts.xpad / gs.w;
106447
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
106448
- var ypadFrac = opts.ypad / gs.h;
106459
+ var xpadFrac = xpad / gs.w;
106460
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
106461
+ var ypadFrac = ypad / gs.h;
106449
106462
 
106450
106463
  // x positioning: do it initially just for left anchor,
106451
106464
  // then fix at the end (since we don't know the width yet)
106452
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
106465
+ var uPx = Math.round(optsX * gs.w + xpad);
106453
106466
  // for dragging... this is getting a little muddled...
106454
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
106467
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
106455
106468
 
106456
106469
  // y positioning we can do correctly from the start
106457
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
106458
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
106459
- var yTopPx = yBottomPx - lenPx;
106470
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
106471
+ var vPx = Math.round(gs.h * (1 - vFrac));
106460
106472
 
106461
106473
  // stash a few things for makeEditable
106462
106474
  opts._lenFrac = lenFrac;
106463
106475
  opts._thickFrac = thickFrac;
106464
- opts._xLeftFrac = xLeftFrac;
106465
- opts._yBottomFrac = yBottomFrac;
106476
+ opts._uFrac = uFrac;
106477
+ opts._vFrac = vFrac;
106466
106478
 
106467
106479
  // stash mocked axis for contour label formatting
106468
106480
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
106469
106481
 
106470
106482
  // position can't go in through supplyDefaults
106471
106483
  // because that restricts it to [0,1]
106472
- ax.position = opts.x + xpadFrac + thickFrac;
106484
+ ax.position = optsX + xpadFrac + thickFrac;
106473
106485
 
106474
106486
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
106475
106487
  ax.title.side = titleSide;
106476
- ax.titlex = opts.x + xpadFrac;
106477
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
106488
+ ax.titlex = optsX + xpadFrac;
106489
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
106478
106490
  }
106479
106491
 
106480
106492
  if(line.color && opts.tickmode === 'auto') {
@@ -106482,7 +106494,7 @@ function drawColorBar(g, opts, gd) {
106482
106494
  ax.tick0 = levelsIn.start;
106483
106495
  var dtick = levelsIn.size;
106484
106496
  // expand if too many contours, so we don't get too many ticks
106485
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
106497
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
106486
106498
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
106487
106499
  if(dtFactor > 1) {
106488
106500
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -106500,8 +106512,8 @@ function drawColorBar(g, opts, gd) {
106500
106512
  // set domain after init, because we may want to
106501
106513
  // allow it outside [0,1]
106502
106514
  ax.domain = [
106503
- yBottomFrac + ypadFrac,
106504
- yBottomFrac + lenFrac - ypadFrac
106515
+ vFrac + ypadFrac,
106516
+ vFrac + lenFrac - ypadFrac
106505
106517
  ];
106506
106518
 
106507
106519
  ax.setScale();
@@ -106542,15 +106554,15 @@ function drawColorBar(g, opts, gd) {
106542
106554
  // draw the title so we know how much room it needs
106543
106555
  // when we squish the axis. This one only applies to
106544
106556
  // top or bottom titles, not right side.
106545
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
106557
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
106546
106558
  var fontSize = ax.title.font.size;
106547
106559
  var y;
106548
106560
 
106549
106561
  if(titleSide === 'top') {
106550
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
106562
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
106551
106563
  gs.t + 3 + fontSize * 0.75;
106552
106564
  } else {
106553
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
106565
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
106554
106566
  gs.t - 3 - fontSize * 0.25;
106555
106567
  }
106556
106568
  drawTitle(ax._id + 'title', {
@@ -106589,7 +106601,7 @@ function drawColorBar(g, opts, gd) {
106589
106601
  // squish the axis top to make room for the title
106590
106602
  var titleGroup = g.select('.' + cn.cbtitle);
106591
106603
  var titleText = titleGroup.select('text');
106592
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
106604
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
106593
106605
  var mathJaxNode = titleGroup
106594
106606
  .select('.h' + ax._id + 'title-math-group')
106595
106607
  .node();
@@ -106661,7 +106673,7 @@ function drawColorBar(g, opts, gd) {
106661
106673
  // Colorbar cannot currently support opacities so we
106662
106674
  // use an opaque fill even when alpha channels present
106663
106675
  var fillEl = d3.select(this).attr({
106664
- x: xLeft,
106676
+ x: uPx,
106665
106677
  width: Math.max(thickPx, 2),
106666
106678
  y: d3.min(z),
106667
106679
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -106685,7 +106697,7 @@ function drawColorBar(g, opts, gd) {
106685
106697
  lines.exit().remove();
106686
106698
  lines.each(function(d) {
106687
106699
  d3.select(this)
106688
- .attr('d', 'M' + xLeft + ',' +
106700
+ .attr('d', 'M' + uPx + ',' +
106689
106701
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
106690
106702
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
106691
106703
  });
@@ -106693,8 +106705,8 @@ function drawColorBar(g, opts, gd) {
106693
106705
  // force full redraw of labels and ticks
106694
106706
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
106695
106707
 
106696
- var shift = xLeft + thickPx +
106697
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
106708
+ var shift = uPx + thickPx +
106709
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
106698
106710
 
106699
106711
  var vals = Axes.calcTicks(ax);
106700
106712
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -106719,9 +106731,9 @@ function drawColorBar(g, opts, gd) {
106719
106731
  // TODO: why are we redrawing multiple times now with this?
106720
106732
  // I guess autoMargin doesn't like being post-promise?
106721
106733
  function positionCB() {
106722
- var innerWidth = thickPx + opts.outlinewidth / 2;
106734
+ var innerThickness = thickPx + outlinewidth / 2;
106723
106735
  if(ax.ticklabelposition.indexOf('inside') === -1) {
106724
- innerWidth += Drawing.bBox(axLayer.node()).width;
106736
+ innerThickness += Drawing.bBox(axLayer.node()).width;
106725
106737
  }
106726
106738
 
106727
106739
  titleEl = titleCont.select('text');
@@ -106736,66 +106748,65 @@ function drawColorBar(g, opts, gd) {
106736
106748
  // (except for top/bottom mathjax, above)
106737
106749
  // but the weird gs.l is because the titleunshift
106738
106750
  // transform gets removed by Drawing.bBox
106739
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
106751
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
106740
106752
  }
106741
- innerWidth = Math.max(innerWidth, titleWidth);
106753
+ innerThickness = Math.max(innerThickness, titleWidth);
106742
106754
  }
106743
106755
 
106744
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
106745
- var outerheight = yBottomPx - yTopPx;
106756
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
106746
106757
 
106747
106758
  g.select('.' + cn.cbbg).attr({
106748
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
106749
- y: yTopPx - yExtraPx,
106750
- width: Math.max(outerwidth, 2),
106751
- height: Math.max(outerheight + 2 * yExtraPx, 2)
106759
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
106760
+ y: vPx - lenPx - yExtraPx,
106761
+ width: Math.max(outerThickness, 2),
106762
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
106752
106763
  })
106753
106764
  .call(Color.fill, opts.bgcolor)
106754
106765
  .call(Color.stroke, opts.bordercolor)
106755
- .style('stroke-width', opts.borderwidth);
106766
+ .style('stroke-width', borderwidth);
106756
106767
 
106757
106768
  g.selectAll('.' + cn.cboutline).attr({
106758
- x: xLeft,
106759
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
106769
+ x: uPx,
106770
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
106760
106771
  width: Math.max(thickPx, 2),
106761
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
106772
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
106762
106773
  })
106763
106774
  .call(Color.stroke, opts.outlinecolor)
106764
106775
  .style({
106765
106776
  fill: 'none',
106766
- 'stroke-width': opts.outlinewidth
106777
+ 'stroke-width': outlinewidth
106767
106778
  });
106768
106779
 
106769
106780
  // fix positioning for xanchor!='left'
106770
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
106781
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
106771
106782
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
106772
106783
 
106773
106784
  // auto margin adjustment
106774
106785
  var marginOpts = {};
106775
- var tFrac = FROM_TL[opts.yanchor];
106776
- var bFrac = FROM_BR[opts.yanchor];
106777
- if(opts.lenmode === 'pixels') {
106778
- marginOpts.y = opts.y;
106779
- marginOpts.t = outerheight * tFrac;
106780
- marginOpts.b = outerheight * bFrac;
106786
+ var tFrac = FROM_TL[yanchor];
106787
+ var bFrac = FROM_BR[yanchor];
106788
+ if(lenmode === 'pixels') {
106789
+ marginOpts.y = optsY;
106790
+ marginOpts.t = lenPx * tFrac;
106791
+ marginOpts.b = lenPx * bFrac;
106781
106792
  } else {
106782
106793
  marginOpts.t = marginOpts.b = 0;
106783
- marginOpts.yt = opts.y + opts.len * tFrac;
106784
- marginOpts.yb = opts.y - opts.len * bFrac;
106794
+ marginOpts.yt = optsY + len * tFrac;
106795
+ marginOpts.yb = optsY - len * bFrac;
106785
106796
  }
106786
106797
 
106787
- var lFrac = FROM_TL[opts.xanchor];
106788
- var rFrac = FROM_BR[opts.xanchor];
106789
- if(opts.thicknessmode === 'pixels') {
106790
- marginOpts.x = opts.x;
106791
- marginOpts.l = outerwidth * lFrac;
106792
- marginOpts.r = outerwidth * rFrac;
106798
+ var lFrac = FROM_TL[xanchor];
106799
+ var rFrac = FROM_BR[xanchor];
106800
+ if(thicknessmode === 'pixels') {
106801
+ marginOpts.x = optsX;
106802
+ marginOpts.l = outerThickness * lFrac;
106803
+ marginOpts.r = outerThickness * rFrac;
106793
106804
  } else {
106794
- var extraThickness = outerwidth - thickPx;
106805
+ var extraThickness = outerThickness - thickPx;
106795
106806
  marginOpts.l = extraThickness * lFrac;
106796
106807
  marginOpts.r = extraThickness * rFrac;
106797
- marginOpts.xl = opts.x - opts.thickness * lFrac;
106798
- marginOpts.xr = opts.x + opts.thickness * rFrac;
106808
+ marginOpts.xl = optsX - thickness * lFrac;
106809
+ marginOpts.xr = optsX + thickness * rFrac;
106799
106810
  }
106800
106811
 
106801
106812
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -106826,9 +106837,9 @@ function makeEditable(g, opts, gd) {
106826
106837
  moveFn: function(dx, dy) {
106827
106838
  g.attr('transform', t0 + strTranslate(dx, dy));
106828
106839
 
106829
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
106840
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
106830
106841
  0, 1, opts.xanchor);
106831
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
106842
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
106832
106843
  0, 1, opts.yanchor);
106833
106844
 
106834
106845
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -111530,11 +111541,13 @@ var cartesianScatterPoints = {
111530
111541
  // The actual rendering is done by private function _hover.
111531
111542
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
111532
111543
  gd = Lib.getGraphDiv(gd);
111533
-
111544
+ // The 'target' property changes when bubbling out of Shadow DOM.
111545
+ // Throttling can delay reading the target, so we save the current value.
111546
+ var eventTarget = evt.target;
111534
111547
  Lib.throttle(
111535
111548
  gd._fullLayout._uid + constants.HOVERID,
111536
111549
  constants.HOVERMINTIME,
111537
- function() { _hover(gd, evt, subplot, noHoverEvent); }
111550
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
111538
111551
  );
111539
111552
  };
111540
111553
 
@@ -111699,7 +111712,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
111699
111712
  };
111700
111713
 
111701
111714
  // The actual implementation is here:
111702
- function _hover(gd, evt, subplot, noHoverEvent) {
111715
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
111703
111716
  if(!subplot) subplot = 'xy';
111704
111717
 
111705
111718
  // if the user passed in an array of subplots,
@@ -111818,7 +111831,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
111818
111831
  // [x|y]px: the pixels (from top left) of the mouse location
111819
111832
  // on the currently selected plot area
111820
111833
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
111821
- var hasUserCalledHover = !evt.target;
111834
+ var hasUserCalledHover = !eventTarget;
111822
111835
  var xpx, ypx;
111823
111836
 
111824
111837
  if(hasUserCalledHover) {
@@ -111835,13 +111848,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
111835
111848
  return;
111836
111849
  }
111837
111850
 
111838
- // Discover event target, traversing open shadow roots.
111839
- var target = evt.composedPath && evt.composedPath()[0];
111840
- if(!target) {
111841
- // Fallback for browsers not supporting composedPath
111842
- target = evt.target;
111843
- }
111844
- var dbb = target.getBoundingClientRect();
111851
+ var dbb = eventTarget.getBoundingClientRect();
111845
111852
 
111846
111853
  xpx = evt.clientX - dbb.left;
111847
111854
  ypx = evt.clientY - dbb.top;
@@ -112289,15 +112296,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
112289
112296
  if(!helpers.isUnifiedHover(hovermode)) {
112290
112297
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
112291
112298
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
112292
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
112299
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
112293
112300
  // we should improve the "fx" API so other plots can use it without these hack.
112294
- if(evt.target && evt.target.tagName) {
112301
+ if(eventTarget && eventTarget.tagName) {
112295
112302
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
112296
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
112303
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
112297
112304
  }
112298
112305
 
112299
112306
  // don't emit events if called manually
112300
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
112307
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
112301
112308
 
112302
112309
  if(oldhoverdata) {
112303
112310
  gd.emit('plotly_unhover', {
@@ -223420,7 +223427,7 @@ function getSortFunc(opts, d2c) {
223420
223427
  'use strict';
223421
223428
 
223422
223429
  // package version injected by `npm run preprocess`
223423
- exports.version = '2.6.2';
223430
+ exports.version = '2.6.3';
223424
223431
 
223425
223432
  },{}],1119:[function(_dereq_,module,exports){
223426
223433
  (function (global){(function (){