Skip to content

Commit

Permalink
fix: 图像分组变量缺失值处理
Browse files Browse the repository at this point in the history
  • Loading branch information
LeafYeeXYZ committed Oct 9, 2024
1 parent 9ffbdfa commit 26a5c82
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/useZustand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 5 additions & 1 deletion src/plots/BasicBoxPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 26a5c82

Please sign in to comment.