From 4ad999415b5281181e9f9c46738d572838223561 Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 2 Dec 2024 17:07:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E6=8A=98=E7=BA=BF?= =?UTF-8?q?=E5=9B=BE=E5=AD=90=E7=BB=B4=E5=BA=A6=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=92=8C=E4=B8=BB=E7=BB=B4=E5=BA=A6=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/line/line.ts | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 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 2b632a9f7c..900948a88b 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 @@ -316,31 +316,23 @@ export class Line extends G2PlotChartView { const xAxisExt = chart.xAxisExt[0] if (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: 4, - fill: basicStyle.colors[index % basicStyle.colors.length] - } + if (sort?.length) { + // 用值域限定排序,有可能出现新数据但是未出现在图表上,所以这边要遍历一下子维度,加到后面,让新数据显示出来 + const data = optionTmp.data + data?.forEach(d => { + const cat = d['category'] + if (cat && !sort.includes(cat)) { + sort.push(cat) } }) - }) - const legend = { - ...l, - custom: true, - items: legendItems - } - return { - ...optionTmp, - legend + optionTmp.meta = { + ...optionTmp.meta, + category: { + type: 'cat', + values: sort + } + } } }