/
1.1k
Sponsor

Dither Area Chart

Composable dithered area charts with layered fills, dots, axes, stacking, bloom, and keyboard interaction

Terminal

Installation

$ pnpm dlx shadcn@latest add @termcn/opentui/dither-area-chart

Usage

import {
  Area,
  AreaChart,
  Grid,
  Legend,
  Tooltip,
  XAxis,
  YAxis,
} from "@/components/ui/dither-area-chart";
import type { ChartConfig } from "@/components/ui/dither-area-chart";
const data = [
  { month: "Jan", desktop: 38, mobile: 22 },
  { month: "Feb", desktop: 52, mobile: 31 },
  { month: "Mar", desktop: 47, mobile: 35 },
];
 
const config = {
  desktop: { color: "blue", label: "Desktop" },
  mobile: { color: "pink", label: "Mobile" },
} satisfies ChartConfig;
 
<AreaChart config={config} data={data} height={12} width={56}>
  <Grid horizontal />
  <XAxis dataKey="month" />
  <YAxis tickCount={4} />
  <Area dataKey="desktop" variant="gradient" />
  <Area dataKey="mobile" variant="dotted" />
  <Legend align="left" />
  <Tooltip labelKey="month" />
</AreaChart>;

Examples

Fill variants

Set variant on each Area to choose a gradient, dotted, hatched, or solid fill.

Terminal

Stacking modes

Use stackType="stacked" for cumulative values or stackType="percent" for normalized proportions.

Terminal

API Reference

PropTypeDefault
dataTData[]required
configChartConfigrequired
widthnumber56
heightnumber12
stackType"default" | "stacked" | "percent""default"
bloom"off" | "low" | "high" | "aura" | BloomConfig"off"
markerIndexnumber | nullnull
interactivebooleantrue
noColorbooleanfalse
screenReaderModebooleanfalse

Use left/right to inspect points, up/down to focus a series, Enter to select, Escape to clear, and R to replay animation. H/J/K/L are supported too.