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/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/dist/README.md +19 -19
- package/dist/plotly-basic.js +85 -78
- package/dist/plotly-basic.min.js +2 -2
- package/dist/plotly-cartesian.js +85 -78
- package/dist/plotly-cartesian.min.js +2 -2
- package/dist/plotly-finance.js +85 -78
- package/dist/plotly-finance.min.js +2 -2
- package/dist/plotly-geo-assets.js +2 -2
- package/dist/plotly-geo.js +85 -78
- package/dist/plotly-geo.min.js +4 -4
- package/dist/plotly-gl2d.js +85 -78
- package/dist/plotly-gl2d.min.js +2 -2
- package/dist/plotly-gl3d.js +85 -78
- package/dist/plotly-gl3d.min.js +8 -8
- package/dist/plotly-mapbox.js +85 -78
- package/dist/plotly-mapbox.min.js +2 -2
- package/dist/plotly-strict.js +85 -78
- package/dist/plotly-strict.min.js +2 -2
- package/dist/plotly-with-meta.js +85 -78
- package/dist/plotly.js +85 -78
- package/dist/plotly.min.js +2 -2
- package/package.json +1 -1
- package/src/components/colorbar/draw.js +72 -61
- package/src/components/fx/hover.js +11 -15
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -167,6 +167,19 @@ function makeColorBarData(gd) {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function drawColorBar(g, opts, gd) {
|
|
170
|
+
var len = opts.len;
|
|
171
|
+
var lenmode = opts.lenmode;
|
|
172
|
+
var thickness = opts.thickness;
|
|
173
|
+
var thicknessmode = opts.thicknessmode;
|
|
174
|
+
var outlinewidth = opts.outlinewidth;
|
|
175
|
+
var borderwidth = opts.borderwidth;
|
|
176
|
+
var xanchor = opts.xanchor;
|
|
177
|
+
var yanchor = opts.yanchor;
|
|
178
|
+
var xpad = opts.xpad;
|
|
179
|
+
var ypad = opts.ypad;
|
|
180
|
+
var optsX = opts.x;
|
|
181
|
+
var optsY = opts.y;
|
|
182
|
+
|
|
170
183
|
var fullLayout = gd._fullLayout;
|
|
171
184
|
var gs = fullLayout._size;
|
|
172
185
|
|
|
@@ -196,42 +209,41 @@ function drawColorBar(g, opts, gd) {
|
|
|
196
209
|
// when the colorbar itself is pushing the margins.
|
|
197
210
|
// but then the fractional size is calculated based on the
|
|
198
211
|
// actual graph size, so that the axes will size correctly.
|
|
199
|
-
var thickPx = Math.round(
|
|
212
|
+
var thickPx = Math.round(thickness * (thicknessmode === 'fraction' ? gs.w : 1));
|
|
200
213
|
var thickFrac = thickPx / gs.w;
|
|
201
|
-
var lenPx = Math.round(
|
|
214
|
+
var lenPx = Math.round(len * (lenmode === 'fraction' ? gs.h : 1));
|
|
202
215
|
var lenFrac = lenPx / gs.h;
|
|
203
|
-
var xpadFrac =
|
|
204
|
-
var yExtraPx = (
|
|
205
|
-
var ypadFrac =
|
|
216
|
+
var xpadFrac = xpad / gs.w;
|
|
217
|
+
var yExtraPx = (borderwidth + outlinewidth) / 2;
|
|
218
|
+
var ypadFrac = ypad / gs.h;
|
|
206
219
|
|
|
207
220
|
// x positioning: do it initially just for left anchor,
|
|
208
221
|
// then fix at the end (since we don't know the width yet)
|
|
209
|
-
var
|
|
222
|
+
var uPx = Math.round(optsX * gs.w + xpad);
|
|
210
223
|
// for dragging... this is getting a little muddled...
|
|
211
|
-
var
|
|
224
|
+
var uFrac = optsX - thickFrac * ({center: 0.5, right: 1}[xanchor] || 0);
|
|
212
225
|
|
|
213
226
|
// y positioning we can do correctly from the start
|
|
214
|
-
var
|
|
215
|
-
var
|
|
216
|
-
var yTopPx = yBottomPx - lenPx;
|
|
227
|
+
var vFrac = optsY + lenFrac * (({top: -0.5, bottom: 0.5}[yanchor] || 0) - 0.5);
|
|
228
|
+
var vPx = Math.round(gs.h * (1 - vFrac));
|
|
217
229
|
|
|
218
230
|
// stash a few things for makeEditable
|
|
219
231
|
opts._lenFrac = lenFrac;
|
|
220
232
|
opts._thickFrac = thickFrac;
|
|
221
|
-
opts.
|
|
222
|
-
opts.
|
|
233
|
+
opts._uFrac = uFrac;
|
|
234
|
+
opts._vFrac = vFrac;
|
|
223
235
|
|
|
224
236
|
// stash mocked axis for contour label formatting
|
|
225
237
|
var ax = opts._axis = mockColorBarAxis(gd, opts, zrange);
|
|
226
238
|
|
|
227
239
|
// position can't go in through supplyDefaults
|
|
228
240
|
// because that restricts it to [0,1]
|
|
229
|
-
ax.position =
|
|
241
|
+
ax.position = optsX + xpadFrac + thickFrac;
|
|
230
242
|
|
|
231
243
|
if(['top', 'bottom'].indexOf(titleSide) !== -1) {
|
|
232
244
|
ax.title.side = titleSide;
|
|
233
|
-
ax.titlex =
|
|
234
|
-
ax.titley =
|
|
245
|
+
ax.titlex = optsX + xpadFrac;
|
|
246
|
+
ax.titley = vFrac + (title.side === 'top' ? lenFrac - ypadFrac : ypadFrac);
|
|
235
247
|
}
|
|
236
248
|
|
|
237
249
|
if(line.color && opts.tickmode === 'auto') {
|
|
@@ -239,7 +251,7 @@ function drawColorBar(g, opts, gd) {
|
|
|
239
251
|
ax.tick0 = levelsIn.start;
|
|
240
252
|
var dtick = levelsIn.size;
|
|
241
253
|
// expand if too many contours, so we don't get too many ticks
|
|
242
|
-
var autoNtick = Lib.constrain(
|
|
254
|
+
var autoNtick = Lib.constrain(lenPx / 50, 4, 15) + 1;
|
|
243
255
|
var dtFactor = (zrange[1] - zrange[0]) / ((opts.nticks || autoNtick) * dtick);
|
|
244
256
|
if(dtFactor > 1) {
|
|
245
257
|
var dtexp = Math.pow(10, Math.floor(Math.log(dtFactor) / Math.LN10));
|
|
@@ -257,8 +269,8 @@ function drawColorBar(g, opts, gd) {
|
|
|
257
269
|
// set domain after init, because we may want to
|
|
258
270
|
// allow it outside [0,1]
|
|
259
271
|
ax.domain = [
|
|
260
|
-
|
|
261
|
-
|
|
272
|
+
vFrac + ypadFrac,
|
|
273
|
+
vFrac + lenFrac - ypadFrac
|
|
262
274
|
];
|
|
263
275
|
|
|
264
276
|
ax.setScale();
|
|
@@ -299,15 +311,15 @@ function drawColorBar(g, opts, gd) {
|
|
|
299
311
|
// draw the title so we know how much room it needs
|
|
300
312
|
// when we squish the axis. This one only applies to
|
|
301
313
|
// top or bottom titles, not right side.
|
|
302
|
-
var x = gs.l + (
|
|
314
|
+
var x = gs.l + (optsX + xpadFrac) * gs.w;
|
|
303
315
|
var fontSize = ax.title.font.size;
|
|
304
316
|
var y;
|
|
305
317
|
|
|
306
318
|
if(titleSide === 'top') {
|
|
307
|
-
y = (1 - (
|
|
319
|
+
y = (1 - (vFrac + lenFrac - ypadFrac)) * gs.h +
|
|
308
320
|
gs.t + 3 + fontSize * 0.75;
|
|
309
321
|
} else {
|
|
310
|
-
y = (1 - (
|
|
322
|
+
y = (1 - (vFrac + ypadFrac)) * gs.h +
|
|
311
323
|
gs.t - 3 - fontSize * 0.25;
|
|
312
324
|
}
|
|
313
325
|
drawTitle(ax._id + 'title', {
|
|
@@ -346,7 +358,7 @@ function drawColorBar(g, opts, gd) {
|
|
|
346
358
|
// squish the axis top to make room for the title
|
|
347
359
|
var titleGroup = g.select('.' + cn.cbtitle);
|
|
348
360
|
var titleText = titleGroup.select('text');
|
|
349
|
-
var titleTrans = [-
|
|
361
|
+
var titleTrans = [-outlinewidth / 2, outlinewidth / 2];
|
|
350
362
|
var mathJaxNode = titleGroup
|
|
351
363
|
.select('.h' + ax._id + 'title-math-group')
|
|
352
364
|
.node();
|
|
@@ -418,7 +430,7 @@ function drawColorBar(g, opts, gd) {
|
|
|
418
430
|
// Colorbar cannot currently support opacities so we
|
|
419
431
|
// use an opaque fill even when alpha channels present
|
|
420
432
|
var fillEl = d3.select(this).attr({
|
|
421
|
-
x:
|
|
433
|
+
x: uPx,
|
|
422
434
|
width: Math.max(thickPx, 2),
|
|
423
435
|
y: d3.min(z),
|
|
424
436
|
height: Math.max(d3.max(z) - d3.min(z), 2),
|
|
@@ -442,7 +454,7 @@ function drawColorBar(g, opts, gd) {
|
|
|
442
454
|
lines.exit().remove();
|
|
443
455
|
lines.each(function(d) {
|
|
444
456
|
d3.select(this)
|
|
445
|
-
.attr('d', 'M' +
|
|
457
|
+
.attr('d', 'M' + uPx + ',' +
|
|
446
458
|
(Math.round(ax.c2p(d)) + (line.width / 2) % 1) + 'h' + thickPx)
|
|
447
459
|
.call(Drawing.lineGroupStyle, line.width, lineColormap(d), line.dash);
|
|
448
460
|
});
|
|
@@ -450,8 +462,8 @@ function drawColorBar(g, opts, gd) {
|
|
|
450
462
|
// force full redraw of labels and ticks
|
|
451
463
|
axLayer.selectAll('g.' + ax._id + 'tick,path').remove();
|
|
452
464
|
|
|
453
|
-
var shift =
|
|
454
|
-
(
|
|
465
|
+
var shift = uPx + thickPx +
|
|
466
|
+
(outlinewidth || 0) / 2 - (opts.ticks === 'outside' ? 1 : 0);
|
|
455
467
|
|
|
456
468
|
var vals = Axes.calcTicks(ax);
|
|
457
469
|
var tickSign = Axes.getTickSigns(ax)[2];
|
|
@@ -476,9 +488,9 @@ function drawColorBar(g, opts, gd) {
|
|
|
476
488
|
// TODO: why are we redrawing multiple times now with this?
|
|
477
489
|
// I guess autoMargin doesn't like being post-promise?
|
|
478
490
|
function positionCB() {
|
|
479
|
-
var
|
|
491
|
+
var innerThickness = thickPx + outlinewidth / 2;
|
|
480
492
|
if(ax.ticklabelposition.indexOf('inside') === -1) {
|
|
481
|
-
|
|
493
|
+
innerThickness += Drawing.bBox(axLayer.node()).width;
|
|
482
494
|
}
|
|
483
495
|
|
|
484
496
|
titleEl = titleCont.select('text');
|
|
@@ -493,66 +505,65 @@ function drawColorBar(g, opts, gd) {
|
|
|
493
505
|
// (except for top/bottom mathjax, above)
|
|
494
506
|
// but the weird gs.l is because the titleunshift
|
|
495
507
|
// transform gets removed by Drawing.bBox
|
|
496
|
-
titleWidth = Drawing.bBox(titleCont.node()).right -
|
|
508
|
+
titleWidth = Drawing.bBox(titleCont.node()).right - uPx - gs.l;
|
|
497
509
|
}
|
|
498
|
-
|
|
510
|
+
innerThickness = Math.max(innerThickness, titleWidth);
|
|
499
511
|
}
|
|
500
512
|
|
|
501
|
-
var
|
|
502
|
-
var outerheight = yBottomPx - yTopPx;
|
|
513
|
+
var outerThickness = 2 * xpad + innerThickness + borderwidth + outlinewidth / 2;
|
|
503
514
|
|
|
504
515
|
g.select('.' + cn.cbbg).attr({
|
|
505
|
-
x:
|
|
506
|
-
y:
|
|
507
|
-
width: Math.max(
|
|
508
|
-
height: Math.max(
|
|
516
|
+
x: uPx - xpad - (borderwidth + outlinewidth) / 2,
|
|
517
|
+
y: vPx - lenPx - yExtraPx,
|
|
518
|
+
width: Math.max(outerThickness, 2),
|
|
519
|
+
height: Math.max(lenPx + 2 * yExtraPx, 2)
|
|
509
520
|
})
|
|
510
521
|
.call(Color.fill, opts.bgcolor)
|
|
511
522
|
.call(Color.stroke, opts.bordercolor)
|
|
512
|
-
.style('stroke-width',
|
|
523
|
+
.style('stroke-width', borderwidth);
|
|
513
524
|
|
|
514
525
|
g.selectAll('.' + cn.cboutline).attr({
|
|
515
|
-
x:
|
|
516
|
-
y:
|
|
526
|
+
x: uPx,
|
|
527
|
+
y: vPx - lenPx + ypad + (titleSide === 'top' ? titleHeight : 0),
|
|
517
528
|
width: Math.max(thickPx, 2),
|
|
518
|
-
height: Math.max(
|
|
529
|
+
height: Math.max(lenPx - 2 * ypad - titleHeight, 2)
|
|
519
530
|
})
|
|
520
531
|
.call(Color.stroke, opts.outlinecolor)
|
|
521
532
|
.style({
|
|
522
533
|
fill: 'none',
|
|
523
|
-
'stroke-width':
|
|
534
|
+
'stroke-width': outlinewidth
|
|
524
535
|
});
|
|
525
536
|
|
|
526
537
|
// fix positioning for xanchor!='left'
|
|
527
|
-
var xoffset = ({center: 0.5, right: 1}[
|
|
538
|
+
var xoffset = ({center: 0.5, right: 1}[xanchor] || 0) * outerThickness;
|
|
528
539
|
g.attr('transform', strTranslate(gs.l - xoffset, gs.t));
|
|
529
540
|
|
|
530
541
|
// auto margin adjustment
|
|
531
542
|
var marginOpts = {};
|
|
532
|
-
var tFrac = FROM_TL[
|
|
533
|
-
var bFrac = FROM_BR[
|
|
534
|
-
if(
|
|
535
|
-
marginOpts.y =
|
|
536
|
-
marginOpts.t =
|
|
537
|
-
marginOpts.b =
|
|
543
|
+
var tFrac = FROM_TL[yanchor];
|
|
544
|
+
var bFrac = FROM_BR[yanchor];
|
|
545
|
+
if(lenmode === 'pixels') {
|
|
546
|
+
marginOpts.y = optsY;
|
|
547
|
+
marginOpts.t = lenPx * tFrac;
|
|
548
|
+
marginOpts.b = lenPx * bFrac;
|
|
538
549
|
} else {
|
|
539
550
|
marginOpts.t = marginOpts.b = 0;
|
|
540
|
-
marginOpts.yt =
|
|
541
|
-
marginOpts.yb =
|
|
551
|
+
marginOpts.yt = optsY + len * tFrac;
|
|
552
|
+
marginOpts.yb = optsY - len * bFrac;
|
|
542
553
|
}
|
|
543
554
|
|
|
544
|
-
var lFrac = FROM_TL[
|
|
545
|
-
var rFrac = FROM_BR[
|
|
546
|
-
if(
|
|
547
|
-
marginOpts.x =
|
|
548
|
-
marginOpts.l =
|
|
549
|
-
marginOpts.r =
|
|
555
|
+
var lFrac = FROM_TL[xanchor];
|
|
556
|
+
var rFrac = FROM_BR[xanchor];
|
|
557
|
+
if(thicknessmode === 'pixels') {
|
|
558
|
+
marginOpts.x = optsX;
|
|
559
|
+
marginOpts.l = outerThickness * lFrac;
|
|
560
|
+
marginOpts.r = outerThickness * rFrac;
|
|
550
561
|
} else {
|
|
551
|
-
var extraThickness =
|
|
562
|
+
var extraThickness = outerThickness - thickPx;
|
|
552
563
|
marginOpts.l = extraThickness * lFrac;
|
|
553
564
|
marginOpts.r = extraThickness * rFrac;
|
|
554
|
-
marginOpts.xl =
|
|
555
|
-
marginOpts.xr =
|
|
565
|
+
marginOpts.xl = optsX - thickness * lFrac;
|
|
566
|
+
marginOpts.xr = optsX + thickness * rFrac;
|
|
556
567
|
}
|
|
557
568
|
|
|
558
569
|
Plots.autoMargin(gd, opts._id, marginOpts);
|
|
@@ -583,9 +594,9 @@ function makeEditable(g, opts, gd) {
|
|
|
583
594
|
moveFn: function(dx, dy) {
|
|
584
595
|
g.attr('transform', t0 + strTranslate(dx, dy));
|
|
585
596
|
|
|
586
|
-
xf = dragElement.align(opts.
|
|
597
|
+
xf = dragElement.align(opts._uFrac + (dx / gs.w), opts._thickFrac,
|
|
587
598
|
0, 1, opts.xanchor);
|
|
588
|
-
yf = dragElement.align(opts.
|
|
599
|
+
yf = dragElement.align(opts._vFrac - (dy / gs.h), opts._lenFrac,
|
|
589
600
|
0, 1, opts.yanchor);
|
|
590
601
|
|
|
591
602
|
var csr = dragElement.getCursor(xf, yf, opts.xanchor, opts.yanchor);
|
|
@@ -78,11 +78,13 @@ var cartesianScatterPoints = {
|
|
|
78
78
|
// The actual rendering is done by private function _hover.
|
|
79
79
|
exports.hover = function hover(gd, evt, subplot, noHoverEvent) {
|
|
80
80
|
gd = Lib.getGraphDiv(gd);
|
|
81
|
-
|
|
81
|
+
// The 'target' property changes when bubbling out of Shadow DOM.
|
|
82
|
+
// Throttling can delay reading the target, so we save the current value.
|
|
83
|
+
var eventTarget = evt.target;
|
|
82
84
|
Lib.throttle(
|
|
83
85
|
gd._fullLayout._uid + constants.HOVERID,
|
|
84
86
|
constants.HOVERMINTIME,
|
|
85
|
-
function() { _hover(gd, evt, subplot, noHoverEvent); }
|
|
87
|
+
function() { _hover(gd, evt, subplot, noHoverEvent, eventTarget); }
|
|
86
88
|
);
|
|
87
89
|
};
|
|
88
90
|
|
|
@@ -247,7 +249,7 @@ exports.loneHover = function loneHover(hoverItems, opts) {
|
|
|
247
249
|
};
|
|
248
250
|
|
|
249
251
|
// The actual implementation is here:
|
|
250
|
-
function _hover(gd, evt, subplot, noHoverEvent) {
|
|
252
|
+
function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
|
|
251
253
|
if(!subplot) subplot = 'xy';
|
|
252
254
|
|
|
253
255
|
// if the user passed in an array of subplots,
|
|
@@ -366,7 +368,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
|
|
|
366
368
|
// [x|y]px: the pixels (from top left) of the mouse location
|
|
367
369
|
// on the currently selected plot area
|
|
368
370
|
// add pointerX|Y property for drawing the spikes in spikesnap 'cursor' situation
|
|
369
|
-
var hasUserCalledHover = !
|
|
371
|
+
var hasUserCalledHover = !eventTarget;
|
|
370
372
|
var xpx, ypx;
|
|
371
373
|
|
|
372
374
|
if(hasUserCalledHover) {
|
|
@@ -383,13 +385,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
|
|
|
383
385
|
return;
|
|
384
386
|
}
|
|
385
387
|
|
|
386
|
-
|
|
387
|
-
var target = evt.composedPath && evt.composedPath()[0];
|
|
388
|
-
if(!target) {
|
|
389
|
-
// Fallback for browsers not supporting composedPath
|
|
390
|
-
target = evt.target;
|
|
391
|
-
}
|
|
392
|
-
var dbb = target.getBoundingClientRect();
|
|
388
|
+
var dbb = eventTarget.getBoundingClientRect();
|
|
393
389
|
|
|
394
390
|
xpx = evt.clientX - dbb.left;
|
|
395
391
|
ypx = evt.clientY - dbb.top;
|
|
@@ -837,15 +833,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
|
|
|
837
833
|
if(!helpers.isUnifiedHover(hovermode)) {
|
|
838
834
|
hoverAvoidOverlaps(hoverLabels, rotateLabels ? 'xa' : 'ya', fullLayout);
|
|
839
835
|
alignHoverText(hoverLabels, rotateLabels, fullLayout._invScaleX, fullLayout._invScaleY);
|
|
840
|
-
} // TODO: tagName hack is needed to appease geo.js's hack of using
|
|
836
|
+
} // TODO: tagName hack is needed to appease geo.js's hack of using eventTarget=true
|
|
841
837
|
// we should improve the "fx" API so other plots can use it without these hack.
|
|
842
|
-
if(
|
|
838
|
+
if(eventTarget && eventTarget.tagName) {
|
|
843
839
|
var hasClickToShow = Registry.getComponentMethod('annotations', 'hasClickToShow')(gd, newhoverdata);
|
|
844
|
-
overrideCursor(d3.select(
|
|
840
|
+
overrideCursor(d3.select(eventTarget), hasClickToShow ? 'pointer' : '');
|
|
845
841
|
}
|
|
846
842
|
|
|
847
843
|
// don't emit events if called manually
|
|
848
|
-
if(!
|
|
844
|
+
if(!eventTarget || noHoverEvent || !hoverChanged(gd, evt, oldhoverdata)) return;
|
|
849
845
|
|
|
850
846
|
if(oldhoverdata) {
|
|
851
847
|
gd.emit('plotly_unhover', {
|
package/src/version.js
CHANGED