feat🔫: 单个cls的label pie

This commit is contained in:
车厘子 2022-10-18 17:13:04 +08:00
parent d27e2d9aae
commit c4e66e2e52
3 changed files with 290 additions and 267 deletions

View File

@ -15,8 +15,7 @@
} }
.cards { .cards {
display: flex; display: grid;
flex-direction: row; grid: repeat(2, auto) / auto-flow auto;
justify-content: right;
} }
} }

View File

@ -66,6 +66,10 @@ const Home = () => {
y: number y: number
}[]>([]); }[]>([]);
// 显示单个cls的饼状图查看cls内部的label的消费情况
// 这里有一个cls列表
const clsesForShow = ["餐饮", "恋爱"]
return ( return (
<div className={styles.home}> <div className={styles.home}>
<div className={styles.total}> <div className={styles.total}>
@ -105,6 +109,16 @@ const Home = () => {
data={transformer(billStore.groupByClass(billType))} data={transformer(billStore.groupByClass(billType))}
/> />
</Card> </Card>
{
clsesForShow.map(cls => {
return (<Card>
<Pie
title={cls}
data={transformer(billStore.groupByLabelOfClass(cls))}
/>
</Card>)
})
}
</div> </div>
<Modal <Modal
visible={isModalOpen} visible={isModalOpen}

View File

@ -43,6 +43,16 @@ export class Bill {
return functions(this._bills) return functions(this._bills)
} }
groupByLabelOfClass(className: string) {
const classFun = R.filter((bill: IBill) => R.of(bill.type).length === 0 || bill.cls === className)
const functions = R.compose(
R.groupBy((bill: IBill) => bill.label),
classFun,
)
return functions(this._bills)
}
get listDailyMoney() { get listDailyMoney() {
return this.groupByDate return this.groupByDate
} }