1
1
/**
2
- * plotly.js (basic) v2.3.0
2
+ * plotly.js (basic) v2.3.1
3
3
* Copyright 2012-2021, Plotly, Inc.
4
4
* All rights reserved.
5
5
* Licensed under the MIT license
@@ -27808,7 +27808,7 @@ function _hover(gd, evt, subplot, noHoverEvent) {
27808
27808
}
27809
27809
27810
27810
function hoverDataKey(d) {
27811
- return [d.trace.index, d.index, d.x0, d.y0, d.name, d.attr, d.xa, d.ya || ''].join(',');
27811
+ return [d.trace.index, d.index, d.x0, d.y0, d.name, d.attr, d.xa ? d.xa._id : '' , d.ya ? d.ya._id : ''].join(',');
27812
27812
}
27813
27813
27814
27814
var EXTRA_STRING_REGEX = /<extra>([\s\S]*)<\/extra>/;
@@ -28996,13 +28996,32 @@ function getCoord(axLetter, winningPoint, fullLayout) {
28996
28996
var ax = winningPoint[axLetter + 'a'];
28997
28997
var val = winningPoint[axLetter + 'Val'];
28998
28998
28999
+ var cd0 = winningPoint.cd[0];
29000
+
28999
29001
if(ax.type === 'category') val = ax._categoriesMap[val];
29000
29002
else if(ax.type === 'date') {
29001
- var period = winningPoint[axLetter + 'Period'];
29002
- val = ax.d2c(period !== undefined ? period : val);
29003
+ var periodalignment = winningPoint.trace[axLetter + 'periodalignment'];
29004
+ if(periodalignment) {
29005
+ var d = winningPoint.cd[winningPoint.index];
29006
+
29007
+ var start = d[axLetter + 'Start'];
29008
+ if(start === undefined) start = d[axLetter];
29009
+
29010
+ var end = d[axLetter + 'End'];
29011
+ if(end === undefined) end = d[axLetter];
29012
+
29013
+ var diff = end - start;
29014
+
29015
+ if(periodalignment === 'end') {
29016
+ val += diff;
29017
+ } else if(periodalignment === 'middle') {
29018
+ val += diff / 2;
29019
+ }
29020
+ }
29021
+
29022
+ val = ax.d2c(val);
29003
29023
}
29004
29024
29005
- var cd0 = winningPoint.cd[winningPoint.index];
29006
29025
if(cd0 && cd0.t && cd0.t.posLetter === ax._id) {
29007
29026
if(
29008
29027
fullLayout.boxmode === 'group' ||
@@ -73497,7 +73516,7 @@ var calcSelection = _dereq_('../scatter/calc_selection');
73497
73516
module.exports = function calc(gd, trace) {
73498
73517
var xa = Axes.getFromId(gd, trace.xaxis || 'x');
73499
73518
var ya = Axes.getFromId(gd, trace.yaxis || 'y');
73500
- var size, pos, origPos, pObj, hasPeriod;
73519
+ var size, pos, origPos, pObj, hasPeriod, pLetter ;
73501
73520
73502
73521
var sizeOpts = {
73503
73522
msUTC: !!(trace.base || trace.base === 0)
@@ -73508,11 +73527,13 @@ module.exports = function calc(gd, trace) {
73508
73527
origPos = ya.makeCalcdata(trace, 'y');
73509
73528
pObj = alignPeriod(trace, ya, 'y', origPos);
73510
73529
hasPeriod = !!trace.yperiodalignment;
73530
+ pLetter = 'y';
73511
73531
} else {
73512
73532
size = ya.makeCalcdata(trace, 'y', sizeOpts);
73513
73533
origPos = xa.makeCalcdata(trace, 'x');
73514
73534
pObj = alignPeriod(trace, xa, 'x', origPos);
73515
73535
hasPeriod = !!trace.xperiodalignment;
73536
+ pLetter = 'x';
73516
73537
}
73517
73538
pos = pObj.vals;
73518
73539
@@ -73526,8 +73547,8 @@ module.exports = function calc(gd, trace) {
73526
73547
73527
73548
if(hasPeriod) {
73528
73549
cd[i].orig_p = origPos[i]; // used by hover
73529
- cd[i].pEnd = pObj.ends[i];
73530
- cd[i].pStart = pObj.starts[i];
73550
+ cd[i][pLetter + 'End'] = pObj.ends[i];
73551
+ cd[i][pLetter + 'Start'] = pObj.starts[i];
73531
73552
}
73532
73553
73533
73554
if(trace.ids) {
@@ -74009,20 +74030,12 @@ function setBarCenterAndWidth(pa, sieve) {
74009
74030
var barwidth = t.barwidth;
74010
74031
var barwidthIsArray = Array.isArray(barwidth);
74011
74032
74012
- var trace = calcTrace[0].trace;
74013
- var isPeriod = !!trace[pLetter + 'periodalignment'];
74014
-
74015
74033
for(var j = 0; j < calcTrace.length; j++) {
74016
74034
var calcBar = calcTrace[j];
74017
74035
74018
74036
// store the actual bar width and position, for use by hover
74019
74037
var width = calcBar.w = barwidthIsArray ? barwidth[j] : barwidth;
74020
74038
calcBar[pLetter] = calcBar.p + (poffsetIsArray ? poffset[j] : poffset) + width / 2;
74021
-
74022
- if(isPeriod) {
74023
- calcBar.wPeriod =
74024
- calcBar.pEnd - calcBar.pStart;
74025
- }
74026
74039
}
74027
74040
}
74028
74041
}
@@ -74678,18 +74691,26 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
74678
74691
}
74679
74692
74680
74693
var period = trace[posLetter + 'period'];
74694
+ var isClosestOrPeriod = isClosest || period;
74681
74695
74682
74696
function thisBarMinPos(di) { return thisBarExtPos(di, -1); }
74683
74697
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }
74684
74698
74685
74699
function thisBarExtPos(di, sgn) {
74686
- var w = (period) ? di.wPeriod : di.w;
74700
+ var w = di.w;
74687
74701
74688
74702
return di[posLetter] + sgn * w / 2;
74689
74703
}
74690
74704
74691
- var minPos = isClosest || period ?
74692
- thisBarMinPos :
74705
+ function periodLength(di) {
74706
+ return di[posLetter + 'End'] - di[posLetter + 'Start'];
74707
+ }
74708
+
74709
+ var minPos = isClosest ?
74710
+ thisBarMinPos : period ?
74711
+ function(di) {
74712
+ return di.p - periodLength(di) / 2;
74713
+ } :
74693
74714
function(di) {
74694
74715
/*
74695
74716
* In compare mode, accept a bar if you're on it *or* its group.
@@ -74706,8 +74727,11 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
74706
74727
return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2);
74707
74728
};
74708
74729
74709
- var maxPos = isClosest || period ?
74710
- thisBarMaxPos :
74730
+ var maxPos = isClosest ?
74731
+ thisBarMaxPos : period ?
74732
+ function(di) {
74733
+ return di.p + periodLength(di) / 2;
74734
+ } :
74711
74735
function(di) {
74712
74736
return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2);
74713
74737
};
@@ -74782,7 +74806,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
74782
74806
// if we get here and we're not in 'closest' mode, push min/max pos back
74783
74807
// onto the group - even though that means occasionally the mouse will be
74784
74808
// over the hover label.
74785
- if(!isClosest ) {
74809
+ if(!isClosestOrPeriod ) {
74786
74810
minPos = function(di) {
74787
74811
return Math.min(thisBarMinPos(di), di.p - t.bargroupwidth / 2);
74788
74812
};
@@ -74805,9 +74829,6 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
74805
74829
74806
74830
var hasPeriod = di.orig_p !== undefined;
74807
74831
pointData[posLetter + 'LabelVal'] = hasPeriod ? di.orig_p : di.p;
74808
- if(hasPeriod) {
74809
- pointData[posLetter + 'Period'] = di.p;
74810
- }
74811
74832
74812
74833
pointData.labelLabel = hoverLabelText(pa, pointData[posLetter + 'LabelVal'], trace[posLetter + 'hoverformat']);
74813
74834
pointData.valueLabel = hoverLabelText(sa, pointData[sizeLetter + 'LabelVal'], trace[sizeLetter + 'hoverformat']);
@@ -79308,9 +79329,6 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
79308
79329
hovertemplate: trace.hovertemplate
79309
79330
});
79310
79331
79311
- if(trace.xperiodalignment === 'end') pointData.xPeriod = di.x;
79312
- if(trace.yperiodalignment === 'end') pointData.yPeriod = di.y;
79313
-
79314
79332
fillText(di, trace, pointData);
79315
79333
Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData);
79316
79334
@@ -82079,7 +82097,7 @@ function getSortFunc(opts, d2c) {
82079
82097
'use strict';
82080
82098
82081
82099
// package version injected by `npm run preprocess`
82082
- exports.version = '2.3.0 ';
82100
+ exports.version = '2.3.1 ';
82083
82101
82084
82102
},{}]},{},[8])(8)
82085
82103
});
0 commit comments