一键导入
recharts-chart
Create new Recharts visualization components following the project's proven chart patterns (responsive, typed, dark-mode compatible).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create new Recharts visualization components following the project's proven chart patterns (responsive, typed, dark-mode compatible).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create new FastAPI CRUD endpoints following the project's proven router patterns (auth, rate limiting, error handling, Pydantic v2 schemas).
Create Architecture Decision Records (ADRs). Use when the user wants to record an architectural decision, document a technical choice, or when creating a new ADR for a PR.
Maintain and update the project CHANGELOG.md. Use when merging PRs, preparing releases, when the user asks to update the changelog, add changelog entries, or review changelog quality.
Reference guide for advanced git workflow patterns including worktrees, parallel development, and periodic cleanup. Use when setting up worktrees, doing parallel development, or cleaning up stale branches.
Create, review, and edit Request for Comments (RFC) documents for technical proposals. Use when the user wants to write an RFC, design document, technical proposal, or feature specification. Also use when reviewing or providing feedback on existing RFCs, or when converting ideas into structured technical proposals.
| name | recharts-chart |
| description | Create new Recharts visualization components following the project's proven chart patterns (responsive, typed, dark-mode compatible). |
Generate new chart components that match the conventions established across the 3 existing Recharts chart types (ROCCurve, CalibrationPlot, MetricsBar) in apps/web/components/charts/.
| Recharts Component | Use When | Example in Codebase |
|---|---|---|
LineChart | Continuous x-y data, curves | ROC curve, calibration plot |
BarChart | Categorical comparisons | Metrics comparison across models |
AreaChart | Line with filled region | Probability distributions |
ScatterChart | Discrete x-y points | Feature importance scatter |
Define the TypeScript interface in apps/web/lib/types.ts
shared/schemas/fpr: number[], tpr: number[])Create the component in apps/web/components/charts/<name>.tsx
references/chart-template.tsx"use client" directiveAdd data transformation (if needed)
Integrate into a page
<Card> component with a descriptive titleEvery chart component follows this order:
"use client";
// 1. Recharts imports (destructured)
import { CartesianGrid, Line, LineChart, ... } from "recharts";
// 2. Type imports
import type { DataType } from "@/lib/types";
// 3. Props interface
interface ChartNameProps { ... }
// 4. Constants (colors, labels)
const COLORS = ["#2563eb", "#dc2626", "#16a34a", "#9333ea", "#ea580c"];
// 5. Component function
export function ChartName({ data }: ChartNameProps) { ... }
350 via ResponsiveContainer"100%" via ResponsiveContainer{ top: 5, right: 20, bottom: 25, left: 10 }{ top: 5, right: 20, bottom: 5, left: 10 }const COLORS = ["#2563eb", "#dc2626", "#16a34a", "#9333ea", "#ea580c"];
// blue red green purple orange
#2563ebCOLORS[idx % COLORS.length]#9ca3af (gray-400)<CartesianGrid strokeDasharray="3 3" />
Numeric 0–1 axis (probabilities, rates):
<XAxis
dataKey="fieldName"
type="number"
domain={[0, 1]}
label={{ value: "Axis Label", position: "insideBottom", offset: -15 }}
/>
<YAxis
domain={[0, 1]}
label={{ value: "Axis Label", angle: -90, position: "insideLeft" }}
/>
Categorical axis (metric names, categories):
<XAxis dataKey="category" />
<YAxis domain={[0, 1]} />
Standard formatter for numeric values:
<Tooltip formatter={(value: number | undefined) => value?.toFixed(4) ?? ""} />
With custom label:
<Tooltip
formatter={(value: number | undefined) => value?.toFixed(4) ?? ""}
labelFormatter={(label) => `Label: ${Number(label).toFixed(4)}`}
/>
<Line
name="Series Label"
type="monotone"
dataKey="fieldName"
stroke="#2563eb"
dot={false} // false for dense data, { r: 4 } for sparse
strokeWidth={2}
/>
<ReferenceLine
segment={[{ x: 0, y: 0 }, { x: 1, y: 1 }]}
stroke="#9ca3af"
strokeDasharray="5 5"
label="Random"
/>
Transform parallel arrays into Recharts point objects:
// Input: { fpr: number[], tpr: number[] }
const chartData = data.fpr.map((fpr, i) => ({
fpr,
tpr: data.tpr[i],
}));
Pivot models into comparison data:
// Input: models[] with metric fields
const chartData = metrics.map((metric) => {
const point: Record<string, string | number> = { metric: labels[metric] };
for (const model of models) {
point[model.name] = Number(model[metric].toFixed(4));
}
return point;
});
{items.map((item, idx) => (
<Line
key={item.label}
name={item.label}
dataKey="y"
stroke={item.color || COLORS[idx % COLORS.length]}
dot={false}
strokeWidth={2}
/>
))}
"use client" directive at top of fileResponsiveContainer wrapping with width="100%" and height={350}CartesianGrid strokeDasharray="3 3".toFixed(4) formatterCOLORS array or #2563eb primary)apps/web/lib/types.ts (if new)<Card>