recharts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYou build Recharts charts integrated with HeroUI v3 design tokens and Tailwind CSS v4. Infer the project's language variant (US/UK English) from existing commits, docs, and code, and match it in all output.
Read individual rule files in for detailed patterns and code examples.
rules/你需要构建集成了HeroUI v3设计令牌和Tailwind CSS v4的Recharts图表。从现有提交记录、文档和代码中推断项目的语言变体(美式/英式英语),并在所有输出中保持一致。
请阅读目录下的单个规则文件,获取详细模式和代码示例。
rules/Rules Overview
规则概述
| Rule | Impact | File |
|---|---|---|
| Container pattern | HIGH | |
| Theme integration | HIGH | |
| Custom components | HIGH | |
| 规则 | 影响程度 | 文件 |
|---|---|---|
| 容器模式 | 高 | |
| 主题集成 | 高 | |
| 自定义组件 | 高 | |
Workflow
工作流程
Building a chart?
构建图表?
- Detect setup — Confirm is in
recharts. Check if HeroUI v3 is installed (package.jsonor individual packages). Detect Tailwind CSS v4 (@heroui/react).@tailwindcss/* - Read rules — Read all files in to load the container pattern, theme token mapping, and custom component templates.
rules/ - Fetch theme tokens — Use to confirm the current HeroUI token names available in the project.
mcp__heroui-react__get_theme_variables - Generate component — Build the chart component applying all three rules: outer container wrapper, CSS variable colours, and custom tooltip/legend.
- Verify — Check the generated code against each rule. Confirm no hardcoded hex colours, is wrapped correctly, and tooltip uses HeroUI classes.
ResponsiveContainer
- 检测环境配置 — 确认中包含
package.json。检查是否已安装HeroUI v3(recharts或独立包)。检测是否安装了Tailwind CSS v4(@heroui/react)。@tailwindcss/* - 阅读规则 — 阅读目录下的所有文件,加载容器模式、主题令牌映射和自定义组件模板。
rules/ - 获取主题令牌 — 使用确认项目中可用的当前HeroUI令牌名称。
mcp__heroui-react__get_theme_variables - 生成组件 — 构建图表组件并应用以下三条规则:外部容器包装器、CSS变量颜色、自定义提示框/图例。
- 验证 — 根据每条规则检查生成的代码。确认没有硬编码的十六进制颜色、已正确包装,且提示框使用了HeroUI类。
ResponsiveContainer
Reviewing existing charts?
评审现有图表?
- Scan — Glob for files importing from . Read each file and check against every rule in
recharts.rules/ - Report — List violations grouped by rule with file paths and line numbers.
- Fix — Apply corrections using the Edit tool, one violation at a time.
- 扫描文件 — 查找所有导入的文件。读取每个文件并对照
recharts目录下的每条规则进行检查。rules/ - 生成报告 — 按规则分组列出违规项,包含文件路径和行号。
- 修复问题 — 使用编辑工具逐一修复每个违规项。
Quick Reminders
快速提示
- Always add as the first child inside every chart for screen reader support
<AccessibilityLayer /> - Set on chart elements when inside components that re-render frequently (tables, filters)
isAnimationActive={false} - Recharts uses SVG — style with and
strokeprops, not CSSfillcolor - Export chart prop interfaces separately so consumers can extend them
- Use with
cartesianGridand theme-aware stroke colourstrokeDasharray="3 3" - Never set a fixed on
width— it must always beResponsiveContainerwidth="100%"
- 始终在每个图表内部添加作为第一个子元素,以支持屏幕阅读器
<AccessibilityLayer /> - 当图表位于频繁重渲染的组件(表格、过滤器)内部时,需在图表元素上设置
isAnimationActive={false} - Recharts使用SVG——请使用和
stroke属性设置样式,而非CSS的fill属性color - 单独导出图表的属性接口,以便使用者可以扩展它们
- 使用时设置
cartesianGrid,并使用与主题匹配的描边颜色strokeDasharray="3 3" - 切勿为设置固定
ResponsiveContainer——它必须始终设为widthwidth="100%"
Assumptions
前提假设
- React + TypeScript project
- Recharts installed (in dependencies)
recharts - HeroUI v3 installed with Tailwind CSS v4
- CSS variables from HeroUI theme are available globally
- React + TypeScript项目
- 已安装Recharts(依赖项中包含)
recharts - 已安装HeroUI v3和Tailwind CSS v4
- HeroUI主题的CSS变量已全局可用