UI componentsCharts
Chart Shared
Layout primitives for building additional charts that match the look of the built-in ones. Exports a ChartCard wrapper (title / subtitle / recharts container / legend row), a ChartTooltipShell for custom recharts tooltips, and a ChartLegendItem color-swatch row.
Installation
pnpm dlx agent-observability-ui@latest add observability-chart-sharednpx agent-observability-ui@latest add observability-chart-sharedyarn dlx agent-observability-ui@latest add observability-chart-sharedbunx --bun agent-observability-ui@latest add observability-chart-sharedUsage
import { Bar, BarChart, Tooltip, XAxis, YAxis } from 'recharts'
import {
ChartCard,
ChartTooltipShell,
} from '@/components/observability-chart-shared'
export function MyChart({ data }: { data: Row[] }) {
return (
<ChartCard
title="My metric"
subtitle="Per-turn trend"
legend={[{ color: 'hsl(var(--primary))', label: 'Value' }]}
>
<BarChart data={data}>
<XAxis dataKey="turn" />
<YAxis />
<Tooltip
content={({ active, label, payload }) => (
<ChartTooltipShell
active={active}
label={label}
rows={(payload ?? []).map((p) => ({
label: String(p.dataKey),
value: String(p.value),
}))}
/>
)}
/>
<Bar dataKey="value" fill="hsl(var(--primary))" />
</BarChart>
</ChartCard>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
ChartCard.titlerequired | string | — | Card title shown at the top-left. |
ChartCard.subtitle | string | — | Optional subtitle under the title. |
ChartCard.legendrequired | { color: string; label: string }[] | — | Legend entries. Pass an empty array to suppress the legend row. |
ChartCard.chartHeight | string | 'h-64' | Tailwind height class applied to the ResponsiveContainer wrapper. |
ChartCard.childrenrequired | React.ReactElement | — | A single recharts element (e.g. <BarChart>, <LineChart>). |
ChartTooltipShell.active | boolean | — | Forwarded by recharts — the component renders nothing when false. |
ChartTooltipShell.label | string | number | — | Axis label for the hovered point (rendered as "Turn {label}"). |
ChartTooltipShell.rowsrequired | { label: string; value: string; color?: string }[] | — | Two-column key/value rows rendered inside the tooltip. Each row may override the label color. |
ChartLegendItem.colorrequired | string | — | Any CSS color — used for the small square swatch. |
ChartLegendItem.labelrequired | string | — | Legend text. |