About
A themed chart card with a title, a one-line takeaway, and an SVG plot (bar, line, area, pie, radar, radial) that draws itself in once scrolled into view, with optional center content and a custom tooltip.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Chart to your project and fits it to your theme.
Code
How Chart is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
import Chart from "@/components/ui/chart";
import { defineChart } from "@tanstack/charts";
import { pie, polar, radialArc } from "@tanstack/charts/polar";
import { tooltip } from "@tanstack/charts/tooltip";
const holdings = [
{ subject: "Medicine", count: 1240 },
{ subject: "Astronomy", count: 860 },
{ subject: "Mathematics", count: 720 },
{ subject: "Philosophy", count: 540 },
{ subject: "Geography", count: 310 },
];
const total = holdings.reduce((sum, h) => sum + h.count, 0);
const subjects = holdings.map((h) => h.subject);
const definition = defineChart({
marks: [
polar({
inset: 8,
radiusRatio: 0.9,
marks: [
radialArc(pie(holdings, { value: "count" }), {
innerRadius: ({ radius }) => radius * 0.62,
cornerRadius: 4,
padAngle: () => 0.012,
color: "subject",
key: "subject",
}),
],
scales: { angle: null, radius: null },
}),
],
scales: { x: null, y: null },
color: { domain: subjects },
tooltip,
});
export default function ChartPieDemo() {
return (
<div className="flex w-full items-center justify-center p-10">
<div className="w-full max-w-xl">
<Chart
title="Holdings by subject"
description="Medicine is a third of the collection."
definition={definition}
center={
<>
<strong className="total">
{new Intl.NumberFormat().format(total)}
</strong>
<span className="unit">manuscripts</span>
</>
}
/>
</div>
</div>
);
}








