From 8f881e7d57c2a31307b51c3db953fe5abd3fa892 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Wed, 17 Apr 2024 14:15:45 +0800 Subject: [PATCH] =?UTF-8?q?style(=E5=9B=BE=E8=A1=A8-=E8=B1=A1=E9=99=90?= =?UTF-8?q?=E5=9B=BE):=20=E4=BC=98=E5=8C=96=E8=B1=A1=E9=99=90=E5=9B=BE?= =?UTF-8?q?=E7=9A=84tooltip=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/others/quadrant.ts | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts index 8d584fa688..ffb77ce3c0 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/quadrant.ts @@ -123,7 +123,7 @@ export class Quadrant extends G2PlotChartView { return } const { colorFieldObj, sizeFieldObj, xFieldObj, yFieldObj } = this.getFieldObject(chart) - if (!xFieldObj.id || !yFieldObj.id) { + if (!xFieldObj.id || !yFieldObj.id || yFieldObj.id === xFieldObj.id) { return } const data: any[] = [] @@ -316,14 +316,10 @@ export class Quadrant extends G2PlotChartView { tooltip: false } } - xAxisTitle['show'] = true - yAxisTitle['show'] = true - yAxisExtTitle['show'] = true - tooltipAttr.seriesTooltipFormatter?.push(xAxisTitle) const formatterMap = tooltipAttr.seriesTooltipFormatter ?.filter(i => i.show) .reduce((pre, next) => { - pre[next['originName']] = next + pre[next['seriesId']] = next return pre }, {}) as Record const tooltip: ScatterOptions['tooltip'] = { @@ -339,17 +335,21 @@ export class Quadrant extends G2PlotChartView { originalItems ?.filter(i => i.name !== xAxisTitle['originName']) .forEach(item => { - const formatter = formatterMap[item.name] - if (formatter) { - const value = - formatter.groupType === 'q' - ? valueFormatter(parseFloat(item.value as string), formatter.formatterCfg) - : item.value - const name = isEmpty(formatter.chartShowName) - ? formatter.name - : formatter.chartShowName - result.push({ color: item.color, name, value }) - } + Object.keys(formatterMap).forEach(key => { + if (formatterMap[key]['originName'] === item.name) { + const formatter = formatterMap[key] + if (formatter) { + const value = + formatter.groupType === 'q' + ? valueFormatter(parseFloat(item.value as string), formatter.formatterCfg) + : item.value + const name = isEmpty(formatter.chartShowName) + ? formatter.name + : formatter.chartShowName + result.push({ color: item.color, name, value }) + } + } + }) }) return result }