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 (gl2d) v2.6.2
2
+ * plotly.js (gl2d) v2.6.3
3
3
  * Copyright 2012-2021, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -35425,6 +35425,19 @@ function makeColorBarData(gd) {
35425
35425
  }
35426
35426
 
35427
35427
  function drawColorBar(g, opts, gd) {
35428
+ var len = opts.len;
35429
+ var lenmode = opts.lenmode;
35430
+ var thickness = opts.thickness;
35431
+ var thicknessmode = opts.thicknessmode;
35432
+ var outlinewidth = opts.outlinewidth;
35433
+ var borderwidth = opts.borderwidth;
35434
+ var xanchor = opts.xanchor;
35435
+ var yanchor = opts.yanchor;
35436
+ var xpad = opts.xpad;
35437
+ var ypad = opts.ypad;
35438
+ var optsX = opts.x;
35439
+ var optsY = opts.y;
35440
+
35428
35441
  var fullLayout = gd._fullLayout;
35429
35442
  var gs = fullLayout._size;
35430
35443
 
@@ -35454,42 +35467,41 @@ function drawColorBar(g, opts, gd) {
35454
35467
  // when the colorbar itself is pushing the margins.
35455
35468
  // but then the fractional size is calculated based on the
35456
35469
  // actual graph size, so that the axes will size correctly.
35457
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
35470
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
35458
35471
  var thickFrac = thickPx / gs.w;
35459
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
35472
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
35460
35473
  var lenFrac = lenPx / gs.h;
35461
- var xpadFrac = opts.xpad / gs.w;
35462
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
35463
- var ypadFrac = opts.ypad / gs.h;
35474
+ var xpadFrac = xpad / gs.w;
35475
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
35476
+ var ypadFrac = ypad / gs.h;
35464
35477
 
35465
35478
  // x positioning: do it initially just for left anchor,
35466
35479
  // then fix at the end (since we don't know the width yet)
35467
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
35480
+ var uPx = Math.round(optsX * gs.w + xpad);
35468
35481
  // for dragging... this is getting a little muddled...
35469
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
35482
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
35470
35483
 
35471
35484
  // y positioning we can do correctly from the start
35472
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
35473
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
35474
- var yTopPx = yBottomPx - lenPx;
35485
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
35486
+ var vPx = Math.round(gs.h * (1 - vFrac));
35475
35487
 
35476
35488
  // stash a few things for makeEditable
35477
35489
  opts._lenFrac = lenFrac;
35478
35490
  opts._thickFrac = thickFrac;
35479
- opts._xLeftFrac = xLeftFrac;
35480
- opts._yBottomFrac = yBottomFrac;
35491
+ opts._uFrac = uFrac;
35492
+ opts._vFrac = vFrac;
35481
35493
 
35482
35494
  // stash mocked axis for contour label formatting
35483
35495
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
35484
35496
 
35485
35497
  // position can't go in through supplyDefaults
35486
35498
  // because that restricts it to [0,1]
35487
- ax.position = opts.x + xpadFrac + thickFrac;
35499
+ ax.position = optsX + xpadFrac + thickFrac;
35488
35500
 
35489
35501
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
35490
35502
  ax.title.side = titleSide;
35491
- ax.titlex = opts.x + xpadFrac;
35492
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
35503
+ ax.titlex = optsX + xpadFrac;
35504
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
35493
35505
  }
35494
35506
 
35495
35507
  if(line.color && opts.tickmode === 'auto') {
@@ -35497,7 +35509,7 @@ function drawColorBar(g, opts, gd) {
35497
35509
  ax.tick0 = levelsIn.start;
35498
35510
  var dtick = levelsIn.size;
35499
35511
  // expand if too many contours, so we don't get too many ticks
35500
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
35512
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
35501
35513
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
35502
35514
  if(dtFactor > 1) {
35503
35515
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -35515,8 +35527,8 @@ function drawColorBar(g, opts, gd) {
35515
35527
  // set domain after init, because we may want to
35516
35528
  // allow it outside [0,1]
35517
35529
  ax.domain = [
35518
- yBottomFrac + ypadFrac,
35519
- yBottomFrac + lenFrac - ypadFrac
35530
+ vFrac + ypadFrac,
35531
+ vFrac + lenFrac - ypadFrac
35520
35532
  ];
35521
35533
 
35522
35534
  ax.setScale();
@@ -35557,15 +35569,15 @@ function drawColorBar(g, opts, gd) {
35557
35569
  // draw the title so we know how much room it needs
35558
35570
  // when we squish the axis. This one only applies to
35559
35571
  // top or bottom titles, not right side.
35560
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
35572
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
35561
35573
  var fontSize = ax.title.font.size;
35562
35574
  var y;
35563
35575
 
35564
35576
  if(titleSide === 'top') {
35565
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
35577
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
35566
35578
  gs.t + 3 + fontSize * 0.75;
35567
35579
  } else {
35568
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
35580
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
35569
35581
  gs.t - 3 - fontSize * 0.25;
35570
35582
  }
35571
35583
  drawTitle(ax._id + 'title', {
@@ -35604,7 +35616,7 @@ function drawColorBar(g, opts, gd) {
35604
35616
  // squish the axis top to make room for the title
35605
35617
  var titleGroup = g.select('.' + cn.cbtitle);
35606
35618
  var titleText = titleGroup.select('text');
35607
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
35619
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
35608
35620
  var mathJaxNode = titleGroup
35609
35621
  .select('.h' + ax._id + 'title-math-group')
35610
35622
  .node();
@@ -35676,7 +35688,7 @@ function drawColorBar(g, opts, gd) {
35676
35688
  // Colorbar cannot currently support opacities so we
35677
35689
  // use an opaque fill even when alpha channels present
35678
35690
  var fillEl = d3.select(this).attr({
35679
- x: xLeft,
35691
+ x: uPx,
35680
35692
  width: Math.max(thickPx, 2),
35681
35693
  y: d3.min(z),
35682
35694
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -35700,7 +35712,7 @@ function drawColorBar(g, opts, gd) {
35700
35712
  lines.exit().remove();
35701
35713
  lines.each(function(d) {
35702
35714
  d3.select(this)
35703
- .attr('d', 'M' + xLeft + ',' +
35715
+ .attr('d', 'M' + uPx + ',' +
35704
35716
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
35705
35717
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
35706
35718
  });
@@ -35708,8 +35720,8 @@ function drawColorBar(g, opts, gd) {
35708
35720
  // force full redraw of labels and ticks
35709
35721
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
35710
35722
 
35711
- var shift = xLeft + thickPx +
35712
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
35723
+ var shift = uPx + thickPx +
35724
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
35713
35725
 
35714
35726
  var vals = Axes.calcTicks(ax);
35715
35727
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -35734,9 +35746,9 @@ function drawColorBar(g, opts, gd) {
35734
35746
  // TODO: why are we redrawing multiple times now with this?
35735
35747
  // I guess autoMargin doesn't like being post-promise?
35736
35748
  function positionCB() {
35737
- var innerWidth = thickPx + opts.outlinewidth / 2;
35749
+ var innerThickness = thickPx + outlinewidth / 2;
35738
35750
  if(ax.ticklabelposition.indexOf('inside') === -1) {
35739
- innerWidth += Drawing.bBox(axLayer.node()).width;
35751
+ innerThickness += Drawing.bBox(axLayer.node()).width;
35740
35752
  }
35741
35753
 
35742
35754
  titleEl = titleCont.select('text');
@@ -35751,66 +35763,65 @@ function drawColorBar(g, opts, gd) {
35751
35763
  // (except for top/bottom mathjax, above)
35752
35764
  // but the weird gs.l is because the titleunshift
35753
35765
  // transform gets removed by Drawing.bBox
35754
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
35766
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
35755
35767
  }
35756
- innerWidth = Math.max(innerWidth, titleWidth);
35768
+ innerThickness = Math.max(innerThickness, titleWidth);
35757
35769
  }
35758
35770
 
35759
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
35760
- var outerheight = yBottomPx - yTopPx;
35771
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
35761
35772
 
35762
35773
  g.select('.' + cn.cbbg).attr({
35763
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
35764
- y: yTopPx - yExtraPx,
35765
- width: Math.max(outerwidth, 2),
35766
- height: Math.max(outerheight + 2 * yExtraPx, 2)
35774
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
35775
+ y: vPx - lenPx - yExtraPx,
35776
+ width: Math.max(outerThickness, 2),
35777
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
35767
35778
  })
35768
35779
  .call(Color.fill, opts.bgcolor)
35769
35780
  .call(Color.stroke, opts.bordercolor)
35770
- .style('stroke-width', opts.borderwidth);
35781
+ .style('stroke-width', borderwidth);
35771
35782
 
35772
35783
  g.selectAll('.' + cn.cboutline).attr({
35773
- x: xLeft,
35774
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
35784
+ x: uPx,
35785
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
35775
35786
  width: Math.max(thickPx, 2),
35776
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
35787
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
35777
35788
  })
35778
35789
  .call(Color.stroke, opts.outlinecolor)
35779
35790
  .style({
35780
35791
  fill: 'none',
35781
- 'stroke-width': opts.outlinewidth
35792
+ 'stroke-width': outlinewidth
35782
35793
  });
35783
35794
 
35784
35795
  // fix positioning for xanchor!='left'
35785
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
35796
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
35786
35797
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
35787
35798
 
35788
35799
  // auto margin adjustment
35789
35800
  var marginOpts = {};
35790
- var tFrac = FROM_TL[opts.yanchor];
35791
- var bFrac = FROM_BR[opts.yanchor];
35792
- if(opts.lenmode === 'pixels') {
35793
- marginOpts.y = opts.y;
35794
- marginOpts.t = outerheight * tFrac;
35795
- marginOpts.b = outerheight * bFrac;
35801
+ var tFrac = FROM_TL[yanchor];
35802
+ var bFrac = FROM_BR[yanchor];
35803
+ if(lenmode === 'pixels') {
35804
+ marginOpts.y = optsY;
35805
+ marginOpts.t = lenPx * tFrac;
35806
+ marginOpts.b = lenPx * bFrac;
35796
35807
  } else {
35797
35808
  marginOpts.t = marginOpts.b = 0;
35798
- marginOpts.yt = opts.y + opts.len * tFrac;
35799
- marginOpts.yb = opts.y - opts.len * bFrac;
35809
+ marginOpts.yt = optsY + len * tFrac;
35810
+ marginOpts.yb = optsY - len * bFrac;
35800
35811
  }
35801
35812
 
35802
- var lFrac = FROM_TL[opts.xanchor];
35803
- var rFrac = FROM_BR[opts.xanchor];
35804
- if(opts.thicknessmode === 'pixels') {
35805
- marginOpts.x = opts.x;
35806
- marginOpts.l = outerwidth * lFrac;
35807
- marginOpts.r = outerwidth * rFrac;
35813
+ var lFrac = FROM_TL[xanchor];
35814
+ var rFrac = FROM_BR[xanchor];
35815
+ if(thicknessmode === 'pixels') {
35816
+ marginOpts.x = optsX;
35817
+ marginOpts.l = outerThickness * lFrac;
35818
+ marginOpts.r = outerThickness * rFrac;
35808
35819
  } else {
35809
- var extraThickness = outerwidth - thickPx;
35820
+ var extraThickness = outerThickness - thickPx;
35810
35821
  marginOpts.l = extraThickness * lFrac;
35811
35822
  marginOpts.r = extraThickness * rFrac;
35812
- marginOpts.xl = opts.x - opts.thickness * lFrac;
35813
- marginOpts.xr = opts.x + opts.thickness * rFrac;
35823
+ marginOpts.xl = optsX - thickness * lFrac;
35824
+ marginOpts.xr = optsX + thickness * rFrac;
35814
35825
  }
35815
35826
 
35816
35827
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -35841,9 +35852,9 @@ function makeEditable(g, opts, gd) {
35841
35852
  moveFn: function(dx, dy) {
35842
35853
  g.attr('transform', t0 + strTranslate(dx, dy));
35843
35854
 
35844
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
35855
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
35845
35856
  0, 1, opts.xanchor);
35846
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
35857
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
35847
35858
  0, 1, opts.yanchor);
35848
35859
 
35849
35860
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -40545,11 +40556,13 @@ var cartesianScatterPoints = {
40545
40556
  // The actual rendering is done by private function _hover.
40546
40557
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
40547
40558
  gd = Lib.getGraphDiv(gd);
40548
-
40559
+ // The 'target' property changes when bubbling out of Shadow DOM.
40560
+ // Throttling can delay reading the target, so we save the current value.
40561
+ var eventTarget = evt.target;
40549
40562
  Lib.throttle(
40550
40563
  gd._fullLayout._uid + constants.HOVERID,
40551
40564
  constants.HOVERMINTIME,
40552
- function() { _hover(gd, evt, subplot, noHoverEvent); }
40565
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
40553
40566
  );
40554
40567
  };
40555
40568
 
@@ -40714,7 +40727,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
40714
40727
  };
40715
40728
 
40716
40729
  // The actual implementation is here:
40717
- function _hover(gd, evt, subplot, noHoverEvent) {
40730
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
40718
40731
  if(!subplot) subplot = 'xy';
40719
40732
 
40720
40733
  // if the user passed in an array of subplots,
@@ -40833,7 +40846,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
40833
40846
  // [x|y]px: the pixels (from top left) of the mouse location
40834
40847
  // on the currently selected plot area
40835
40848
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
40836
- var hasUserCalledHover = !evt.target;
40849
+ var hasUserCalledHover = !eventTarget;
40837
40850
  var xpx, ypx;
40838
40851
 
40839
40852
  if(hasUserCalledHover) {
@@ -40850,13 +40863,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
40850
40863
  return;
40851
40864
  }
40852
40865
 
40853
- // Discover event target, traversing open shadow roots.
40854
- var target = evt.composedPath && evt.composedPath()[0];
40855
- if(!target) {
40856
- // Fallback for browsers not supporting composedPath
40857
- target = evt.target;
40858
- }
40859
- var dbb = target.getBoundingClientRect();
40866
+ var dbb = eventTarget.getBoundingClientRect();
40860
40867
 
40861
40868
  xpx = evt.clientX - dbb.left;
40862
40869
  ypx = evt.clientY - dbb.top;
@@ -41304,15 +41311,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
41304
41311
  if(!helpers.isUnifiedHover(hovermode)) {
41305
41312
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
41306
41313
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
41307
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
41314
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
41308
41315
  // we should improve the "fx" API so other plots can use it without these hack.
41309
- if(evt.target && evt.target.tagName) {
41316
+ if(eventTarget && eventTarget.tagName) {
41310
41317
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
41311
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
41318
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
41312
41319
  }
41313
41320
 
41314
41321
  // don't emit events if called manually
41315
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
41322
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
41316
41323
 
41317
41324
  if(oldhoverdata) {
41318
41325
  gd.emit('plotly_unhover', {
@@ -100553,7 +100560,7 @@ function getSortFunc(opts, d2c) {
100553
100560
  'use strict';
100554
100561
 
100555
100562
  // package version injected by `npm run preprocess`
100556
- exports.version = '2.6.2';
100563
+ exports.version = '2.6.3';
100557
100564
 
100558
100565
  },{}],588:[function(_dereq_,module,exports){
100559
100566
  (function (global){(function (){