From 26a5c820316ff6eb868ab284aa7ec4ba886cc4b1 Mon Sep 17 00:00:00 2001 From: LeafYeeXYZ Date: Wed, 9 Oct 2024 12:19:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9B=BE=E5=83=8F=E5=88=86=E7=BB=84?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E7=BC=BA=E5=A4=B1=E5=80=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/useZustand.ts | 2 +- src/plots/BasicBoxPlot.tsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/useZustand.ts b/src/lib/useZustand.ts index 65ebd66..0f6851e 100644 --- a/src/lib/useZustand.ts +++ b/src/lib/useZustand.ts @@ -12,7 +12,7 @@ const CALCULATE_VARIABLES = (dataCols: Variable[], dataRows: { [key: string]: un const count = data.length const missing = data.filter((v) => v === undefined).length const valid = count - missing - const unique = new Set(data).size + const unique = new Set(data.filter((v) => v !== undefined)).size // 判断数据类型, 并计算描述统计量 let type: '称名或等级数据' | '等距或等比数据' = '称名或等级数据' if ( diff --git a/src/plots/BasicBoxPlot.tsx b/src/plots/BasicBoxPlot.tsx index 2a1e839..6d33130 100644 --- a/src/plots/BasicBoxPlot.tsx +++ b/src/plots/BasicBoxPlot.tsx @@ -41,7 +41,11 @@ export function BasicBoxPlot() { try { messageApi?.loading('正在处理数据...') const data = dataRows - .filter((row) => typeof row[values.dataVar] !== 'undefined' && !isNaN(Number(row[values.dataVar]))) + .filter((row) => + typeof row[values.dataVar] !== 'undefined' + && typeof row[values.groupVar] !== 'undefined' + && !isNaN(Number(row[values.dataVar])) + ) .map((row) => ({ [values.groupVar]: row[values.groupVar], [values.dataVar]: Number(row[values.dataVar]) })) .sort((a, b) => Number(a[values.groupVar]) - Number(b[values.groupVar])) setConfig({