From 7703d3b92ee8d41fbd57fc82b6f98cedc7a49d2b Mon Sep 17 00:00:00 2001 From: ulleo Date: Tue, 3 Dec 2024 14:27:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=9B=BE=E8=A1=A8=E5=9B=BE=E4=BE=8B=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=AE=E6=94=B9=E6=96=87=E5=AD=97=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/bar/bidirectional-bar.ts | 14 +++++----- .../js/panel/charts/others/chart-mix.ts | 26 +++++++++---------- .../components/js/panel/common/common_antv.ts | 6 +++++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts index 0ac6e1f10e..b45401a8b7 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/bar/bidirectional-bar.ts @@ -318,15 +318,13 @@ export class BidirectionalHorizontalBar extends G2PlotChartView< protected configLegend(chart: Chart, options: BidirectionalBarOptions): BidirectionalBarOptions { const o = super.configLegend(chart, options) if (o.legend) { - o.legend.itemName = { - formatter: (_text: string, _item: any, index: number) => { - const yaxis = chart.yAxis[0] - const yaxisExt = chart.yAxisExt[0] - if (index === 0) { - return yaxis.chartShowName ? yaxis.chartShowName : yaxis.name - } - return yaxisExt.chartShowName ? yaxisExt.chartShowName : yaxisExt.name + o.legend.itemName.formatter = (_text: string, _item: any, index: number) => { + const yaxis = chart.yAxis[0] + const yaxisExt = chart.yAxisExt[0] + if (index === 0) { + return yaxis.chartShowName ? yaxis.chartShowName : yaxis.name } + return yaxisExt.chartShowName ? yaxisExt.chartShowName : yaxisExt.name } } return o diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix.ts index 3846e06c7c..4fb148a7e0 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/others/chart-mix.ts @@ -573,20 +573,18 @@ export class ColumnLineMix extends G2PlotChartView { const left = cloneDeep(chart.data?.left?.data) const right = cloneDeep(chart.data?.right?.data) - o.legend.itemName = { - formatter: (text: string, item: any, index: number) => { - let name = undefined - if (item.viewId === 'left-axes-view' && text === 'value') { - name = left[0]?.categories[0] - } else if (item.viewId === 'right-axes-view' && text === 'valueExt') { - name = right[0]?.categories[0] - } - item.id = item.id + '__' + index //防止重复的图例出现问题,但是左右轴如果有相同的怎么办 - if (name === undefined) { - return text - } else { - return name - } + o.legend.itemName.formatter = (text: string, item: any, index: number) => { + let name = undefined + if (item.viewId === 'left-axes-view' && text === 'value') { + name = left[0]?.categories[0] + } else if (item.viewId === 'right-axes-view' && text === 'valueExt') { + name = right[0]?.categories[0] + } + item.id = item.id + '__' + index //防止重复的图例出现问题,但是左右轴如果有相同的怎么办 + if (name === undefined) { + return text + } else { + return name } } diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 21d57ee6f4..6dce0b31a0 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -360,6 +360,12 @@ export function getLegend(chart: Chart) { r: l.size } }, + itemName: { + style: { + fill: l.color, + fontSize: l.fontSize + } + }, itemHeight: (l.fontSize > l.size * 2 ? l.fontSize : l.size * 2) + 4, radio: false, pageNavigator: {