Light

Chart

Beautiful charts. Built using Recharts.

Spec · from metadata

When to use

  • Visualizing quantitative data as bar, line, area, pie, or radar charts
  • Dashboards and analytics views with interactive tooltips
  • Any Recharts chart that needs consistent Helix design system styling

When not to use

  • For simple numeric display — use a stat card or Badge instead
  • For tabular data — use Table instead
  • For progress toward a goal — use Progress instead

Anti-patterns

Avoid<ChartContainer config={config}><BarChart data={data}><Bar fill="#8884d8" /></BarChart></ChartContainer>
Prefer<ChartContainer config={config}><BarChart data={data}><Bar fill="var(--color-desktop)" /></BarChart></ChartContainer>

Use CSS variable references (var(--color-{key})) so colors respond to theme changes and match the ChartConfig

Avoid<ChartContainer config={config}><BarChart data={data}>...</BarChart></ChartContainer>
Prefer<ChartContainer config={config} className="min-h-[200px]"><BarChart data={data}>...</BarChart></ChartContainer>

ResponsiveContainer needs a measurable height — set min-h on ChartContainer or its parent

Accessibility

  • Screen readerCharts are visual by nature; provide a data table alternative or aria-label describing the data trend for accessibility
  • ContrastChart colors are set via ChartConfig — ensure sufficient contrast between data series and background; use the --chart-1 through --chart-5 CSS variables for consistent palette

Token bindings

TokenCategoryUsage
fill-muted-foregroundcolorAxis tick text color
stroke-border/50colorCartesian grid lines
fill-mutedcolorTooltip cursor and radial bar background
bg-backgroundcolorTooltip content background
border-border/50colorTooltip content border

Import

import {
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  ChartLegend,
  ChartLegendContent,
} from "@timelycare/helix-ui"

Props

interface ChartConfig {
  [key: string]: {
    label: string
    color?: string  // Use CSS variables like "hsl(var(--chart-1))"
    icon?: React.ComponentType
  }
}

interface ChartContainerProps {
  config: ChartConfig
  className?: string
  children: React.ReactNode
}

Chart Types

Bar Chart

TypeUse For
BasicSimple category comparisons
HorizontalLong category names, many categories
StackedComposition + total values
MultipleDirect comparison of multiple series
NegativePositive/negative values (profit/loss)
LabelWhen exact values needed inline

Area Chart

TypeUse For
BasicVolume/magnitude over time
GradientMore visually appealing areas
LinearExact data without smoothing
StepDiscrete value changes, pricing
StackedComposition over time
Stacked ExpandedProportion changes (100% height)

Line Chart

TypeUse For
BasicTrends over time
LinearExact data points
StepDiscrete values
MultipleComparing multiple series
DotsEmphasizing individual data points
LabelInline value display

Pie/Donut Chart

TypeUse For
Full PieProportions of a whole
DonutProportions with center info
InteractiveInteractive with center metric display
Stacked DonutMultiple concentric rings

Radar Chart

TypeUse For
BasicMulti-dimensional comparison
MultipleComparing entities across dimensions
Lines OnlyCleaner look for multiple series
Grid CircleTraditional radar appearance

Radial Chart

TypeUse For
BasicMultiple progress metrics
TextSingle metric with center text
StackedComparing multiple metrics

Chart Colors

Use these CSS variables for data series:

TokenTailwind VariableUse For
Chart 1--chart-1Primary series (blue)
Chart 2--chart-2Second series (green)
Chart 3--chart-3Third series (tc-orange)
Chart 4--chart-4Fourth series (red-brown)
Chart 5--chart-5Fifth series (pink)
// In chart config
const chartConfig = {
  desktop: {
    label: "Desktop",
    color: "hsl(var(--chart-1))",
  },
  mobile: {
    label: "Mobile", 
    color: "hsl(var(--chart-2))",
  },
}

Common Patterns

Basic Bar Chart

import { Bar, BarChart, XAxis, YAxis } from "recharts"

const data = [
  { month: "Jan", value: 186 },
  { month: "Feb", value: 305 },
  { month: "Mar", value: 237 },
]

const chartConfig = {
  value: { label: "Value", color: "hsl(var(--chart-1))" },
}

<ChartContainer config={chartConfig}>
  <BarChart data={data}>
    <XAxis dataKey="month" />
    <YAxis />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Bar dataKey="value" fill="var(--color-value)" radius={4} />
  </BarChart>
</ChartContainer>

Area Chart with Gradient

import { Area, AreaChart, XAxis, YAxis } from "recharts"

<ChartContainer config={chartConfig}>
  <AreaChart data={data}>
    <defs>
      <linearGradient id="fillValue" x1="0" y1="0" x2="0" y2="1">
        <stop offset="5%" stopColor="var(--color-value)" stopOpacity={0.8} />
        <stop offset="95%" stopColor="var(--color-value)" stopOpacity={0.1} />
      </linearGradient>
    </defs>
    <XAxis dataKey="month" />
    <YAxis />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Area
      dataKey="value"
      type="monotone"
      fill="url(#fillValue)"
      stroke="var(--color-value)"
    />
  </AreaChart>
</ChartContainer>

Line Chart with Multiple Series

import { Line, LineChart, XAxis, YAxis } from "recharts"

const chartConfig = {
  desktop: { label: "Desktop", color: "hsl(var(--chart-1))" },
  mobile: { label: "Mobile", color: "hsl(var(--chart-2))" },
}

<ChartContainer config={chartConfig}>
  <LineChart data={data}>
    <XAxis dataKey="month" />
    <YAxis />
    <ChartTooltip content={<ChartTooltipContent />} />
    <ChartLegend content={<ChartLegendContent />} />
    <Line dataKey="desktop" stroke="var(--color-desktop)" />
    <Line dataKey="mobile" stroke="var(--color-mobile)" />
  </LineChart>
</ChartContainer>

Donut Chart

import { Pie, PieChart } from "recharts"

const data = [
  { name: "Chrome", value: 275, fill: "var(--color-chrome)" },
  { name: "Safari", value: 200, fill: "var(--color-safari)" },
  { name: "Firefox", value: 187, fill: "var(--color-firefox)" },
]

<ChartContainer config={chartConfig}>
  <PieChart>
    <ChartTooltip content={<ChartTooltipContent />} />
    <Pie
      data={data}
      dataKey="value"
      nameKey="name"
      innerRadius={60}
      outerRadius={80}
    />
  </PieChart>
</ChartContainer>

Tooltip & Legend

// Basic tooltip
<ChartTooltip content={<ChartTooltipContent />} />

// Tooltip with indicator
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />

// Legend
<ChartLegend content={<ChartLegendContent />} />

Accessibility

  • Built on Recharts — not a Radix primitive, requires manual a11y
  • Provide text alternative: use aria-label or aria-describedby on chart container
  • Consider providing a data table fallback for screen readers
  • Chart tooltips may not be accessible to keyboard users

Gotchas

ProblemSolution
Colors not applyingUse CSS variables in config: "hsl(var(--chart-1))"
Tooltip not showingWrap chart in ChartContainer with config
Legend items wrong colorEnsure config keys match data keys
Grid lines too prominentUse stroke="hsl(var(--border))" with low opacity
Charts not responsiveChartContainer handles responsiveness

See Also

  • Related Components: Card (chart wrapper), Table (tabular data complement)
  • Tokens: Colors — Chart color tokens

Last updated: February 9, 2026