Agent Observability
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-shared
npx agent-observability-ui@latest add observability-chart-shared
yarn dlx agent-observability-ui@latest add observability-chart-shared
bunx --bun agent-observability-ui@latest add observability-chart-shared

Usage

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

PropTypeDefaultDescription
ChartCard.titlerequiredstringCard title shown at the top-left.
ChartCard.subtitlestringOptional subtitle under the title.
ChartCard.legendrequired{ color: string; label: string }[]Legend entries. Pass an empty array to suppress the legend row.
ChartCard.chartHeightstring'h-64'Tailwind height class applied to the ResponsiveContainer wrapper.
ChartCard.childrenrequiredReact.ReactElementA single recharts element (e.g. <BarChart>, <LineChart>).
ChartTooltipShell.activebooleanForwarded by recharts — the component renders nothing when false.
ChartTooltipShell.labelstring | numberAxis 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.colorrequiredstringAny CSS color — used for the small square swatch.
ChartLegendItem.labelrequiredstringLegend text.

On this page