Skip to content

Commit 8432d8f

Browse files
committed
keep waterfall totals hover as is - dont add delta for totals
1 parent 8cca543 commit 8432d8f

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

Diff for: src/traces/waterfall/hover.js

+20-22
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
2828
var vAxis = isHorizontal ? pointData.xa : pointData.ya;
2929

3030
function formatNumber(a) {
31-
return (a === undefined) ? '' : hoverLabelText(vAxis, a);
31+
return hoverLabelText(vAxis, a);
3232
}
3333

3434
// the closest data point
@@ -37,20 +37,16 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
3737

3838
var size = (di.isSum) ? di.b + di.s : di.rawS;
3939

40-
if(di.isSum) {
41-
point.final = undefined;
42-
point.initial = undefined;
43-
point.delta = size - di.b;
44-
} else {
40+
if(!di.isSum) {
4541
point.initial = di.b + di.s - size;
4642
point.delta = size;
4743
point.final = point.initial + point.delta;
48-
}
4944

50-
var v = formatNumber(Math.abs(point.delta));
51-
point.deltaLabel = size < 0 ? '(' + v + ')' : v;
52-
point.finalLabel = formatNumber(point.final);
53-
point.initialLabel = formatNumber(point.initial);
45+
var v = formatNumber(Math.abs(point.delta));
46+
point.deltaLabel = size < 0 ? '(' + v + ')' : v;
47+
point.finalLabel = formatNumber(point.final);
48+
point.initialLabel = formatNumber(point.initial);
49+
}
5450

5551
var hoverinfo = di.hi || trace.hoverinfo;
5652
var text = [];
@@ -60,18 +56,20 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
6056

6157
var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; };
6258

63-
if(hasFlag('final') && point.finalLabel !== '') {
64-
text.push(point.finalLabel);
65-
}
66-
if(hasFlag('delta') && point.deltaLabel !== '') {
67-
if(size < 0) {
68-
text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing);
69-
} else {
70-
text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing);
59+
if(!di.isSum) {
60+
if(hasFlag('final')) {
61+
text.push(point.finalLabel);
62+
}
63+
if(hasFlag('delta')) {
64+
if(size < 0) {
65+
text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing);
66+
} else {
67+
text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing);
68+
}
69+
}
70+
if(hasFlag('initial')) {
71+
text.push('Initial: ' + point.initialLabel);
7172
}
72-
}
73-
if(hasFlag('initial') && point.initialLabel !== '') {
74-
text.push('Initial: ' + point.initialLabel);
7573
}
7674
}
7775

Diff for: test/jasmine/tests/waterfall_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ describe('waterfall hover', function() {
15221522
.then(function() {
15231523
var out = _hover(gd, 0, 1000.5, 'closest');
15241524
expect(out.yLabelVal).toEqual(1002.201);
1525-
expect(out.extraText).toEqual('$2.2m ▲');
1525+
expect(out.extraText).toEqual(undefined);
15261526
expect(out.style).toEqual([0, '#4499FF', 0, 1002.201]);
15271527
})
15281528
.then(function() {
@@ -1534,7 +1534,7 @@ describe('waterfall hover', function() {
15341534
.then(function() {
15351535
var out = _hover(gd, 2, 1000.5, 'closest');
15361536
expect(out.yLabelVal).toEqual(1001.101);
1537-
expect(out.extraText).toEqual('$1.1m ▲');
1537+
expect(out.extraText).toEqual(undefined);
15381538
expect(out.style).toEqual([2, '#4499FF', 2, 1001.101]);
15391539
})
15401540
.then(function() {
@@ -1546,7 +1546,7 @@ describe('waterfall hover', function() {
15461546
.then(function() {
15471547
var out = _hover(gd, 4, 1000.5, 'closest');
15481548
expect(out.yLabelVal).toEqual(1004.401);
1549-
expect(out.extraText).toEqual('$4.4m ▲');
1549+
expect(out.extraText).toEqual(undefined);
15501550
expect(out.style).toEqual([4, '#4499FF', 4, 1004.401]);
15511551
})
15521552
.catch(failTest)

0 commit comments

Comments
 (0)