Recharts

From InugamiDev/ultrathink-oss · View interactive version

Recharts is an AI agent skill from the GitHub repository InugamiDev/ultrathink-oss. - **Triggers**: recharts, chart, graph, data visualization, line chart, bar chart, pie chart

How to use this skill

Skill file

Recharts

Overview

Composable charting library built on React components and D3. Declarative API where each chart element (axes, tooltips, legends) is a standalone component composed inside a chart wrapper.

When to Use

Key Patterns

Chart Types

Use the appropriate wrapper: LineChart, BarChart, AreaChart, PieChart, RadarChart, ScatterChart. Each accepts data, width, height and composes child components.

Responsive Container

Always wrap charts in <ResponsiveContainer width="100%" height={300}> to handle resizing. Never set fixed width/height on the chart itself when using this.

Axes and Grid

<XAxis dataKey="name" />, <YAxis />, <CartesianGrid strokeDasharray="3 3" />. Use tickFormatter for number/date formatting. Hide with hide prop, not CSS.

Tooltips and Legends

<Tooltip /> and <Legend /> are drop-in. Custom tooltip: pass content={<CustomTooltip />} receiving active, payload, label props. Custom legend: use content prop.

Custom Components

Custom tick: <XAxis tick={<CustomTick />} />. Custom shapes: <Bar shape={<CustomBar />} />. Custom dot: <Line dot={<CustomDot />} />. All receive element props via spread.

Animation Control

Disable for SSR/tests: isAnimationActive={false}. Tune with animationDuration={500} and animationEasing="ease-in-out". Disable globally during snapshots.

Data Formatting

tickFormatter={(val) => $${val}} on axes. labelFormatter on Tooltip for x-axis label. formatter on Tooltip for series values.

Brush for Zooming

<Brush dataKey="name" height={30} stroke="#8884d8" /> enables range selection. Combine with startIndex/endIndex for controlled zoom.

Composed Charts

<ComposedChart> mixes <Line>, <Bar>, <Area> in one view. Each series maps to its own dataKey. Share axes automatically.

Reference Lines and Areas

<ReferenceLine y={avg} stroke="red" label="Avg" /> for thresholds. <ReferenceArea x1="Mar" x2="Jun" fill="#eee" /> for highlighting ranges.

Anti-Patterns

Related Skills

react · typescript-frontend · design-systems

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.