Dashboard Charts
Hand-written SVG charts: DashLineChart with a hover scrubber, DashBarChart, DashDonut with hoverable segments and DashSparkline.
npx shadcn@latest add https://ui.develop-better-solutions.com/r/dash-charts.jsonUses:dash-chart-math
Recovery trend
Visits by month
Patient flow
Sparkline
Recovery trend
Visits by month
Patient flow
Sparkline
Usage
dash-charts-example.tsx
"use client";
import { DashBarChart, DashDonut, DashLineChart, DashSparkline } from "@dbs/ui";
import { DashScope } from "./_store";
const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"];
function Charts({ dark }: { dark?: boolean }) {
return (
<DashScope dark={dark} minHeight={0}>
<div className="grid gap-6 sm:grid-cols-2">
<div>
<p className="mb-2 text-sm font-medium">Recovery trend</p>
<DashLineChart values={[42, 48, 46, 58, 64, 71]} labels={MONTHS} unit="%" ariaLabel="Recovery trend by month" />
</div>
<div>
<p className="mb-2 text-sm font-medium">Visits by month</p>
<DashBarChart values={[34, 52, 28, 48, 40, 61]} labels={MONTHS} highlight={1} ariaLabel="Visits by month" />
</div>
<div>
<p className="mb-2 text-sm font-medium">Patient flow</p>
<DashDonut
center="900"
sub="capacity"
ariaLabel="Patient flow by ward"
slices={[
{ label: "General", value: 420, color: "var(--dash-bar)" },
{ label: "Critical", value: 180, color: "var(--dash-line2)" },
{ label: "Observation", value: 300, color: "var(--dash-green-soft)" },
]}
/>
</div>
<div className="flex flex-col gap-2">
<p className="text-sm font-medium">Sparkline</p>
<DashSparkline values={[4, 7, 5, 9, 8, 12, 11, 15]} className="h-16 w-full" />
</div>
</div>
</DashScope>
);
}
export default function DashChartsExample() {
return (
<div className="grid w-full gap-4">
<Charts />
<Charts dark />
</div>
);
}