Skip to content

Commit

Permalink
fix: 作用域错误
Browse files Browse the repository at this point in the history
  • Loading branch information
LeafYeeXYZ committed Oct 12, 2024
1 parent c0d64f7 commit 7ed3d70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@

本软件所用的工具包括但不限于: `React`, `Vite`, `Ant Design`, `Ant Design Charts`, `Sheet.js`, `Math.js`, `HTML2Canvas`, `Simple-Statistics`, `@Stdlib/Stats` 等; 如果您对本项目感兴趣, 欢迎 `star``fork``watch` 或者提出 `issue``pull request`!

## 使用说明

请提前准备 `.xlsx``.xls``.csv``.txt``.json``.txt``.dta` 等格式的数据文件, 打开本项目的网站, 并导入数据文件, 即可进行数据分析和图表绘制

## 开发说明

1. 克隆本项目到本地
```bash
git clone https://github.com/LeafYeeXYZ/PsychPen.git
cd PsychPen
```
2. 安装依赖 (本项目使用 [bun](https://bun.sh) 作为包管理工具)
```bash
bun install
```
3. 启动项目
1. 启动项目
```bash
bun dev
```
4. 打包项目
1. 打包项目
```bash
bun run build
```
Expand Down
22 changes: 10 additions & 12 deletions src/lib/useZustand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ const CALCULATE_VARIABLES = (
// 未来还会支持用不同方法定义插值 (在 dataCols 中), 返回插值后的数据
calculatedRows: { [key: string]: unknown }[]
} => {
const rows: { [key: string]: unknown }[] = new Array(dataRows.length).fill({})
const cols: Variable[] = dataCols.map((col) => {
// 原始数据
let data = dataRows.map((row) => row[col.name])
const rows: { [key: string]: unknown }[] = dataRows.map((row) => {
// 替换缺失值
if (col.missingValues?.length) {
data = data.map((v) => {
dataCols.forEach((col) => {
if (col.missingValues?.length) {
// 故意使用 == 而不是 ===
return col.missingValues?.some((m) => v == m) ? undefined : v
})
}
// 添加到 rows
data.forEach((v, i) => {
rows[i][col.name] = v
row[col.name] = col.missingValues?.some((m) => row[col.name] == m) ? undefined : row[col.name]
}
})
return row
})
const cols: Variable[] = dataCols.map((col) => {
// 原始数据
const data = rows.map((row) => row[col.name])
// 基础统计量
const count = data.length
const missing = data.filter((v) => v === undefined).length
Expand Down

0 comments on commit 7ed3d70

Please sign in to comment.