style👗: 修改图表样式

This commit is contained in:
clz 2022-09-17 22:21:06 +08:00
parent 36392b9bde
commit 820226c08d
5 changed files with 62 additions and 39 deletions

View File

@ -37,6 +37,23 @@ export const Bar = (props: IProps) => {
subtext: subTitle ?? "", subtext: subTitle ?? "",
left: 'center' left: 'center'
}, },
tooltip: {
show: true,
trigger: "item",
triggerOn: "mousemove|click",
axisPointer: {
type: "line"
},
showContent: true,
alwaysShowContent: false,
showDelay: 0,
hideDelay: 100,
textStyle: {
fontSize: 14
},
borderWidth: 0,
padding: 5
},
xAxis: { xAxis: {
type: 'category', type: 'category',
data: data.map(item => { data: data.map(item => {
@ -64,23 +81,6 @@ export const Bar = (props: IProps) => {
}), }),
}, },
], ],
tooltip: {
show: true,
trigger: "item",
triggerOn: "mousemove|click",
axisPointer: {
type: "line"
},
showContent: true,
alwaysShowContent: false,
showDelay: 0,
hideDelay: 100,
textStyle: {
fontSize: 14
},
borderWidth: 0,
padding: 5
}
}; };
}, [data, title, subTitle]) }, [data, title, subTitle])

View File

@ -14,6 +14,8 @@ import {
TitleComponentOption, TitleComponentOption,
TooltipComponent, TooltipComponent,
TooltipComponentOption, TooltipComponentOption,
LegendComponent,
LegendComponentOption,
GridComponent, GridComponent,
GridComponentOption, GridComponentOption,
// 数据集组件 // 数据集组件
@ -34,6 +36,7 @@ export type ECOption = echarts.ComposeOption<
| PieSeriesOption | PieSeriesOption
| TitleComponentOption | TitleComponentOption
| TooltipComponentOption | TooltipComponentOption
| LegendComponentOption
| GridComponentOption | GridComponentOption
| DatasetComponentOption>; | DatasetComponentOption>;
@ -41,6 +44,7 @@ export type ECOption = echarts.ComposeOption<
echarts.use([ echarts.use([
TitleComponent, TitleComponent,
TooltipComponent, TooltipComponent,
LegendComponent,
GridComponent, GridComponent,
DatasetComponent, DatasetComponent,
TransformComponent, TransformComponent,

View File

@ -33,15 +33,15 @@ export default function Pie(props: IProps) {
}, },
tooltip: { tooltip: {
trigger: 'item', trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)', formatter: '{b} : ¥{c} ({d}%)',
},
legend: {
orient: 'vertical',
left: 'left'
}, },
// legend: {
// orient: 'vertical',
// left: 'left',
// },
series: [ series: [
{ {
name: "金额", // name: "金额",
type: "pie", type: "pie",
radius: ['40%', '70%'], radius: ['40%', '70%'],
// roseType: "radius", // roseType: "radius",
@ -52,14 +52,14 @@ export default function Pie(props: IProps) {
}, },
label: { label: {
show: true, show: false,
// position: "top", // position: "top",
margin: 8, margin: 8,
formatter: "{b}: {c}" formatter: "{b}: {c}"
}, },
emphasis: { emphasis: {
label: { label: {
show: true show: false,
} }
}, },
data: data.map(item => { data: data.map(item => {

View File

@ -9,4 +9,14 @@
gap: 10px; gap: 10px;
align-items: flex-start; align-items: flex-start;
} }
.monthBar {
height: 300px;
}
.cards {
display: flex;
flex-direction: row;
justify-content: right;
}
} }

View File

@ -74,8 +74,17 @@ const Home = () => {
</Card> </Card>
</Space> </Space>
</div> </div>
<Bar data={transformer(billStore.groupByDate(billType))} /> <div className={styles.monthBar}>
<Pie data={transformer(billStore.groupByClass(billType))} /> <Bar data={transformer(billStore.groupByDate(billType))} />
</div>
<div className={styles.cards}>
<Card bodyStyle={{ height: 400, width: 400 }}>
<Pie
title="本月消费分类"
data={transformer(billStore.groupByClass(billType))}
/>
</Card>
</div>
</div> </div>
) )
} }