Skip to content

ChartArea

The ChartArea component displays data as filled areas with customizable styling, tooltips, and legends. Built with ApexCharts.

import { ChartArea } from '@fintech-sandpit/ui/react';
const data = [
{ name: 'Jan', revenue: 4000, expenses: 2400 },
{ name: 'Feb', revenue: 3000, expenses: 1398 },
{ name: 'Mar', revenue: 2000, expenses: 9800 },
];
const series = [
{ name: 'Revenue', dataKey: 'revenue' },
{ name: 'Expenses', dataKey: 'expenses' },
];
const colors = ['#14b8a6', '#a855f7'];
return (
<ChartArea
data={data}
series={series}
height="400px"
colors={colors}
showTooltip={true}
showLegend={true}
/>
);
NameTypeDefaultDescription
dataChartDataItem[]Array of data objects where each object represents a data point with multiple value properties
seriesArray<{ name: string; dataKey: string }>Array of series objects defining which data keys to display as areas
widthCssUnit'100%'Width of the chart container (CSS unit string like ‘100%’, ‘400px’, ‘50rem’)
heightCssUnit'400px'Height of the chart container (CSS unit string like ‘400px’, ‘50vh’)
legendPositionLegendPosition'bottom'Position of the legend
showTooltipbooleantrueWhether to display tooltips on hover
showLegendbooleantrueWhether to display the legend
colorsstring[]Array of colors for the chart areas
xAxisKeystring'name'Key in data objects to use for X-axis labels
type CssUnit = `${number}${'px' | 'em' | 'rem' | 'vw' | 'vh' | 'vmin' | 'vmax' | '%'}`
type ChartDataItem = {
[key: string]: string | number;
}
type LegendPosition = 'top' | 'right' | 'bottom' | 'left'