From c5e6fa9253fd4de69bb8a753c1cd21fceece206d Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Tue, 3 Sep 2024 21:28:19 +0800 Subject: [PATCH] =?UTF-8?q?style(=E5=9B=BE=E8=A1=A8-=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E6=8A=98=E7=BA=BF=E5=9B=BE):=20=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=90=8E=EF=BC=8C=E5=9B=BE=E4=BE=8B=E4=B8=AA?= =?UTF-8?q?=E6=95=B0=E8=B6=85=E8=BF=879=E4=B8=AA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=9B=BE=E4=BE=8Bmarker=E6=9C=AA=E7=9D=80=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/line/line.ts | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/line/line.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/line/line.ts index bf4c8e49c9..cc601921a3 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/line/line.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/line/line.ts @@ -288,40 +288,40 @@ export class Line extends G2PlotChartView { } protected configLegend(chart: Chart, options: LineOptions): LineOptions { const optionTmp = super.configLegend(chart, options) - const xAxisExt = chart.xAxisExt - if (!optionTmp.legend || xAxisExt.length === 0 || xAxisExt[0].customSort?.length === 0) { - return optionTmp - } - // 图例自定义排序 - const l = optionTmp.legend - const basicStyle = parseJson(chart.customAttr).basicStyle - const sort = xAxisExt[0].customSort ?? [] - const legendItems = [] - sort.forEach((item, index) => { - legendItems.push({ - name: item, - value: item, - marker: { - symbol: l.marker.symbol, - style: { - r: 6, - fill: 'rgba(0,0,0,0)', - lineWidth: 2, - lineJoin: 'round', - stroke: basicStyle.colors[index] + const xAxisExt = chart.xAxisExt[0] + if (optionTmp.legend && xAxisExt?.customSort?.length > 0) { + // 图例自定义排序 + const l = optionTmp.legend + const basicStyle = parseJson(chart.customAttr).basicStyle + const sort = xAxisExt.customSort ?? [] + const legendItems = [] + sort.forEach((item, index) => { + legendItems.push({ + name: item, + value: item, + marker: { + symbol: l.marker.symbol, + style: { + r: 6, + fill: 'rgba(0,0,0,0)', + lineWidth: 2, + lineJoin: 'round', + stroke: basicStyle.colors[index % basicStyle.colors.length] + } } - } + }) }) - }) - const legend = { - ...l, - custom: true, - items: legendItems - } - return { - ...optionTmp, - legend + const legend = { + ...l, + custom: true, + items: legendItems + } + return { + ...optionTmp, + legend + } } + return optionTmp } protected setupOptions(chart: Chart, options: LineOptions): LineOptions { return flow(