Skip to content

Charts

A collection of chart components built on Recharts with Darwin UI styling.

Installation

import {
AreaChart,
BarChart,
LineChart,
PieChart,
DonutChart,
StackedBarChart
} from '@smc/darwin-ui';

Charts

AreaChart

const data = [
{ month: 'Jan', revenue: 4500 },
{ month: 'Feb', revenue: 5200 },
{ month: 'Mar', revenue: 4800 },
];
<AreaChart
data={data}
xAxisKey="month"
dataKey="revenue"
height={300}
/>

BarChart

<BarChart
data={data}
xAxisKey="month"
dataKey="revenue"
height={300}
/>

LineChart

<LineChart
data={data}
xAxisKey="month"
dataKey="revenue"
height={300}
/>

PieChart

const pieData = [
{ name: 'Desktop', value: 45 },
{ name: 'Mobile', value: 35 },
{ name: 'Tablet', value: 20 },
];
<PieChart data={pieData} height={300} />

DonutChart

<DonutChart data={pieData} height={300} />

StackedBarChart

const stackedData = [
{ month: 'Jan', desktop: 400, mobile: 200 },
{ month: 'Feb', desktop: 500, mobile: 300 },
];
<StackedBarChart
data={stackedData}
xAxisKey="month"
dataKeys={['desktop', 'mobile']}
height={300}
/>

Color Palette

Charts use Darwin UI’s color palette:

ColorHexUse
Blue#60a5faPrimary data
Green#34d399Positive values
Yellow#fbbf24Warnings
Red#f87171Negative values
Purple#a78bfaAccent data
Teal#2dd4bfSecondary data

API Reference

Common Props

PropTypeDefaultDescription
dataany[]-Chart data
heightnumber300Chart height
xAxisKeystring-X-axis data key
dataKeystring-Y-axis data key
colorstring-Custom color