AreaChart

A filled area chart for emphasising volume and cumulative values over time.

Installation

npx @obi/ui add area-chart

Requires: recharts

Preview

Usage

import { AreaChart } from '@/src/components/Charts/Charts';

const data = [
  { month: 'Jan', users: 800, sessions: 1200 },
  { month: 'Feb', users: 1200, sessions: 1800 },
  { month: 'Mar', users: 1000, sessions: 1500 },
  { month: 'Apr', users: 1400, sessions: 2100 },
  { month: 'May', users: 1800, sessions: 2700 },
  { month: 'Jun', users: 2200, sessions: 3300 },
];

export default function Example() {
  return (
    <AreaChart
      data={data}
      xKey="month"
      series={[
        { key: 'users', label: 'Users' },
        { key: 'sessions', label: 'Sessions' },
      ]}
    />
  );
}

Props

NameTypeDefaultDescription
dataChartDataPoint[]Array of data objects.
xKeystringKey to use as the x-axis label.
seriesChartSeries[]Areas to render.
stackedbooleanfalseStack areas on top of each other.
heightnumber240Chart height in px.
showLegendbooleantrueWhether to show the legend.
showGridbooleantrueWhether to show the background grid.
classNamestring""Extra classes applied to the container.