From 2c60ebb7abb1329fb78e31963b411b4a675465a1 Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 14 Jun 2019 02:52:27 -0400 Subject: [PATCH 1/5] implement hoverinfo & hovertemplate flags i.e. initial, delta & final in waterfall similar to PR 3958 --- src/traces/waterfall/attributes.js | 11 +++- src/traces/waterfall/constants.js | 17 ++++++ src/traces/waterfall/event_data.js | 25 +++++++++ src/traces/waterfall/hover.js | 44 +++++++++++---- src/traces/waterfall/index.js | 2 + test/jasmine/tests/waterfall_test.js | 80 ++++++++++++++++++++++++---- 6 files changed, 160 insertions(+), 19 deletions(-) create mode 100644 src/traces/waterfall/constants.js create mode 100644 src/traces/waterfall/event_data.js diff --git a/src/traces/waterfall/attributes.js b/src/traces/waterfall/attributes.js index a4b8efacc93..08ddfb6bdd2 100644 --- a/src/traces/waterfall/attributes.js +++ b/src/traces/waterfall/attributes.js @@ -10,6 +10,9 @@ var barAttrs = require('../bar/attributes'); var lineAttrs = require('../scatter/attributes').line; +var plotAttrs = require('../../plots/attributes'); +var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes'); +var constants = require('./constants'); var extendFlat = require('../../lib/extend').extendFlat; var Color = require('../../components/color'); @@ -74,7 +77,13 @@ module.exports = { dy: barAttrs.dy, hovertext: barAttrs.hovertext, - hovertemplate: barAttrs.hovertemplate, + hovertemplate: hovertemplateAttrs({}, { + keys: constants.eventDataKeys + }), + + hoverinfo: extendFlat({}, plotAttrs.hoverinfo, { + flags: ['name', 'x', 'y', 'text', 'initial', 'delta', 'final'] + }), textinfo: { valType: 'flaglist', diff --git a/src/traces/waterfall/constants.js b/src/traces/waterfall/constants.js new file mode 100644 index 00000000000..21def0c5a92 --- /dev/null +++ b/src/traces/waterfall/constants.js @@ -0,0 +1,17 @@ +/** +* Copyright 2012-2019, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = { + eventDataKeys: [ + 'initial', + 'delta', + 'final' + ] +}; diff --git a/src/traces/waterfall/event_data.js b/src/traces/waterfall/event_data.js new file mode 100644 index 00000000000..a3a8e308e75 --- /dev/null +++ b/src/traces/waterfall/event_data.js @@ -0,0 +1,25 @@ +/** +* Copyright 2012-2019, Plotly, Inc. +* All rights reserved. +* +* This source code is licensed under the MIT license found in the +* LICENSE file in the root directory of this source tree. +*/ + +'use strict'; + +module.exports = function eventData(out, pt /* , trace, cd, pointNumber */) { + // standard cartesian event data + out.x = 'xVal' in pt ? pt.xVal : pt.x; + out.y = 'yVal' in pt ? pt.yVal : pt.y; + + // for funnel + if('initial' in pt) out.initial = pt.initial; + if('delta' in pt) out.delta = pt.delta; + if('final' in pt) out.final = pt.final; + + if(pt.xa) out.xaxis = pt.xa; + if(pt.ya) out.yaxis = pt.ya; + + return out; +}; diff --git a/src/traces/waterfall/hover.js b/src/traces/waterfall/hover.js index f542765885e..5e95f6952a6 100644 --- a/src/traces/waterfall/hover.js +++ b/src/traces/waterfall/hover.js @@ -38,18 +38,44 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var size = (di.isSum) ? di.b + di.s : di.rawS; if(!di.isSum) { - // format delta numbers: - if(size > 0) { - point.extraText = formatNumber(size) + ' ' + DIRSYMBOL.increasing; - } else if(size < 0) { - point.extraText = '(' + (formatNumber(-size)) + ') ' + DIRSYMBOL.decreasing; - } else { - return; + point.initial = di.b + di.s - size; + point.delta = size; + point.final = point.initial + point.delta; + } else { + point.final = size; + point.initial = di.b; + point.delta = point.final - point.initial; + } + + point.finalLabel = formatNumber(point.final); + point.deltaLabel = formatNumber(Math.abs(point.delta)); + point.initialLabel = formatNumber(point.initial, 1); + + var hoverinfo = di.hi || trace.hoverinfo; + var text = []; + if(hoverinfo && hoverinfo !== 'none' && hoverinfo !== 'skip') { + var isAll = (hoverinfo === 'all'); + var parts = hoverinfo.split('+'); + + var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; }; + + if(hasFlag('final') && point.finalLabel !== '') { + text.push('Final: ' + point.finalLabel); + } + if(hasFlag('delta') && point.deltaLabel !== '') { + if(size < 0) { + text.push('(' + point.deltaLabel + ') ' + DIRSYMBOL.decreasing); + } else { + text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing); + } + } + if(hasFlag('initial') && point.initialLabel !== '') { + text.push('Initial: ' + point.initialLabel); } - // display initial value - point.extraText += '
Initial: ' + formatNumber(di.b + di.s - size); } + if(text.length) point.extraText = text.join('
'); + point.color = getTraceColor(trace, di); return [point]; diff --git a/src/traces/waterfall/index.js b/src/traces/waterfall/index.js index 23da97872e2..73d0a7f8cfd 100644 --- a/src/traces/waterfall/index.js +++ b/src/traces/waterfall/index.js @@ -19,6 +19,8 @@ module.exports = { plot: require('./plot'), style: require('./style').style, hoverPoints: require('./hover'), + eventData: require('./event_data'), + selectPoints: require('../bar/select'), moduleType: 'trace', diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index c48451f2e4e..6f4b5d5b358 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -1379,13 +1379,72 @@ describe('waterfall hover', function() { .then(done); }); + it('should turn off percentages with hoveinfo none or skip', function(done) { + gd = createGraphDiv(); + + var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); + mock.data.forEach(function(t, i) { + t.type = 'waterfall'; + if(i === 0) { + t.hoverinfo = 'none'; + } else { + t.hoverinfo = 'skip'; + } + }); + + function _hover() { + var evt = { xpx: 125, ypx: 150 }; + Fx.hover('graph', evt, 'xy'); + } + + Plotly.plot(gd, mock) + .then(_hover) + .then(function() { + expect(d3.selectAll('g.hovertext').size()).toBe(0); + }) + .catch(failTest) + .then(done); + }); + + it('should turn on percentages with hoveinfo all', function(done) { + gd = createGraphDiv(); + + var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); + mock.data.forEach(function(t) { + t.type = 'waterfall'; + t.base = 1000; + t.hoverinfo = 'all'; + }); + + function _hover() { + var evt = { xpx: 125, ypx: 150 }; + Fx.hover('graph', evt, 'xy'); + } + + Plotly.plot(gd, mock) + .then(_hover) + .then(function() { + assertHoverLabelContent({ + nums: [ + '1001\nHover text A\nFinal: 1001\n1 ▲\nInitial: 1000', + '1002\nHover text G\nFinal: 1002\n2 ▲\nInitial: 1000', + '1,001.5\na (hover)\nFinal: 1,001.5\n1.5 ▲\nInitial: 1000' + ], + name: ['Lines, Marke...', 'Lines and Text', 'missing text'], + axis: '0' + }); + }) + .catch(failTest) + .then(done); + }); + it('should use hovertemplate if specified', function(done) { gd = createGraphDiv(); var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); mock.data.forEach(function(t) { t.type = 'waterfall'; - t.hovertemplate = '%{y}'; + t.hovertemplate = t.hovertemplate = 'Value: %{y}
SUM: %{final}
START: %{initial}
DIFF: %{delta}'; }); function _hover() { @@ -1397,11 +1456,14 @@ describe('waterfall hover', function() { .then(_hover) .then(function() { assertHoverLabelContent({ - nums: ['1', '2', '1.5'], + nums: [ + 'Value: 1\nSUM: 1\nSTART: 0\nDIFF: 1', + 'Value: 2\nSUM: 2\nSTART: 0\nDIFF: 2', + 'Value: 1.5\nSUM: 1.5\nSTART: 0\nDIFF: 1.5' + ], name: ['', '', ''], axis: '0' }); - // return Plotly.restyle(gd, 'text', ['APPLE', 'BANANA', 'ORANGE']); }) .catch(failTest) .then(done); @@ -1424,7 +1486,7 @@ describe('waterfall hover', function() { }) .then(function() { assertHoverLabelContent({ - nums: '2.2\n4.4 ▲\nInitial: −2.2', + nums: '2.2\nFinal: 2.2\n4.4 ▲\nInitial: −2.2', name: '', axis: 'E' }); @@ -1460,31 +1522,31 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 0, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1002.201); - expect(out.extraText).toEqual(undefined); + expect(out.extraText).toEqual('Final: $1,002.201m
$2.2m ▲
Initial: $1,000.001m'); expect(out.style).toEqual([0, '#4499FF', 0, 1002.201]); }) .then(function() { var out = _hover(gd, 1, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual('($1.1m) ▼
Initial: $1,002.201m'); + expect(out.extraText).toEqual('Final: $1,001.101m
($1.1m) ▼
Initial: $1,002.201m'); expect(out.style).toEqual([1, '#FF4136', 1, 1001.101]); }) .then(function() { var out = _hover(gd, 2, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual(undefined); + expect(out.extraText).toEqual('Final: $1,001.101m
$1.1m ▲
Initial: $1,000.001m'); expect(out.style).toEqual([2, '#4499FF', 2, 1001.101]); }) .then(function() { var out = _hover(gd, 3, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual('$3.3m ▲
Initial: $1,001.101m'); + expect(out.extraText).toEqual('Final: $1,004.401m
$3.3m ▲
Initial: $1,001.101m'); expect(out.style).toEqual([3, '#3D9970', 3, 1004.401]); }) .then(function() { var out = _hover(gd, 4, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual(undefined); + expect(out.extraText).toEqual('Final: $1,004.401m
$4.4m ▲
Initial: $1,000.001m'); expect(out.style).toEqual([4, '#4499FF', 4, 1004.401]); }) .catch(failTest) From 8ed6474842a1462cc45413394fb02b54117b79b8 Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 14 Jun 2019 13:59:26 -0400 Subject: [PATCH 2/5] revise waterfall hover formats - remove Final --- src/traces/waterfall/hover.js | 21 +++++++++++---------- test/jasmine/tests/waterfall_test.js | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/traces/waterfall/hover.js b/src/traces/waterfall/hover.js index 5e95f6952a6..2174831bc67 100644 --- a/src/traces/waterfall/hover.js +++ b/src/traces/waterfall/hover.js @@ -28,7 +28,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var vAxis = isHorizontal ? pointData.xa : pointData.ya; function formatNumber(a) { - return hoverLabelText(vAxis, a); + return (a === undefined) ? '' : hoverLabelText(vAxis, a); } // the closest data point @@ -37,19 +37,20 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var size = (di.isSum) ? di.b + di.s : di.rawS; - if(!di.isSum) { + if(di.isSum) { + point.final = undefined; + point.initial = undefined; + point.delta = size - di.b; + } else { point.initial = di.b + di.s - size; point.delta = size; point.final = point.initial + point.delta; - } else { - point.final = size; - point.initial = di.b; - point.delta = point.final - point.initial; } + var v = formatNumber(Math.abs(point.delta)); + point.deltaLabel = size < 0 ? '(' + v + ')' : v; point.finalLabel = formatNumber(point.final); - point.deltaLabel = formatNumber(Math.abs(point.delta)); - point.initialLabel = formatNumber(point.initial, 1); + point.initialLabel = formatNumber(point.initial); var hoverinfo = di.hi || trace.hoverinfo; var text = []; @@ -60,11 +61,11 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; }; if(hasFlag('final') && point.finalLabel !== '') { - text.push('Final: ' + point.finalLabel); + text.push(point.finalLabel); } if(hasFlag('delta') && point.deltaLabel !== '') { if(size < 0) { - text.push('(' + point.deltaLabel + ') ' + DIRSYMBOL.decreasing); + text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing); } else { text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing); } diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index 6f4b5d5b358..696de113043 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -1379,7 +1379,7 @@ describe('waterfall hover', function() { .then(done); }); - it('should turn off percentages with hoveinfo none or skip', function(done) { + it('should turn off hoverinfo flags with hoveinfo none or skip', function(done) { gd = createGraphDiv(); var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); @@ -1406,7 +1406,7 @@ describe('waterfall hover', function() { .then(done); }); - it('should turn on percentages with hoveinfo all', function(done) { + it('should turn on hoverinfo flags with hoveinfo all', function(done) { gd = createGraphDiv(); var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); @@ -1426,9 +1426,9 @@ describe('waterfall hover', function() { .then(function() { assertHoverLabelContent({ nums: [ - '1001\nHover text A\nFinal: 1001\n1 ▲\nInitial: 1000', - '1002\nHover text G\nFinal: 1002\n2 ▲\nInitial: 1000', - '1,001.5\na (hover)\nFinal: 1,001.5\n1.5 ▲\nInitial: 1000' + '1001\nHover text A\n1001\n1 ▲\nInitial: 1000', + '1002\nHover text G\n1002\n2 ▲\nInitial: 1000', + '1,001.5\na (hover)\n1,001.5\n1.5 ▲\nInitial: 1000' ], name: ['Lines, Marke...', 'Lines and Text', 'missing text'], axis: '0' @@ -1486,7 +1486,7 @@ describe('waterfall hover', function() { }) .then(function() { assertHoverLabelContent({ - nums: '2.2\nFinal: 2.2\n4.4 ▲\nInitial: −2.2', + nums: '2.2\n2.2\n4.4 ▲\nInitial: −2.2', name: '', axis: 'E' }); @@ -1522,31 +1522,31 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 0, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1002.201); - expect(out.extraText).toEqual('Final: $1,002.201m
$2.2m ▲
Initial: $1,000.001m'); + expect(out.extraText).toEqual('$2.2m ▲'); expect(out.style).toEqual([0, '#4499FF', 0, 1002.201]); }) .then(function() { var out = _hover(gd, 1, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual('Final: $1,001.101m
($1.1m) ▼
Initial: $1,002.201m'); + expect(out.extraText).toEqual('$1,001.101m
($1.1m) ▼
Initial: $1,002.201m'); expect(out.style).toEqual([1, '#FF4136', 1, 1001.101]); }) .then(function() { var out = _hover(gd, 2, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual('Final: $1,001.101m
$1.1m ▲
Initial: $1,000.001m'); + expect(out.extraText).toEqual('$1.1m ▲'); expect(out.style).toEqual([2, '#4499FF', 2, 1001.101]); }) .then(function() { var out = _hover(gd, 3, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual('Final: $1,004.401m
$3.3m ▲
Initial: $1,001.101m'); + expect(out.extraText).toEqual('$1,004.401m
$3.3m ▲
Initial: $1,001.101m'); expect(out.style).toEqual([3, '#3D9970', 3, 1004.401]); }) .then(function() { var out = _hover(gd, 4, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual('Final: $1,004.401m
$4.4m ▲
Initial: $1,000.001m'); + expect(out.extraText).toEqual('$4.4m ▲'); expect(out.style).toEqual([4, '#4499FF', 4, 1004.401]); }) .catch(failTest) From 8cca5430dda9cd528f81e7044d11db8b8d13df1b Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 14 Jun 2019 14:12:13 -0400 Subject: [PATCH 3/5] edit typo in test --- test/jasmine/tests/waterfall_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index 696de113043..3744162f5da 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -1444,7 +1444,7 @@ describe('waterfall hover', function() { var mock = Lib.extendDeep({}, require('@mocks/text_chart_arrays')); mock.data.forEach(function(t) { t.type = 'waterfall'; - t.hovertemplate = t.hovertemplate = 'Value: %{y}
SUM: %{final}
START: %{initial}
DIFF: %{delta}'; + t.hovertemplate = 'Value: %{y}
SUM: %{final}
START: %{initial}
DIFF: %{delta}'; }); function _hover() { From 8432d8f770d912d90532f151d3abbf07e138ba23 Mon Sep 17 00:00:00 2001 From: archmoj Date: Mon, 17 Jun 2019 11:46:30 -0400 Subject: [PATCH 4/5] keep waterfall totals hover as is - dont add delta for totals --- src/traces/waterfall/hover.js | 42 +++++++++++++--------------- test/jasmine/tests/waterfall_test.js | 6 ++-- 2 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/traces/waterfall/hover.js b/src/traces/waterfall/hover.js index 2174831bc67..af8abd09784 100644 --- a/src/traces/waterfall/hover.js +++ b/src/traces/waterfall/hover.js @@ -28,7 +28,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var vAxis = isHorizontal ? pointData.xa : pointData.ya; function formatNumber(a) { - return (a === undefined) ? '' : hoverLabelText(vAxis, a); + return hoverLabelText(vAxis, a); } // the closest data point @@ -37,20 +37,16 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var size = (di.isSum) ? di.b + di.s : di.rawS; - if(di.isSum) { - point.final = undefined; - point.initial = undefined; - point.delta = size - di.b; - } else { + if(!di.isSum) { point.initial = di.b + di.s - size; point.delta = size; point.final = point.initial + point.delta; - } - var v = formatNumber(Math.abs(point.delta)); - point.deltaLabel = size < 0 ? '(' + v + ')' : v; - point.finalLabel = formatNumber(point.final); - point.initialLabel = formatNumber(point.initial); + var v = formatNumber(Math.abs(point.delta)); + point.deltaLabel = size < 0 ? '(' + v + ')' : v; + point.finalLabel = formatNumber(point.final); + point.initialLabel = formatNumber(point.initial); + } var hoverinfo = di.hi || trace.hoverinfo; var text = []; @@ -60,18 +56,20 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; }; - if(hasFlag('final') && point.finalLabel !== '') { - text.push(point.finalLabel); - } - if(hasFlag('delta') && point.deltaLabel !== '') { - if(size < 0) { - text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing); - } else { - text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing); + if(!di.isSum) { + if(hasFlag('final')) { + text.push(point.finalLabel); + } + if(hasFlag('delta')) { + if(size < 0) { + text.push(point.deltaLabel + ' ' + DIRSYMBOL.decreasing); + } else { + text.push(point.deltaLabel + ' ' + DIRSYMBOL.increasing); + } + } + if(hasFlag('initial')) { + text.push('Initial: ' + point.initialLabel); } - } - if(hasFlag('initial') && point.initialLabel !== '') { - text.push('Initial: ' + point.initialLabel); } } diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index 3744162f5da..2dfad6aa786 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -1522,7 +1522,7 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 0, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1002.201); - expect(out.extraText).toEqual('$2.2m ▲'); + expect(out.extraText).toEqual(undefined); expect(out.style).toEqual([0, '#4499FF', 0, 1002.201]); }) .then(function() { @@ -1534,7 +1534,7 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 2, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual('$1.1m ▲'); + expect(out.extraText).toEqual(undefined); expect(out.style).toEqual([2, '#4499FF', 2, 1001.101]); }) .then(function() { @@ -1546,7 +1546,7 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 4, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual('$4.4m ▲'); + expect(out.extraText).toEqual(undefined); expect(out.style).toEqual([4, '#4499FF', 4, 1004.401]); }) .catch(failTest) From 0a588366201a20d2d90483d19e42f89e06555126 Mon Sep 17 00:00:00 2001 From: archmoj Date: Mon, 17 Jun 2019 12:19:39 -0400 Subject: [PATCH 5/5] waterfall hover - dont display redundant info when both final and y|x present --- src/traces/waterfall/hover.js | 4 +++- test/jasmine/tests/waterfall_test.js | 12 ++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/traces/waterfall/hover.js b/src/traces/waterfall/hover.js index af8abd09784..477c59b8bbb 100644 --- a/src/traces/waterfall/hover.js +++ b/src/traces/waterfall/hover.js @@ -57,7 +57,9 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { var hasFlag = function(flag) { return isAll || parts.indexOf(flag) !== -1; }; if(!di.isSum) { - if(hasFlag('final')) { + if(hasFlag('final') && + (isHorizontal ? !hasFlag('x') : !hasFlag('y')) // don't display redundant info. + ) { text.push(point.finalLabel); } if(hasFlag('delta')) { diff --git a/test/jasmine/tests/waterfall_test.js b/test/jasmine/tests/waterfall_test.js index 2dfad6aa786..20845b600f2 100644 --- a/test/jasmine/tests/waterfall_test.js +++ b/test/jasmine/tests/waterfall_test.js @@ -1426,9 +1426,9 @@ describe('waterfall hover', function() { .then(function() { assertHoverLabelContent({ nums: [ - '1001\nHover text A\n1001\n1 ▲\nInitial: 1000', - '1002\nHover text G\n1002\n2 ▲\nInitial: 1000', - '1,001.5\na (hover)\n1,001.5\n1.5 ▲\nInitial: 1000' + '1001\nHover text A\n1 ▲\nInitial: 1000', + '1002\nHover text G\n2 ▲\nInitial: 1000', + '1,001.5\na (hover)\n1.5 ▲\nInitial: 1000' ], name: ['Lines, Marke...', 'Lines and Text', 'missing text'], axis: '0' @@ -1486,7 +1486,7 @@ describe('waterfall hover', function() { }) .then(function() { assertHoverLabelContent({ - nums: '2.2\n2.2\n4.4 ▲\nInitial: −2.2', + nums: '2.2\n4.4 ▲\nInitial: −2.2', name: '', axis: 'E' }); @@ -1528,7 +1528,7 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 1, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1001.101); - expect(out.extraText).toEqual('$1,001.101m
($1.1m) ▼
Initial: $1,002.201m'); + expect(out.extraText).toEqual('($1.1m) ▼
Initial: $1,002.201m'); expect(out.style).toEqual([1, '#FF4136', 1, 1001.101]); }) .then(function() { @@ -1540,7 +1540,7 @@ describe('waterfall hover', function() { .then(function() { var out = _hover(gd, 3, 1000.5, 'closest'); expect(out.yLabelVal).toEqual(1004.401); - expect(out.extraText).toEqual('$1,004.401m
$3.3m ▲
Initial: $1,001.101m'); + expect(out.extraText).toEqual('$3.3m ▲
Initial: $1,001.101m'); expect(out.style).toEqual([3, '#3D9970', 3, 1004.401]); }) .then(function() {