agentleFS
bkjain655bkjain655/agent-skills/skills/recharts-dashboard/SKILL.md

recharts-dashboard

Skill0 starsChanged 4 months agoMITView on GitHub

Builds dashboard charts with Recharts in React/Next.js: responsive containers, pie/bar/line charts, custom tooltips, currency formatting, and export-safe SVG styling. Use when adding data visualizations, allocation charts, trend graphs, or financial dashboards.

  • Installs packages

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Don't render an empty chart — show placeholder:

    line 105
  2. Very specific:

    Avoid CSS filter on chart containers during export

    line 119
  3. Distinctive:

    Test capture at 2× pixel ratio

    line 121
  4. Distinctive:

    Keep slice count reasonable (< 12).

    line 126
  5. Very specific:

    Don't animate on first render if it causes export flicker (isAnimationActive={false} for exports)

    line 127

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Recharts Dashboard Charts

Install

npm install recharts

Charts are client components — add "use client" to wrapper files.

Layout pattern

import { ResponsiveContainer, PieChart, Pie, Cell, Tooltip, Legend } from "recharts";

<div className="h-64 w-full">
  <ResponsiveContainer width="100%" height="100%">
    <PieChart>
      <Pie data={data} dataKey="value" nameKey="name" cx="50%" cy="50%" innerRadius={60} outerRadius={90}>
        {data.map((entry, i) => (
          <Cell key={entry.name} fill={COLORS[i % COLORS.length]} />
        ))}
      </Pie>
      <Tooltip content={<CustomTooltip />} />
    </PieChart>
  </ResponsiveContainer>
</div>

Parent must have explicit height — ResponsiveContainer needs it.

Data shape

Normalize before passing to Recharts:

interface ChartSlice {
  name: string;
  value: number;
  percent?: number;
}

function toChartData(items: { label: string; amount: number }[]): ChartSlice[] {
  const total = items.reduce((s, i) => s + i.amount, 0);
  return items
    .filter((i) => i.amount > 0)
    .map((i) => ({
      name: i.label,
      value: i.amount,
      percent: total > 0 ? (i.amount / total) * 100 : 0,
    }));
}

Custom tooltip

function CustomTooltip({ active, payload }: { active?: boolean; payload?: { name: string; value: number; payload: ChartSlice }[] }) {
  if (!active || !payload?.length) return null;
  const { name, value, percent } = payload[0].payload;
  return (
    <div className="rounded-lg border bg-white px-3 py-2 text-sm shadow-md">
      <p className="font-medium">{name}</p>
      <p>{formatMoney(value)} ({percent?.toFixed(1)}%)</p>
    </div>
  );
}

Color palette

Define once, reuse across charts:

export const CHART_COLORS = [
  "#1e3a5f", "#2563eb", "#0d9488", "#d97706", "#7c3aed", "#64748b",
];

Match brand tokens from Tailwind @theme.

Bar / line charts

<BarChart data={monthlyData}>
  <XAxis dataKey="month" tick={{ fontSize: 12 }} />
  <YAxis tickFormatter={(v) => formatCompact(v)} width={60} />
  <Bar dataKey="amount" fill="var(--color-brand-700)" radius={[4, 4, 0, 0]} />
</BarChart>

Format Y-axis for large numbers (K, L, M).

Empty states

Don't render an empty chart — show placeholder:

{data.length === 0 ? (
  <p className="text-sm text-muted-foreground">No data yet</p>
) : (
  <ResponsiveContainer>...</ResponsiveContainer>
)}

Export compatibility

Recharts renders SVG — works with html-to-image capture. Tips:

  • Avoid CSS filter on chart containers during export
  • Set [data-export="true"] overrides if legend overlaps
  • Test capture at 2× pixel ratio

Performance

  • Memoize data with useMemo when derived from store
  • Keep slice count reasonable (< 12); group remainder as "Other"
  • Don't animate on first render if it causes export flicker (isAnimationActive={false} for exports)

Accessibility

Charts fail WCAG 1.1.1 if values are visual-only. Add sr-only data table:

<table className="sr-only">
  <caption>Allocation breakdown</caption>
  <thead><tr><th scope="col">Category</th><th scope="col">Share</th></tr></thead>
  <tbody>{data.map(d => (
    <tr key={d.name}><td>{d.name}</td><td>{formatValue(d.value)} ({d.percent}%)</td></tr>
  ))}</tbody>
</table>
<div className="h-64 w-full" aria-hidden="true">
  <ResponsiveContainer>...</ResponsiveContainer>
</div>

Also provide visible legend; ensure tooltip isn't the only access path. See web-accessibility-wcag.

Anti-patterns

  • Putting business logic inside tooltip components
  • Using Recharts for single static numbers (use typography instead)
  • Missing height on parent → collapsed invisible chart

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.