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 (strict) v2.6.2
2
+ * plotly.js (strict) v2.6.3
3
3
  * Copyright 2012-2021, Plotly, Inc.
4
4
  * All rights reserved.
5
5
  * Licensed under the MIT license
@@ -97132,6 +97132,19 @@ function makeColorBarData(gd) {
97132
97132
  }
97133
97133
 
97134
97134
  function drawColorBar(g, opts, gd) {
97135
+ var len = opts.len;
97136
+ var lenmode = opts.lenmode;
97137
+ var thickness = opts.thickness;
97138
+ var thicknessmode = opts.thicknessmode;
97139
+ var outlinewidth = opts.outlinewidth;
97140
+ var borderwidth = opts.borderwidth;
97141
+ var xanchor = opts.xanchor;
97142
+ var yanchor = opts.yanchor;
97143
+ var xpad = opts.xpad;
97144
+ var ypad = opts.ypad;
97145
+ var optsX = opts.x;
97146
+ var optsY = opts.y;
97147
+
97135
97148
  var fullLayout = gd._fullLayout;
97136
97149
  var gs = fullLayout._size;
97137
97150
 
@@ -97161,42 +97174,41 @@ function drawColorBar(g, opts, gd) {
97161
97174
  // when the colorbar itself is pushing the margins.
97162
97175
  // but then the fractional size is calculated based on the
97163
97176
  // actual graph size, so that the axes will size correctly.
97164
- var thickPx = Math.round(opts.thickness * (opts.thicknessmode === 'fraction' ? gs.w : 1));
97177
+ var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
97165
97178
  var thickFrac = thickPx / gs.w;
97166
- var lenPx = Math.round(opts.len * (opts.lenmode === 'fraction' ? gs.h : 1));
97179
+ var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
97167
97180
  var lenFrac = lenPx / gs.h;
97168
- var xpadFrac = opts.xpad / gs.w;
97169
- var yExtraPx = (opts.borderwidth + opts.outlinewidth) / 2;
97170
- var ypadFrac = opts.ypad / gs.h;
97181
+ var xpadFrac = xpad / gs.w;
97182
+ var yExtraPx = (borderwidth + outlinewidth) / 2;
97183
+ var ypadFrac = ypad / gs.h;
97171
97184
 
97172
97185
  // x positioning: do it initially just for left anchor,
97173
97186
  // then fix at the end (since we don't know the width yet)
97174
- var xLeft = Math.round(opts.x * gs.w + opts.xpad);
97187
+ var uPx = Math.round(optsX * gs.w + xpad);
97175
97188
  // for dragging... this is getting a little muddled...
97176
- var xLeftFrac = opts.x - thickFrac * ({center: 0.5, right: 1}[opts.xanchor] || 0);
97189
+ var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
97177
97190
 
97178
97191
  // y positioning we can do correctly from the start
97179
- var yBottomFrac = opts.y + lenFrac * (({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5);
97180
- var yBottomPx = Math.round(gs.h * (1 - yBottomFrac));
97181
- var yTopPx = yBottomPx - lenPx;
97192
+ var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
97193
+ var vPx = Math.round(gs.h * (1 - vFrac));
97182
97194
 
97183
97195
  // stash a few things for makeEditable
97184
97196
  opts._lenFrac = lenFrac;
97185
97197
  opts._thickFrac = thickFrac;
97186
- opts._xLeftFrac = xLeftFrac;
97187
- opts._yBottomFrac = yBottomFrac;
97198
+ opts._uFrac = uFrac;
97199
+ opts._vFrac = vFrac;
97188
97200
 
97189
97201
  // stash mocked axis for contour label formatting
97190
97202
  var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
97191
97203
 
97192
97204
  // position can't go in through supplyDefaults
97193
97205
  // because that restricts it to [0,1]
97194
- ax.position = opts.x + xpadFrac + thickFrac;
97206
+ ax.position = optsX + xpadFrac + thickFrac;
97195
97207
 
97196
97208
  if(['top', 'bottom'].indexOf(titleSide) !== -1) {
97197
97209
  ax.title.side = titleSide;
97198
- ax.titlex = opts.x + xpadFrac;
97199
- ax.titley = yBottomFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
97210
+ ax.titlex = optsX + xpadFrac;
97211
+ ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
97200
97212
  }
97201
97213
 
97202
97214
  if(line.color && opts.tickmode === 'auto') {
@@ -97204,7 +97216,7 @@ function drawColorBar(g, opts, gd) {
97204
97216
  ax.tick0 = levelsIn.start;
97205
97217
  var dtick = levelsIn.size;
97206
97218
  // expand if too many contours, so we don't get too many ticks
97207
- var autoNtick = Lib.constrain((yBottomPx - yTopPx) / 50, 4, 15) + 1;
97219
+ var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
97208
97220
  var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
97209
97221
  if(dtFactor > 1) {
97210
97222
  var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
@@ -97222,8 +97234,8 @@ function drawColorBar(g, opts, gd) {
97222
97234
  // set domain after init, because we may want to
97223
97235
  // allow it outside [0,1]
97224
97236
  ax.domain = [
97225
- yBottomFrac + ypadFrac,
97226
- yBottomFrac + lenFrac - ypadFrac
97237
+ vFrac + ypadFrac,
97238
+ vFrac + lenFrac - ypadFrac
97227
97239
  ];
97228
97240
 
97229
97241
  ax.setScale();
@@ -97264,15 +97276,15 @@ function drawColorBar(g, opts, gd) {
97264
97276
  // draw the title so we know how much room it needs
97265
97277
  // when we squish the axis. This one only applies to
97266
97278
  // top or bottom titles, not right side.
97267
- var x = gs.l + (opts.x + xpadFrac) * gs.w;
97279
+ var x = gs.l + (optsX + xpadFrac) * gs.w;
97268
97280
  var fontSize = ax.title.font.size;
97269
97281
  var y;
97270
97282
 
97271
97283
  if(titleSide === 'top') {
97272
- y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h +
97284
+ y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
97273
97285
  gs.t + 3 + fontSize * 0.75;
97274
97286
  } else {
97275
- y = (1 - (yBottomFrac + ypadFrac)) * gs.h +
97287
+ y = (1 - (vFrac + ypadFrac)) * gs.h +
97276
97288
  gs.t - 3 - fontSize * 0.25;
97277
97289
  }
97278
97290
  drawTitle(ax._id + 'title', {
@@ -97311,7 +97323,7 @@ function drawColorBar(g, opts, gd) {
97311
97323
  // squish the axis top to make room for the title
97312
97324
  var titleGroup = g.select('.' + cn.cbtitle);
97313
97325
  var titleText = titleGroup.select('text');
97314
- var titleTrans = [-opts.outlinewidth / 2, opts.outlinewidth / 2];
97326
+ var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
97315
97327
  var mathJaxNode = titleGroup
97316
97328
  .select('.h' + ax._id + 'title-math-group')
97317
97329
  .node();
@@ -97383,7 +97395,7 @@ function drawColorBar(g, opts, gd) {
97383
97395
  // Colorbar cannot currently support opacities so we
97384
97396
  // use an opaque fill even when alpha channels present
97385
97397
  var fillEl = d3.select(this).attr({
97386
- x: xLeft,
97398
+ x: uPx,
97387
97399
  width: Math.max(thickPx, 2),
97388
97400
  y: d3.min(z),
97389
97401
  height: Math.max(d3.max(z) - d3.min(z), 2),
@@ -97407,7 +97419,7 @@ function drawColorBar(g, opts, gd) {
97407
97419
  lines.exit().remove();
97408
97420
  lines.each(function(d) {
97409
97421
  d3.select(this)
97410
- .attr('d', 'M' + xLeft + ',' +
97422
+ .attr('d', 'M' + uPx + ',' +
97411
97423
  (Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
97412
97424
  .call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
97413
97425
  });
@@ -97415,8 +97427,8 @@ function drawColorBar(g, opts, gd) {
97415
97427
  // force full redraw of labels and ticks
97416
97428
  axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
97417
97429
 
97418
- var shift = xLeft + thickPx +
97419
- (opts.outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
97430
+ var shift = uPx + thickPx +
97431
+ (outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
97420
97432
 
97421
97433
  var vals = Axes.calcTicks(ax);
97422
97434
  var tickSign = Axes.getTickSigns(ax)[2];
@@ -97441,9 +97453,9 @@ function drawColorBar(g, opts, gd) {
97441
97453
  // TODO: why are we redrawing multiple times now with this?
97442
97454
  // I guess autoMargin doesn't like being post-promise?
97443
97455
  function positionCB() {
97444
- var innerWidth = thickPx + opts.outlinewidth / 2;
97456
+ var innerThickness = thickPx + outlinewidth / 2;
97445
97457
  if(ax.ticklabelposition.indexOf('inside') === -1) {
97446
- innerWidth += Drawing.bBox(axLayer.node()).width;
97458
+ innerThickness += Drawing.bBox(axLayer.node()).width;
97447
97459
  }
97448
97460
 
97449
97461
  titleEl = titleCont.select('text');
@@ -97458,66 +97470,65 @@ function drawColorBar(g, opts, gd) {
97458
97470
  // (except for top/bottom mathjax, above)
97459
97471
  // but the weird gs.l is because the titleunshift
97460
97472
  // transform gets removed by Drawing.bBox
97461
- titleWidth = Drawing.bBox(titleCont.node()).right - xLeft - gs.l;
97473
+ titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
97462
97474
  }
97463
- innerWidth = Math.max(innerWidth, titleWidth);
97475
+ innerThickness = Math.max(innerThickness, titleWidth);
97464
97476
  }
97465
97477
 
97466
- var outerwidth = 2 * opts.xpad + innerWidth + opts.borderwidth + opts.outlinewidth / 2;
97467
- var outerheight = yBottomPx - yTopPx;
97478
+ var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
97468
97479
 
97469
97480
  g.select('.' + cn.cbbg).attr({
97470
- x: xLeft - opts.xpad - (opts.borderwidth + opts.outlinewidth) / 2,
97471
- y: yTopPx - yExtraPx,
97472
- width: Math.max(outerwidth, 2),
97473
- height: Math.max(outerheight + 2 * yExtraPx, 2)
97481
+ x: uPx - xpad - (borderwidth + outlinewidth) / 2,
97482
+ y: vPx - lenPx - yExtraPx,
97483
+ width: Math.max(outerThickness, 2),
97484
+ height: Math.max(lenPx + 2 * yExtraPx, 2)
97474
97485
  })
97475
97486
  .call(Color.fill, opts.bgcolor)
97476
97487
  .call(Color.stroke, opts.bordercolor)
97477
- .style('stroke-width', opts.borderwidth);
97488
+ .style('stroke-width', borderwidth);
97478
97489
 
97479
97490
  g.selectAll('.' + cn.cboutline).attr({
97480
- x: xLeft,
97481
- y: yTopPx + opts.ypad + (titleSide === 'top' ? titleHeight : 0),
97491
+ x: uPx,
97492
+ y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
97482
97493
  width: Math.max(thickPx, 2),
97483
- height: Math.max(outerheight - 2 * opts.ypad - titleHeight, 2)
97494
+ height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
97484
97495
  })
97485
97496
  .call(Color.stroke, opts.outlinecolor)
97486
97497
  .style({
97487
97498
  fill: 'none',
97488
- 'stroke-width': opts.outlinewidth
97499
+ 'stroke-width': outlinewidth
97489
97500
  });
97490
97501
 
97491
97502
  // fix positioning for xanchor!='left'
97492
- var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) * outerwidth;
97503
+ var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
97493
97504
  g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
97494
97505
 
97495
97506
  // auto margin adjustment
97496
97507
  var marginOpts = {};
97497
- var tFrac = FROM_TL[opts.yanchor];
97498
- var bFrac = FROM_BR[opts.yanchor];
97499
- if(opts.lenmode === 'pixels') {
97500
- marginOpts.y = opts.y;
97501
- marginOpts.t = outerheight * tFrac;
97502
- marginOpts.b = outerheight * bFrac;
97508
+ var tFrac = FROM_TL[yanchor];
97509
+ var bFrac = FROM_BR[yanchor];
97510
+ if(lenmode === 'pixels') {
97511
+ marginOpts.y = optsY;
97512
+ marginOpts.t = lenPx * tFrac;
97513
+ marginOpts.b = lenPx * bFrac;
97503
97514
  } else {
97504
97515
  marginOpts.t = marginOpts.b = 0;
97505
- marginOpts.yt = opts.y + opts.len * tFrac;
97506
- marginOpts.yb = opts.y - opts.len * bFrac;
97516
+ marginOpts.yt = optsY + len * tFrac;
97517
+ marginOpts.yb = optsY - len * bFrac;
97507
97518
  }
97508
97519
 
97509
- var lFrac = FROM_TL[opts.xanchor];
97510
- var rFrac = FROM_BR[opts.xanchor];
97511
- if(opts.thicknessmode === 'pixels') {
97512
- marginOpts.x = opts.x;
97513
- marginOpts.l = outerwidth * lFrac;
97514
- marginOpts.r = outerwidth * rFrac;
97520
+ var lFrac = FROM_TL[xanchor];
97521
+ var rFrac = FROM_BR[xanchor];
97522
+ if(thicknessmode === 'pixels') {
97523
+ marginOpts.x = optsX;
97524
+ marginOpts.l = outerThickness * lFrac;
97525
+ marginOpts.r = outerThickness * rFrac;
97515
97526
  } else {
97516
- var extraThickness = outerwidth - thickPx;
97527
+ var extraThickness = outerThickness - thickPx;
97517
97528
  marginOpts.l = extraThickness * lFrac;
97518
97529
  marginOpts.r = extraThickness * rFrac;
97519
- marginOpts.xl = opts.x - opts.thickness * lFrac;
97520
- marginOpts.xr = opts.x + opts.thickness * rFrac;
97530
+ marginOpts.xl = optsX - thickness * lFrac;
97531
+ marginOpts.xr = optsX + thickness * rFrac;
97521
97532
  }
97522
97533
 
97523
97534
  Plots.autoMargin(gd, opts._id, marginOpts);
@@ -97548,9 +97559,9 @@ function makeEditable(g, opts, gd) {
97548
97559
  moveFn: function(dx, dy) {
97549
97560
  g.attr('transform', t0 + strTranslate(dx, dy));
97550
97561
 
97551
- xf = dragElement.align(opts._xLeftFrac + (dx / gs.w), opts._thickFrac,
97562
+ xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
97552
97563
  0, 1, opts.xanchor);
97553
- yf = dragElement.align(opts._yBottomFrac - (dy / gs.h), opts._lenFrac,
97564
+ yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
97554
97565
  0, 1, opts.yanchor);
97555
97566
 
97556
97567
  var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
@@ -102252,11 +102263,13 @@ var cartesianScatterPoints = {
102252
102263
  // The actual rendering is done by private function _hover.
102253
102264
  exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
102254
102265
  gd = Lib.getGraphDiv(gd);
102255
-
102266
+ // The 'target' property changes when bubbling out of Shadow DOM.
102267
+ // Throttling can delay reading the target, so we save the current value.
102268
+ var eventTarget = evt.target;
102256
102269
  Lib.throttle(
102257
102270
  gd._fullLayout._uid + constants.HOVERID,
102258
102271
  constants.HOVERMINTIME,
102259
- function() { _hover(gd, evt, subplot, noHoverEvent); }
102272
+ function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
102260
102273
  );
102261
102274
  };
102262
102275
 
@@ -102421,7 +102434,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
102421
102434
  };
102422
102435
 
102423
102436
  // The actual implementation is here:
102424
- function _hover(gd, evt, subplot, noHoverEvent) {
102437
+ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
102425
102438
  if(!subplot) subplot = 'xy';
102426
102439
 
102427
102440
  // if the user passed in an array of subplots,
@@ -102540,7 +102553,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
102540
102553
  // [x|y]px: the pixels (from top left) of the mouse location
102541
102554
  // on the currently selected plot area
102542
102555
  // add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
102543
- var hasUserCalledHover = !evt.target;
102556
+ var hasUserCalledHover = !eventTarget;
102544
102557
  var xpx, ypx;
102545
102558
 
102546
102559
  if(hasUserCalledHover) {
@@ -102557,13 +102570,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
102557
102570
  return;
102558
102571
  }
102559
102572
 
102560
- // Discover event target, traversing open shadow roots.
102561
- var target = evt.composedPath && evt.composedPath()[0];
102562
- if(!target) {
102563
- // Fallback for browsers not supporting composedPath
102564
- target = evt.target;
102565
- }
102566
- var dbb = target.getBoundingClientRect();
102573
+ var dbb = eventTarget.getBoundingClientRect();
102567
102574
 
102568
102575
  xpx = evt.clientX - dbb.left;
102569
102576
  ypx = evt.clientY - dbb.top;
@@ -103011,15 +103018,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
103011
103018
  if(!helpers.isUnifiedHover(hovermode)) {
103012
103019
  hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
103013
103020
  alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
103014
- } // TODO: tagName hack is needed to appease geo.js's hack of using evt.target=true
103021
+ } // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
103015
103022
  // we should improve the "fx" API so other plots can use it without these hack.
103016
- if(evt.target && evt.target.tagName) {
103023
+ if(eventTarget && eventTarget.tagName) {
103017
103024
  var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
103018
- overrideCursor(d3.select(evt.target), hasClickToShow ? 'pointer' : '');
103025
+ overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
103019
103026
  }
103020
103027
 
103021
103028
  // don't emit events if called manually
103022
- if(!evt.target || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
103029
+ if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
103023
103030
 
103024
103031
  if(oldhoverdata) {
103025
103032
  gd.emit('plotly_unhover', {
@@ -207696,7 +207703,7 @@ function getSortFunc(opts, d2c) {
207696
207703
  'use strict';
207697
207704
 
207698
207705
  // package version injected by `npm run preprocess`
207699
- exports.version = '2.6.2';
207706
+ exports.version = '2.6.3';
207700
207707
 
207701
207708
  },{}],933:[function(_dereq_,module,exports){
207702
207709
  (function (global){(function (){