From 2c32827d899fa9e98a84f950a0d737a192b70dae Mon Sep 17 00:00:00 2001 From: deqingli Date: Fri, 29 Nov 2019 20:34:49 +0800 Subject: [PATCH 1/2] fix formatter tooltip can't get value in sankey diagram #11459 --- src/chart/sankey/SankeySeries.js | 11 +++++++++++ test/sankey-vertical.html | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/chart/sankey/SankeySeries.js b/src/chart/sankey/SankeySeries.js index 9feaf3e601..8f58019361 100644 --- a/src/chart/sankey/SankeySeries.js +++ b/src/chart/sankey/SankeySeries.js @@ -138,6 +138,17 @@ var SankeySeries = SeriesModel.extend({ } }, + // Override Series.getDataParams() + getDataParams: function (dataIndex, dataType) { + var params = SankeySeries.superCall(this, 'getDataParams', dataIndex, dataType); + if (!params.value && dataType === 'node') { + var node = this.getGraph().getNodeByIndex(dataIndex); + var nodeValue = node.getLayout().value; + params.value = nodeValue; + } + return params; + }, + defaultOption: { zlevel: 0, z: 2, diff --git a/test/sankey-vertical.html b/test/sankey-vertical.html index f28731ff9a..6962a36bf1 100644 --- a/test/sankey-vertical.html +++ b/test/sankey-vertical.html @@ -173,7 +173,10 @@ color: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'], tooltip: { trigger: 'item', - triggerOn: 'mousemove' + triggerOn: 'mousemove', + formatter: function (params) { + return params.name + ': ' + params.value; + } }, animation: false, series: [ From 22b67585c5639804c727e72e6e1e74889e7ce099 Mon Sep 17 00:00:00 2001 From: deqingli Date: Mon, 2 Dec 2019 13:55:48 +0800 Subject: [PATCH 2/2] fix(sankey): forget to process the special value 0 when getDataParams() in SankeySeries.js --- src/chart/sankey/SankeySeries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/sankey/SankeySeries.js b/src/chart/sankey/SankeySeries.js index 8f58019361..05abf323ac 100644 --- a/src/chart/sankey/SankeySeries.js +++ b/src/chart/sankey/SankeySeries.js @@ -141,7 +141,7 @@ var SankeySeries = SeriesModel.extend({ // Override Series.getDataParams() getDataParams: function (dataIndex, dataType) { var params = SankeySeries.superCall(this, 'getDataParams', dataIndex, dataType); - if (!params.value && dataType === 'node') { + if (params.value == null && dataType === 'node') { var node = this.getGraph().getNodeByIndex(dataIndex); var nodeValue = node.getLayout().value; params.value = nodeValue;