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 (mapbox) v2.6.2
2
+ * plotly.js (mapbox) v2.6.3
3
3
  * Copyright 2012-2021, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -69226,6 +69226,19 @@ function makeColorBarData(gd) {
69226
69226
  }
69227
69227
 
69228
69228
  function drawColorBar(g, opts, gd) {
69229
+ var len = opts.len;
69230
+ var lenmode = opts.lenmode;
69231
+ var thickness = opts.thickness;
69232
+ var thicknessmode = opts.thicknessmode;
69233
+ var outlinewidth = opts.outlinewidth;
69234
+ var borderwidth = opts.borderwidth;
69235
+ var xanchor = opts.xanchor;
69236
+ var yanchor = opts.yanchor;
69237
+ var xpad = opts.xpad;
69238
+ var ypad = opts.ypad;
69239
+ var optsX = opts.x;
69240
+ var optsY = opts.y;
69241
+
69229
69242
  var fullLayout = gd._fullLayout;
69230
69243
  var gs = fullLayout._size;
69231
69244
 
@@ -69255,42 +69268,41 @@ function drawColorBar(g, opts, gd) {
69255
69268
  // when the colorbar itself is pushing the margins.
69256
69269
  // but then the fractional size is calculated based on the
69257
69270
  // actual graph size, so that the axes will size correctly.
69258
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
69271
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
69259
69272
  var thickFrac = thickPx / gs.w;
69260
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
69273
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
69261
69274
  var lenFrac = lenPx / gs.h;
69262
- var xpadFrac = opts.xpad / gs.w;
69263
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
69264
- var ypadFrac = opts.ypad / gs.h;
69275
+ var xpadFrac = xpad / gs.w;
69276
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
69277
+ var ypadFrac = ypad / gs.h;
69265
69278
 
69266
69279
  // x positioning: do it initially just for left anchor,
69267
69280
  // then fix at the end (since we don't know the width yet)
69268
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
69281
+ var uPx = Math.round(optsX * gs.w + xpad);
69269
69282
  // for dragging... this is getting a little muddled...
69270
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
69283
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
69271
69284
 
69272
69285
  // y positioning we can do correctly from the start
69273
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
69274
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
69275
- var yTopPx = yBottomPx - lenPx;
69286
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
69287
+ var vPx = Math.round(gs.h * (1 - vFrac));
69276
69288
 
69277
69289
  // stash a few things for makeEditable
69278
69290
  opts._lenFrac = lenFrac;
69279
69291
  opts._thickFrac = thickFrac;
69280
- opts._xLeftFrac = xLeftFrac;
69281
- opts._yBottomFrac = yBottomFrac;
69292
+ opts._uFrac = uFrac;
69293
+ opts._vFrac = vFrac;
69282
69294
 
69283
69295
  // stash mocked axis for contour label formatting
69284
69296
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
69285
69297
 
69286
69298
  // position can't go in through supplyDefaults
69287
69299
  // because that restricts it to [0,1]
69288
- ax.position = opts.x + xpadFrac + thickFrac;
69300
+ ax.position = optsX + xpadFrac + thickFrac;
69289
69301
 
69290
69302
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
69291
69303
  ax.title.side = titleSide;
69292
- ax.titlex = opts.x + xpadFrac;
69293
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
69304
+ ax.titlex = optsX + xpadFrac;
69305
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
69294
69306
  }
69295
69307
 
69296
69308
  if(line.color && opts.tickmode === 'auto') {
@@ -69298,7 +69310,7 @@ function drawColorBar(g, opts, gd) {
69298
69310
  ax.tick0 = levelsIn.start;
69299
69311
  var dtick = levelsIn.size;
69300
69312
  // expand if too many contours, so we don't get too many ticks
69301
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
69313
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
69302
69314
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
69303
69315
  if(dtFactor > 1) {
69304
69316
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -69316,8 +69328,8 @@ function drawColorBar(g, opts, gd) {
69316
69328
  // set domain after init, because we may want to
69317
69329
  // allow it outside [0,1]
69318
69330
  ax.domain = [
69319
- yBottomFrac + ypadFrac,
69320
- yBottomFrac + lenFrac - ypadFrac
69331
+ vFrac + ypadFrac,
69332
+ vFrac + lenFrac - ypadFrac
69321
69333
  ];
69322
69334
 
69323
69335
  ax.setScale();
@@ -69358,15 +69370,15 @@ function drawColorBar(g, opts, gd) {
69358
69370
  // draw the title so we know how much room it needs
69359
69371
  // when we squish the axis. This one only applies to
69360
69372
  // top or bottom titles, not right side.
69361
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
69373
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
69362
69374
  var fontSize = ax.title.font.size;
69363
69375
  var y;
69364
69376
 
69365
69377
  if(titleSide === 'top') {
69366
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
69378
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
69367
69379
  gs.t + 3 + fontSize * 0.75;
69368
69380
  } else {
69369
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
69381
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
69370
69382
  gs.t - 3 - fontSize * 0.25;
69371
69383
  }
69372
69384
  drawTitle(ax._id + 'title', {
@@ -69405,7 +69417,7 @@ function drawColorBar(g, opts, gd) {
69405
69417
  // squish the axis top to make room for the title
69406
69418
  var titleGroup = g.select('.' + cn.cbtitle);
69407
69419
  var titleText = titleGroup.select('text');
69408
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
69420
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
69409
69421
  var mathJaxNode = titleGroup
69410
69422
  .select('.h' + ax._id + 'title-math-group')
69411
69423
  .node();
@@ -69477,7 +69489,7 @@ function drawColorBar(g, opts, gd) {
69477
69489
  // Colorbar cannot currently support opacities so we
69478
69490
  // use an opaque fill even when alpha channels present
69479
69491
  var fillEl = d3.select(this).attr({
69480
- x: xLeft,
69492
+ x: uPx,
69481
69493
  width: Math.max(thickPx, 2),
69482
69494
  y: d3.min(z),
69483
69495
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -69501,7 +69513,7 @@ function drawColorBar(g, opts, gd) {
69501
69513
  lines.exit().remove();
69502
69514
  lines.each(function(d) {
69503
69515
  d3.select(this)
69504
- .attr('d', 'M' + xLeft + ',' +
69516
+ .attr('d', 'M' + uPx + ',' +
69505
69517
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
69506
69518
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
69507
69519
  });
@@ -69509,8 +69521,8 @@ function drawColorBar(g, opts, gd) {
69509
69521
  // force full redraw of labels and ticks
69510
69522
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
69511
69523
 
69512
- var shift = xLeft + thickPx +
69513
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
69524
+ var shift = uPx + thickPx +
69525
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
69514
69526
 
69515
69527
  var vals = Axes.calcTicks(ax);
69516
69528
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -69535,9 +69547,9 @@ function drawColorBar(g, opts, gd) {
69535
69547
  // TODO: why are we redrawing multiple times now with this?
69536
69548
  // I guess autoMargin doesn't like being post-promise?
69537
69549
  function positionCB() {
69538
- var innerWidth = thickPx + opts.outlinewidth / 2;
69550
+ var innerThickness = thickPx + outlinewidth / 2;
69539
69551
  if(ax.ticklabelposition.indexOf('inside') === -1) {
69540
- innerWidth += Drawing.bBox(axLayer.node()).width;
69552
+ innerThickness += Drawing.bBox(axLayer.node()).width;
69541
69553
  }
69542
69554
 
69543
69555
  titleEl = titleCont.select('text');
@@ -69552,66 +69564,65 @@ function drawColorBar(g, opts, gd) {
69552
69564
  // (except for top/bottom mathjax, above)
69553
69565
  // but the weird gs.l is because the titleunshift
69554
69566
  // transform gets removed by Drawing.bBox
69555
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
69567
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
69556
69568
  }
69557
- innerWidth = Math.max(innerWidth, titleWidth);
69569
+ innerThickness = Math.max(innerThickness, titleWidth);
69558
69570
  }
69559
69571
 
69560
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
69561
- var outerheight = yBottomPx - yTopPx;
69572
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
69562
69573
 
69563
69574
  g.select('.' + cn.cbbg).attr({
69564
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
69565
- y: yTopPx - yExtraPx,
69566
- width: Math.max(outerwidth, 2),
69567
- height: Math.max(outerheight + 2 * yExtraPx, 2)
69575
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
69576
+ y: vPx - lenPx - yExtraPx,
69577
+ width: Math.max(outerThickness, 2),
69578
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
69568
69579
  })
69569
69580
  .call(Color.fill, opts.bgcolor)
69570
69581
  .call(Color.stroke, opts.bordercolor)
69571
- .style('stroke-width', opts.borderwidth);
69582
+ .style('stroke-width', borderwidth);
69572
69583
 
69573
69584
  g.selectAll('.' + cn.cboutline).attr({
69574
- x: xLeft,
69575
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
69585
+ x: uPx,
69586
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
69576
69587
  width: Math.max(thickPx, 2),
69577
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
69588
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
69578
69589
  })
69579
69590
  .call(Color.stroke, opts.outlinecolor)
69580
69591
  .style({
69581
69592
  fill: 'none',
69582
- 'stroke-width': opts.outlinewidth
69593
+ 'stroke-width': outlinewidth
69583
69594
  });
69584
69595
 
69585
69596
  // fix positioning for xanchor!='left'
69586
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
69597
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
69587
69598
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
69588
69599
 
69589
69600
  // auto margin adjustment
69590
69601
  var marginOpts = {};
69591
- var tFrac = FROM_TL[opts.yanchor];
69592
- var bFrac = FROM_BR[opts.yanchor];
69593
- if(opts.lenmode === 'pixels') {
69594
- marginOpts.y = opts.y;
69595
- marginOpts.t = outerheight * tFrac;
69596
- marginOpts.b = outerheight * bFrac;
69602
+ var tFrac = FROM_TL[yanchor];
69603
+ var bFrac = FROM_BR[yanchor];
69604
+ if(lenmode === 'pixels') {
69605
+ marginOpts.y = optsY;
69606
+ marginOpts.t = lenPx * tFrac;
69607
+ marginOpts.b = lenPx * bFrac;
69597
69608
  } else {
69598
69609
  marginOpts.t = marginOpts.b = 0;
69599
- marginOpts.yt = opts.y + opts.len * tFrac;
69600
- marginOpts.yb = opts.y - opts.len * bFrac;
69610
+ marginOpts.yt = optsY + len * tFrac;
69611
+ marginOpts.yb = optsY - len * bFrac;
69601
69612
  }
69602
69613
 
69603
- var lFrac = FROM_TL[opts.xanchor];
69604
- var rFrac = FROM_BR[opts.xanchor];
69605
- if(opts.thicknessmode === 'pixels') {
69606
- marginOpts.x = opts.x;
69607
- marginOpts.l = outerwidth * lFrac;
69608
- marginOpts.r = outerwidth * rFrac;
69614
+ var lFrac = FROM_TL[xanchor];
69615
+ var rFrac = FROM_BR[xanchor];
69616
+ if(thicknessmode === 'pixels') {
69617
+ marginOpts.x = optsX;
69618
+ marginOpts.l = outerThickness * lFrac;
69619
+ marginOpts.r = outerThickness * rFrac;
69609
69620
  } else {
69610
- var extraThickness = outerwidth - thickPx;
69621
+ var extraThickness = outerThickness - thickPx;
69611
69622
  marginOpts.l = extraThickness * lFrac;
69612
69623
  marginOpts.r = extraThickness * rFrac;
69613
- marginOpts.xl = opts.x - opts.thickness * lFrac;
69614
- marginOpts.xr = opts.x + opts.thickness * rFrac;
69624
+ marginOpts.xl = optsX - thickness * lFrac;
69625
+ marginOpts.xr = optsX + thickness * rFrac;
69615
69626
  }
69616
69627
 
69617
69628
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -69642,9 +69653,9 @@ function makeEditable(g, opts, gd) {
69642
69653
  moveFn: function(dx, dy) {
69643
69654
  g.attr('transform', t0 + strTranslate(dx, dy));
69644
69655
 
69645
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
69656
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
69646
69657
  0, 1, opts.xanchor);
69647
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
69658
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
69648
69659
  0, 1, opts.yanchor);
69649
69660
 
69650
69661
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -74346,11 +74357,13 @@ var cartesianScatterPoints = {
74346
74357
  // The actual rendering is done by private function _hover.
74347
74358
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
74348
74359
  gd = Lib.getGraphDiv(gd);
74349
-
74360
+ // The 'target' property changes when bubbling out of Shadow DOM.
74361
+ // Throttling can delay reading the target, so we save the current value.
74362
+ var eventTarget = evt.target;
74350
74363
  Lib.throttle(
74351
74364
  gd._fullLayout._uid + constants.HOVERID,
74352
74365
  constants.HOVERMINTIME,
74353
- function() { _hover(gd, evt, subplot, noHoverEvent); }
74366
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
74354
74367
  );
74355
74368
  };
74356
74369
 
@@ -74515,7 +74528,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
74515
74528
  };
74516
74529
 
74517
74530
  // The actual implementation is here:
74518
- function _hover(gd, evt, subplot, noHoverEvent) {
74531
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
74519
74532
  if(!subplot) subplot = 'xy';
74520
74533
 
74521
74534
  // if the user passed in an array of subplots,
@@ -74634,7 +74647,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
74634
74647
  // [x|y]px: the pixels (from top left) of the mouse location
74635
74648
  // on the currently selected plot area
74636
74649
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
74637
- var hasUserCalledHover = !evt.target;
74650
+ var hasUserCalledHover = !eventTarget;
74638
74651
  var xpx, ypx;
74639
74652
 
74640
74653
  if(hasUserCalledHover) {
@@ -74651,13 +74664,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
74651
74664
  return;
74652
74665
  }
74653
74666
 
74654
- // Discover event target, traversing open shadow roots.
74655
- var target = evt.composedPath && evt.composedPath()[0];
74656
- if(!target) {
74657
- // Fallback for browsers not supporting composedPath
74658
- target = evt.target;
74659
- }
74660
- var dbb = target.getBoundingClientRect();
74667
+ var dbb = eventTarget.getBoundingClientRect();
74661
74668
 
74662
74669
  xpx = evt.clientX - dbb.left;
74663
74670
  ypx = evt.clientY - dbb.top;
@@ -75105,15 +75112,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
75105
75112
  if(!helpers.isUnifiedHover(hovermode)) {
75106
75113
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
75107
75114
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
75108
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
75115
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
75109
75116
  // we should improve the "fx" API so other plots can use it without these hack.
75110
- if(evt.target && evt.target.tagName) {
75117
+ if(eventTarget && eventTarget.tagName) {
75111
75118
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
75112
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
75119
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
75113
75120
  }
75114
75121
 
75115
75122
  // don't emit events if called manually
75116
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
75123
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
75117
75124
 
75118
75125
  if(oldhoverdata) {
75119
75126
  gd.emit('plotly_unhover', {
@@ -129495,7 +129502,7 @@ function getSortFunc(opts, d2c) {
129495
129502
  'use strict';
129496
129503
 
129497
129504
  // package version injected by `npm run preprocess`
129498
- exports.version = '2.6.2';
129505
+ exports.version = '2.6.3';
129499
129506
 
129500
129507
  },{}]},{},[9])(9)
129501
129508
  });