图表与数据
方格比例图
一个自动填充的占比图:方格按阅读顺序填上各类别的颜色,总数同步计数,图例数值随之更新。
安装
npx @imgcli/cli add unit-chart使用
import { UnitChart } from "@/components/imgcli/unit-chart";
<UnitChart />默认参数下以 30 fps 渲染 126 帧(4.2 秒),预览画布为 960 × 540。
Use <UnitChart title="Installs by category" series={[{ label: "Titles", value: 4820 }]} /> for 126 frames at 30 fps (UNIT_CHART_SECONDS). Categories default to steps of the accent.
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | "Installs by category" | |
series | readonly UnitChartSeries[] | [
{ label: "Titles", value: 4820 },
{ label: "Devices", value: 2610 },
{ label: "Transitions", value: 1390 },
{ label: "Charts", value: 780 },
] | |
columns | number | 20 | Grid size; each cell is total ÷ (columns × rows). |
rows | number | 10 | |
unit | string | "" | Formats the total and the legend values. |
fontFamily | string | — | A face from the Imgcli font list, or any loaded CSS font stack. |
accentColor | string | — | |
theme | Partial<ImgcliTheme> | — | |
mode | "light" | "dark" | — | |
speed | number | 1 |
许可
MIT 许可,可免费用于个人及商业项目,保留版权和许可声明。
Copyright (c) 2026 Ricky (Imgcli) <https://imgcli.com>
常见问题
如何在 Remotion 项目中使用方格比例图?
运行 npx @imgcli/cli add unit-chart。CLI 会把组件源码复制到项目的 components/imgcli/ 目录并安装依赖,之后可以直接修改源码。
方格比例图能做什么?
一个自动填充的占比图:方格按阅读顺序填上各类别的颜色,总数同步计数,图例数值随之更新。
使用方格比例图前需要准备什么?
准备 Node.js 20.19 或更高版本,以及一个 Remotion 项目。新项目可以用 npx create-video@latest 创建。免费组件采用 MIT 许可证。