From ce9dadfd6b5e2e54ae3e4557985977eb4fe33b2b Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Tue, 24 Jun 2025 21:37:59 +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 | 81 ++++++++++--------- 1 file changed, 44 insertions(+), 37 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 5eb942fcfe..7bedd37a3e 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 @@ -356,7 +356,6 @@ export class BulletGraph extends G2PlotChartView { pre['ranges'] = next return pre default: - pre[next.name] = next return pre } }, {}) as Record @@ -366,51 +365,58 @@ export class BulletGraph extends G2PlotChartView { showMarkers: true, customItems(originalItems) { if (!tooltipAttr.seriesTooltipFormatter?.length) return originalItems - + const isDynamic = bullet.bar.ranges.showType === 'dynamic' + const rangeFormatter = chart.extBubble[0] const result = [] const data = options.data.find(item => item.title === originalItems[0].title) Object.keys(formatterMap).forEach((key, _index) => { if (key === '记录数*') return const formatter = formatterMap[key] if (formatter) { - if (key !== 'ranges') { - 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 - }) - } else { - const ranges = data.ranges - const isDynamic = bullet.bar.ranges.showType === 'dynamic' - ranges.forEach((range, index) => { - const value = valueFormatter( - parseFloat(isDynamic ? data.minRanges[0] : (range as string)), - formatter.formatterCfg - ) - let name = '' - let color: string | string[] - if (bullet.bar.ranges.showType === 'dynamic') { - name = isEmpty(formatter.chartShowName) ? formatter.name : formatter.chartShowName - color = bullet.bar[key].fill - } else { - const customRange = bullet.bar.ranges.fixedRange[index].name - name = customRange - ? customRange - : isEmpty(formatter.chartShowName) - ? formatter.name - : formatter.chartShowName - color = bullet.bar[key].fixedRange[index].fill - } - result.push({ ...originalItems[0], color, name, value }) - }) + let name = isEmpty(formatter.chartShowName) ? formatter.name : formatter.chartShowName + let value = valueFormatter(parseFloat(data[key] as string), formatter.formatterCfg) + let color = bullet.bar[key]?.fill ?? 'grey' + if (key === 'ranges') { + if (!isDynamic && rangeFormatter) { + name = isEmpty(rangeFormatter.chartShowName) + ? rangeFormatter.name + : rangeFormatter.chartShowName + value = valueFormatter(parseFloat(data.minRanges[0]), rangeFormatter.formatterCfg) + color = 'grey' + } else { + return + } } + result.push({ + color, + name, + value + }) } }) + const ranges = data.ranges + ranges.forEach((range, index) => { + const value = isDynamic + ? valueFormatter(parseFloat(data.minRanges[0]), rangeFormatter.formatterCfg) + : (range as string) + let name = '' + let color: string | string[] + if (bullet.bar.ranges.showType === 'dynamic') { + name = isEmpty(rangeFormatter.chartShowName) + ? rangeFormatter.name + : rangeFormatter.chartShowName + color = bullet.bar['ranges'].fill + } else { + const customRange = bullet.bar.ranges.fixedRange[index].name + name = customRange + ? customRange + : isEmpty(rangeFormatter.chartShowName) + ? rangeFormatter.name + : rangeFormatter.chartShowName + color = bullet.bar['ranges'].fixedRange[index].fill + } + result.push({ ...originalItems[0], color, name, value }) + }) const dynamicTooltipValue = chart.data.data.find( d => d.field === originalItems[0]['title'] )?.dynamicTooltipValue @@ -424,6 +430,7 @@ export class BulletGraph extends G2PlotChartView { } }) } + result.sort((a, b) => (a.color === 'grey' ? 1 : b.color === 'grey' ? -1 : 0)) return result }, container: getTooltipContainer(`tooltip-${chart.id}`),