Skip to content

Stats 统计展示

基本用法

统计展示用于在方框中显示数值和数据。可通过dataSource属性传入数据

Offices
4
21% more than last month
const dataSource = [
{
title: "Offices",
value: "4",
desc: "21% more than last month",
},
];
<Stats dataSource={dataSource} />;

垂直布局

默认统计展示布局为水平方向,通过可选字段direction设置统计展示布局为垂直方向。

Offices
4
21% more than last month
Employees2
2480
21% more than last month
Employees3
2480
21% more than last month
const dataSource = [
{
title: "Offices",
value: "4",
desc: "21% more than last month",
},
{
title: "Employees2",
value: "2480",
desc: "21% more than last month",
},
{
title: "Employees3",
value: "2480",
desc: "21% more than last month",
},
];
<Stats dataSource={dataSource} direction="vertical" />;

扩展配置项

数据源字段 dataSource 支持配置项 titlevaluedesciconplace,分别对应标题、数值、描述、图标、位置。 其中 titlevaluedescicon 都支持扩展配置项 content, variant

Offices
4
21% more than last month
Offices2
4
21% more than last month
Offices3
4
21% more than last month
const dataSource = [
{
title: {
content: "Offices",
variant: "primary",
},
value: {
content: "4",
variant: "primary",
},
desc: {
content: "21% more than last month",
variant: "primary",
},
icon: {
content: "tabler:building",
variant: "primary",
},
},
];
<Stats dataSource={dataSource} />;

统计展示每项内容的位置配置

通过可选字段 place 设置统计展示每项内容的位置。 可选 startcenterend,分别对应内容在左侧、中间、右侧。

Employees
24
21% more than last month
Employees
2480
21% more than last month
Templates
12
21% more than last month
const dataSource = [
{
title: "Employees",
value: "24",
desc: "21% more than last month",
place: "start",
},
{
title: "Employees",
value: "2480",
desc: "21% more than last month",
place: "center",
},
{
title: "Templates",
value: "12",
desc: "21% more than last month",
place: "end",
},
];
<Stats dataSource={dataSource} />;

API

Stats

参数说明类型默认值
dataSource数据源StatItem[][]
direction布局方向'horizontal' | 'vertical''horizontal'
class自定义类名string-

StatItem

参数说明类型默认值
title标题string | StatItemBase-
value数值string | StatItemBase-
desc描述string | StatItemBase-
icon图标string | StatItemBase-
place位置'start' | 'center' | 'end''start'

StatItemBase

参数说明类型默认值
content内容string-
variant颜色'primary' | 'secondary' | 'neutral''primary'