From 0afc8c4c08ddf4db9ee9027e5a231c778f72bb08 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Tue, 24 Jun 2025 18:40:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E5=AD=90=E5=BC=B9?= =?UTF-8?q?=E5=9B=BE=E6=8F=90=E7=A4=BA=E4=B8=AD=EF=BC=8C=E5=AE=9E=E9=99=85?= =?UTF-8?q?=E5=80=BC=E4=B8=8E=E7=9B=AE=E6=A0=87=E5=80=BC=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98=20#16308?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/bar/bullet-graph.ts | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bullet-graph.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bullet-graph.ts index 623f7d8ed9..5eb942fcfe 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bullet-graph.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bullet-graph.ts @@ -344,10 +344,21 @@ export class BulletGraph extends G2PlotChartView { const formatterMap = tooltipAttr.seriesTooltipFormatter ?.filter(i => i.show) - .reduce((pre, next, index) => { - const keys = ['measures', 'target', 'ranges'] - if (keys[index]) pre[keys[index]] = next - return pre + .reduce((pre, next, _index) => { + switch (next.axisType) { + case 'yAxis': + pre['measures'] = next + return pre + case 'yAxisExt': + pre['target'] = next + return pre + case 'extBubble': + pre['ranges'] = next + return pre + default: + pre[next.name] = next + return pre + } }, {}) as Record const tooltip = { @@ -358,35 +369,21 @@ export class BulletGraph extends G2PlotChartView { const result = [] const data = options.data.find(item => item.title === originalItems[0].title) - Object.keys(formatterMap).forEach((key, index) => { + Object.keys(formatterMap).forEach((key, _index) => { if (key === '记录数*') return const formatter = formatterMap[key] if (formatter) { if (key !== 'ranges') { - let name = '' - let value = 0 - let color: string | Array = [] - let tFormatter = chart.yAxis[1] - if (index === 0) { - tFormatter = chart.yAxis[0] - value = valueFormatter( - parseFloat(data['measures'] as string), - formatter.formatterCfg - ) - color = bullet.bar['measures'].fill - } - if (index === 1) { - tFormatter = chart.yAxisExt[0] - value = valueFormatter(parseFloat(data['target'] as string), formatter.formatterCfg) - color = bullet.bar['target'].fill - } - name = isEmpty(tFormatter.chartShowName) ? tFormatter.name : tFormatter.chartShowName + const name = isEmpty(formatter.chartShowName) + ? formatter.name + : formatter.chartShowName + const value = valueFormatter(parseFloat(data[key] as string), formatter.formatterCfg) + const color = bullet.bar[key].fill result.push({ color, name, value }) - result.reverse() } else { const ranges = data.ranges const isDynamic = bullet.bar.ranges.showType === 'dynamic'