bklit-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBklit UI
Bklit UI
Composable chart components for React, distributed via the shadcn registry. Charts are installed as source into the user's project.
@bklitIMPORTANT: Run shadcn CLI commands with the project's package runner:,npx shadcn@latest, orpnpm dlx shadcn@latest.bunx --bun shadcn@latest
适用于React的可组合图表组件,通过 shadcn注册表分发。图表会作为源码安装到用户项目中。
@bklit重要提示: 使用项目的包运行器执行shadcn CLI命令:、npx shadcn@latest或pnpm dlx shadcn@latest。bunx --bun shadcn@latest
Current Project Context
当前项目上下文
json
!`npx shadcn@latest info --json`Use the JSON above for framework, aliases, Tailwind version, installed components, and resolved paths. Confirm the registry is configured before adding charts.
@bklitjson
!`npx shadcn@latest info --json`使用上述JSON信息获取框架、别名、Tailwind版本、已安装组件及解析路径。在添加图表前,请确认已配置注册表。
@bklitPrinciples
原则
- Install before inventing. Use — charts are registry components, not hand-rolled SVG.
npx shadcn@latest add @bklit/<chart> - Compose, don't flatten. Root chart → → series → axes →
Grid. See composition.md.ChartTooltip - Theme with tokens. Use and
chartCssVarsvariables — never hardcode one-off colors. See theming.md.--chart-* - Read the doc page first. Each chart has props, data shape, and examples at .
https://ui.bklit.com/docs/components/<slug> - Browse variants. Gallery: — Studio:
https://ui.bklit.com/charts/<slug>.https://ui.bklit.com/studio?chart=<slug>
- 优先安装,而非自行编写。使用——图表是注册表组件,而非手动编写的SVG。
npx shadcn@latest add @bklit/<chart> - 组合而非扁平化。根图表 → → 系列 → 坐标轴 →
Grid。详见composition.md。ChartTooltip - 使用令牌进行主题配置。使用和
chartCssVars变量——绝不硬编码一次性颜色。详见theming.md。--chart-* - 先阅读文档页面。每个图表的属性、数据格式及示例均位于。
https://ui.bklit.com/docs/components/<slug> - 浏览变体。画廊:——工作室:
https://ui.bklit.com/charts/<slug>。https://ui.bklit.com/studio?chart=<slug>
Critical Rules
核心规则
These rules are always enforced. Each links to Incorrect/Correct examples.
这些规则始终强制执行,每条规则均链接至错误/正确示例。
Composition → composition.md
组件组合 → composition.md
- Series and axes live inside the root chart — ,
LineChart,BarChart, etc.AreaChart - One root per chart — use for mixed series types.
ComposedChart - Grid before series so lines/bars render above grid lines.
- as a chart child — required for crosshair and hover context.
ChartTooltip
- 系列与坐标轴需置于根图表内部——、
LineChart、BarChart等。AreaChart - 每个图表仅一个根组件——混合系列类型请使用。
ComposedChart - Grid组件需在系列组件之前,确保线条/柱状图渲染在网格线上方。
- 作为图表子组件——为十字线和悬停上下文所必需。
ChartTooltip
Theming → theming.md
主题配置 → theming.md
- Use from
chartCssVarsinstead of raw@bklitui/ui/chartsstrings."var(--chart-…)" - Series palette: …
--chart-1for multi-series charts.--chart-5 - Tooltip surfaces: — avoids white-on-white in light mode.
bg-popover text-popover-foreground
- 使用——来自
chartCssVars,而非直接使用@bklitui/ui/charts字符串。"var(--chart-…)" - 系列调色板: …
--chart-1适用于多系列图表。--chart-5 - 提示框背景: 使用——避免浅色模式下白字白背景的问题。
bg-popover text-popover-foreground
Animation → animation.md
动画设置 → animation.md
- Default duration ~1100ms for cartesian enter animations unless the doc specifies otherwise.
- Replay: change or remount with a new
revealSignature.key - Live charts: use on
pausedto debug without stopping the rAF loop manually.LiveLineChart
- 默认时长约1100ms——笛卡尔图入场动画,除非文档另有指定。
- 重播: 修改或使用新的
revealSignature重新挂载组件。key - 实时图表: 在上使用
LiveLineChart属性,无需手动停止rAF循环即可调试。paused
Tooltips → tooltips.md
提示框 → tooltips.md
- Custom content via
ChartTooltipprop or children patterns from docs.content - function for candlestick / dynamic crosshair colors.
indicatorColor - Custom indicators: use — do not track mouse globally outside chart context.
useChart()
- 通过的
ChartTooltip属性自定义内容,或使用文档中的子组件模式。content - 函数——用于K线图/动态十字线颜色。
indicatorColor - 自定义指示器: 使用——不要在图表上下文之外全局跟踪鼠标位置。
useChart()
Installation → installation.md
安装指南 → installation.md
- Require registry in
@bklit.components.json - Install: .
npx shadcn@latest add @bklit/<slug> - Let the CLI install peer dependencies — do not pin /
@visx/*manually unless resolving a conflict.motion
- 要求中配置
components.json注册表。@bklit - 安装命令: 。
npx shadcn@latest add @bklit/<slug> - 让CLI安装对等依赖——除非解决冲突,否则不要手动固定/
@visx/*版本。motion
Chart Catalog
图表目录
| Slug | Use when | Install | Docs | Gallery |
|---|---|---|---|---|
| Trends with filled regions under lines | | /docs/components/area-chart | /charts/area-chart |
| Category comparisons, stacked or grouped bars | | /docs/components/bar-chart | /charts/bar-chart |
| Time series, multi-line trends, markers | | /docs/components/line-chart | /charts/line-chart |
| Streaming / real-time data | | /docs/components/live-line-chart | /charts/live-line-chart |
| Mixed bar + line (or similar) on one axis | | /docs/components/composed-chart | /charts/composed-chart |
| Correlation, distribution, bubble sizing | | /docs/components/scatter-chart | /charts/scatter-chart |
| OHLC financial data, brushes | | /docs/components/candlestick-chart | /charts/candlestick-chart |
| Part-to-whole slices | | /docs/components/pie-chart | /charts/pie-chart |
| Donut / ring KPIs | | /docs/components/ring-chart | /charts/ring-chart |
| Multi-axis comparison | | /docs/components/radar-chart | /charts/radar-chart |
| Single-value KPI dial | | /docs/components/gauge-chart | /charts/gauge-chart |
| Stage conversion funnels | | /docs/components/funnel-chart | /charts/funnel-chart |
| Flow between nodes | | /docs/components/sankey-chart | /charts/sankey-chart |
| Geo regions colored by value | | /docs/components/choropleth-chart | /charts/choropleth-chart |
Workflow
工作流程
- Run — verify
npx shadcn@latest info --jsonregistry and aliases.@bklit - Pick a chart from the catalog (or ask the user what story the data tells).
- Open the doc URL for data shape and props.
- If not installed: .
npx shadcn@latest add @bklit/<slug> - Compose with grid, series, axes, tooltip — apply theming tokens.
- Point the user to the gallery or Studio URL for variant inspiration.
- 运行——验证
npx shadcn@latest info --json注册表及别名配置。@bklit - 从目录中选择图表(或询问用户数据要呈现的故事)。
- 打开文档URL查看数据格式与属性。
- 若未安装:执行。
npx shadcn@latest add @bklit/<slug> - 组合Grid、系列、坐标轴、提示框组件——应用主题令牌。
- 引导用户查看画廊或工作室URL获取变体灵感。
Quick Reference
快速参考
bash
undefinedbash
undefinedProject info
项目信息
npx shadcn@latest info --json
npx shadcn@latest info --json
Add a chart
添加图表
npx shadcn@latest add @bklit/line-chart
npx shadcn@latest add @bklit/line-chart
Search registries (if configured)
搜索注册表(已配置情况下)
npx shadcn@latest search @bklit
```tsx
import { LineChart, Line, Grid, XAxis, ChartTooltip, chartCssVars } from "@bklitui/ui/charts";
<LineChart data={data} xDataKey="date">
<Grid horizontal />
<Line dataKey="users" stroke={chartCssVars.linePrimary} />
<XAxis />
<ChartTooltip />
</LineChart>npx shadcn@latest search @bklit
```tsx
import { LineChart, Line, Grid, XAxis, ChartTooltip, chartCssVars } from "@bklitui/ui/charts";
<LineChart data={data} xDataKey="date">
<Grid horizontal />
<Line dataKey="users" stroke={chartCssVars.linePrimary} />
<XAxis />
<ChartTooltip />
</LineChart>Utility docs
工具文档
- Theming: https://ui.bklit.com/docs/theming
- Grid: https://ui.bklit.com/docs/utility/grid
- Legend: https://ui.bklit.com/docs/utility/legend
- Tooltip: https://ui.bklit.com/docs/utility/tooltip
- Custom indicator: https://ui.bklit.com/docs/utility/custom-indicator
- useChart: https://ui.bklit.com/docs/utility/use-chart
Detailed References
详细参考
- composition.md
- theming.md
- animation.md
- tooltips.md
- installation.md
- composition.md
- theming.md
- animation.md
- tooltips.md
- installation.md