From e50482b3284dcd159e9390ec68a1e474e71aff14 Mon Sep 17 00:00:00 2001 From: wisonic Date: Wed, 9 Apr 2025 20:51:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8A=98=E7=BA=BF=E5=9B=BE=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AD=90?= =?UTF-8?q?=E7=BB=B4=E5=BA=A6=E6=8E=92=E5=BA=8F=E5=90=8E=E5=9B=BE=E4=BE=8B?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E4=BA=86=E8=A2=AB=E8=BF=87=E6=BB=A4=E6=8E=89?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=20#15463?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/line/line.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 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 cf16e043ba..8d7d738613 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 @@ -325,17 +325,30 @@ export class Line extends G2PlotChartView { if (sort?.length) { // 用值域限定排序,有可能出现新数据但是未出现在图表上,所以这边要遍历一下子维度,加到后面,让新数据显示出来 const data = optionTmp.data - data?.forEach(d => { - const cat = d['category'] - if (cat && !sort.includes(cat)) { - sort.push(cat) + const cats = + data?.reduce((p, n) => { + const cat = n['category'] + if (cat && !p.includes(cat)) { + p.push(cat) + } + return p + }, []) || [] + const values = sort.reduce((p, n) => { + if (cats.includes(n)) { + const index = cats.indexOf(n) + if (index !== -1) { + cats.splice(index, 1) + } + p.push(n) } - }) + return p + }, []) + cats.length > 0 && values.push(...cats) optionTmp.meta = { ...optionTmp.meta, category: { type: 'cat', - values: sort + values } } }