From 2fe8de69fd7af22d5b1fff62becc307146917d9d Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 25 May 2026 14:47:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9D=A1=E5=BD=A2=E5=9B=BE=E8=BE=85=E5=8A=A9=E7=BA=BF-?= =?UTF-8?q?=E6=95=B0=E5=80=BC=E6=A0=BC=E5=BC=8F=E6=B2=A1=E6=9C=89=E4=B8=8E?= =?UTF-8?q?=E6=A8=AA=E8=BD=B4=E7=BB=9F=E4=B8=80=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/components/js/panel/charts/g2/bar/bar.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts index 4248b375dc..53566dc023 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/g2/bar/bar.ts @@ -526,10 +526,10 @@ export class Bar extends G2ChartView { const { children } = options return { ...options, - children: [...children, ...this.getAssistLineStyle(chart)] + children: [...children, ...this.getAssistLineStyle(chart, options)] } } - protected getAssistLineStyle = (chart: Chart) => { + protected getAssistLineStyle = (chart: Chart, options?: ViewSpec) => { const assistLine = [] const senior = parseJson(chart.senior) if (!senior.assistLineCfg?.enable) { @@ -540,6 +540,8 @@ export class Bar extends G2ChartView { const customStyle = parseJson(chart.customStyle) let axisFormatterCfg, axisExtFormatterCfg const isHorizontalBar = this.name.includes('horizontal') + const axis = options?.children?.[0]?.axis + const valueAxisLabelFormatter = isHorizontalBar ? (axis as any)?.y?.labelFormatter : undefined if (isHorizontalBar) { if (customStyle.xAxis) { const a = JSON.parse(JSON.stringify(customStyle.xAxis)) @@ -580,7 +582,11 @@ export class Bar extends G2ChartView { const value = parseFloat(item.value) const targetFormatter = item.yAxisType === 'left' || !axisExtFormatterCfg ? axisFormatterCfg : axisExtFormatterCfg - const content = item.name + ' : ' + valueFormatter(value, targetFormatter) + const axisFormattedValue = + typeof valueAxisLabelFormatter === 'function' + ? valueAxisLabelFormatter(value) + : valueFormatter(value, targetFormatter) + const content = item.name + ' : ' + axisFormattedValue const fontSize = item.fontSize ? parseInt(item.fontSize + '') : '100%' assistLine.push({ type: 'lineY',