图表与数据
柱状图
一周数据一目了然:柱子依次长出,重点那天以强调色显示并计数到实际数值,随后出现涨幅标签。
安装
npx @imgcli/cli add bar-chart使用
import { BarChart } from "@/components/imgcli/bar-chart";
<BarChart />默认参数下以 30 fps 渲染 120 帧(4 秒),预览画布为 960 × 540。
Use <BarChart title="Renders this week" values={[312, 358, 551]} labels={["Fri", "Sat", "Sun"]} delta="+38% vs last week" /> for 120 frames at 30 fps (BAR_CHART_SECONDS).
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
title | string | "Renders this week" | |
labels | readonly string[] | ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"] | |
values | readonly number[] | [312, 358, 341, 402, 389, 274, 551] | |
highlight | number | — | Which bar is the story. Defaults to the last. |
delta | string | "+38% vs last week" | A short change label shown once the bars land, such as "+38% vs last week". |
unit | string | "" | |
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 bar-chart。CLI 会把组件源码复制到项目的 components/imgcli/ 目录并安装依赖,之后可以直接修改源码。
柱状图能做什么?
一周数据一目了然:柱子依次长出,重点那天以强调色显示并计数到实际数值,随后出现涨幅标签。
使用柱状图前需要准备什么?
准备 Node.js 20.19 或更高版本,以及一个 Remotion 项目。新项目可以用 npx create-video@latest 创建。免费组件采用 MIT 许可证。