From 763c3e24e9a94e78d4e6b75fdeb031f2e94c3521 Mon Sep 17 00:00:00 2001 From: junjun Date: Mon, 8 Aug 2022 11:32:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E8=A7=86=E5=9B=BE):=20=E5=A0=86=E5=8F=A0?= =?UTF-8?q?=E5=9B=BElabel=EF=BC=8Ctooltip=E5=81=B6=E5=B0=94=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/chart/chart/common/common_antv.js | 37 ++++++++++++++----- frontend/src/views/chart/view/ChartEdit.vue | 4 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/frontend/src/views/chart/chart/common/common_antv.js b/frontend/src/views/chart/chart/common/common_antv.js index e4635f9735..f7676efa51 100644 --- a/frontend/src/views/chart/chart/common/common_antv.js +++ b/frontend/src/views/chart/chart/common/common_antv.js @@ -143,15 +143,24 @@ export function getLabel(chart) { yAxis = JSON.parse(JSON.stringify(chart.yaxis)) } - for (let i = 0; i < yAxis.length; i++) { - const f = yAxis[i] - if (f.name === param.category) { - if (f.formatterCfg) { - res = valueFormatter(param.value, f.formatterCfg) - } else { - res = valueFormatter(param.value, formatterItem) + if (chart.type === 'bar-stack' || chart.type === 'line-stack') { + const f = yAxis[0] + if (f.formatterCfg) { + res = valueFormatter(param.value, f.formatterCfg) + } else { + res = valueFormatter(param.value, formatterItem) + } + } else { + for (let i = 0; i < yAxis.length; i++) { + const f = yAxis[i] + if (f.name === param.category) { + if (f.formatterCfg) { + res = valueFormatter(param.value, f.formatterCfg) + } else { + res = valueFormatter(param.value, formatterItem) + } + break } - break } } return res @@ -187,7 +196,15 @@ export function getTooltip(chart) { } let obj - if (chart.type === 'word-cloud') { + if (chart.type === 'bar-stack' || chart.type === 'line-stack') { + obj = { name: param.category, value: param.value } + const f = yAxis[0] + if (f.formatterCfg) { + res = valueFormatter(param.value, f.formatterCfg) + } else { + res = valueFormatter(param.value, formatterItem) + } + } else if (chart.type === 'word-cloud') { obj = { name: param.text, value: param.value } for (let i = 0; i < yAxis.length; i++) { const f = yAxis[i] @@ -217,7 +234,7 @@ export function getTooltip(chart) { res = valueFormatter(param.value, formatterItem) } } - } else if (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar')) { + } else if (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar') || chart.type.includes('area')) { obj = { name: param.category, value: param.value } for (let i = 0; i < yAxis.length; i++) { const f = yAxis[i] diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 24ee19851e..b6f5ad0761 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -1660,7 +1660,9 @@ export default { view.type === 'treemap' || view.type === 'liquid' || view.type === 'word-cloud' || - view.type === 'waterfall') { + view.type === 'waterfall' || + view.type === 'bar-stack' || + view.type === 'line-stack') { if (view.yaxis.length > 1) { view.yaxis.splice(1, view.yaxis.length) }