An area chart for visualizing trends, stacked contributions, and confidence bands with Skia-accelerated rendering.
AreaChartruns on the UI thread. React renders the parts once; data changes, layout, animations, scrubbing and labels update through Reanimated shared values without re-rendering. Rendering a chart requires the optionalreact-native-skiapeer (>=3.0.0).
import { AreaChart } from 'heroui-native-pro';<AreaChart data={...} xKey="...">
<AreaChart.Grid />
<AreaChart.XAxis />
<AreaChart.YAxis />
<AreaChart.Area dataKey="..." />
<AreaChart.Range lowKey="..." highKey="..." />
<AreaChart.Line dataKey="..." />
<AreaChart.Crosshair />
<AreaChart.Indicator dataKey="..." />
<AreaChart.Tooltip dataKey="..." />
</AreaChart>LineChart.stack id stack in render order.lowKey, highKey) with faint bound lines.LineChart.Line.LineChart.<AreaChart data={DATA} xKey="month" className="h-48">
<AreaChart.Grid />
<AreaChart.XAxis />
<AreaChart.YAxis />
<AreaChart.Area dataKey="revenue" curveType="monotoneX" />
<AreaChart.Line dataKey="revenue" curveType="monotoneX" />
</AreaChart>opacity takes a number for a solid fill, or { top, bottom } for a vertical gradient (default { top: 0.7, bottom: 0.02 }). strokeWidth adds an outline along the top edge in the fill color.
<AreaChart.Area dataKey="revenue" opacity={0.2} strokeWidth={1.5} />Give every layer the same stack id. The first one rendered is the bottom layer.
<AreaChart data={DATA} xKey="month" yDomain={{ min: 0 }} className="h-56">
<AreaChart.Grid dashed={[4, 4]} />
<AreaChart.YAxis format={formatCompact} />
<AreaChart.Area
dataKey="organic"
stack="traffic"
colorClassName="accent-chart-4"
strokeWidth={1.5}
/>
<AreaChart.Area
dataKey="paidAds"
stack="traffic"
colorClassName="accent-chart-3"
strokeWidth={1.5}
/>
<AreaChart.Area
dataKey="referral"
stack="traffic"
colorClassName="accent-chart-2"
strokeWidth={1.5}
/>
</AreaChart>Stacked layers default to a lighter gradient ({ top: 0.5, bottom: 0.05 }).
<AreaChart data={TEMPERATURES} xKey="month" className="h-56">
<AreaChart.YAxis format={formatCelsius} />
<AreaChart.Range lowKey="low" highKey="high" curveType="natural" />
<AreaChart.Line dataKey="avg" curveType="natural" />
</AreaChart>animateIn grows the area out of its baseline on mount (down for values below it); change resetKey to replay it. On Line it draws the stroke in.
<AreaChart.Area dataKey="revenue" animateIn={1200} resetKey={replay} />
<AreaChart.Line dataKey="revenue" animateIn={1200} resetKey={replay} /><AreaChart data={DATA} xKey="month" className="h-48">
<AreaChart.Area dataKey="revenue" />
<AreaChart.Crosshair />
<AreaChart.Indicator dataKey="revenue" />
<AreaChart.Tooltip dataKey="revenue" followPoint />
</AreaChart>See LineChart for formatters, data transitions, onSelect and custom tooltip content; they work the same way.
import { Card } from 'heroui-native';
import { AreaChart } from 'heroui-native-pro';
import { View } from 'react-native';
const DATA = [
{ month: 'Jan', revenue: 4200 },
{ month: 'Feb', revenue: 5800 },
{ month: 'Mar', revenue: 4900 },
{ month: 'Apr', revenue: 7200 },
{ month: 'May', revenue: 6100 },
{ month: 'Jun', revenue: 8400 },
];
const formatThousands = (value: number) => {
'worklet';
return `$${(value / 1000).toFixed(0)}k`;
};
export default function RevenueChart() {
return (
<View className="flex-1 justify-center px-5">
<Card>
<Card.Header>
<Card.Title>Monthly Revenue</Card.Title>
</Card.Header>
<Card.Body>
<AreaChart data={DATA} xKey="month" className="h-[200px]">
<AreaChart.Grid />
<AreaChart.XAxis />
<AreaChart.YAxis format={formatThousands} />
<AreaChart.Area dataKey="revenue" curveType="monotoneX" />
<AreaChart.Line dataKey="revenue" curveType="monotoneX" />
<AreaChart.Crosshair />
<AreaChart.Indicator dataKey="revenue" />
<AreaChart.Tooltip dataKey="revenue" followPoint />
</AreaChart>
</Card.Body>
</Card>
</View>
);
}Same props as LineChart.
| prop | type | default | description |
|---|---|---|---|
dataKey | string | - | Field of each row to plot. |
curveType | CurveType | 'linear' | Curve through the points. |
colorClassName | string | 'accent-chart-3' | Uniwind color class for the fill. |
stack | string | - | Areas with the same id stack in render order. |
opacity | number | { top: number; bottom: number } | { top: 0.7, bottom: 0.02 } | Solid fill opacity, or a vertical gradient. |
strokeWidth | number | 0 | Outline along the top edge, in the fill color. |
animateIn | boolean | number | - | Grows the series out of its baseline on mount (down for values below it); a number sets the duration in ms. |
resetKey | unknown | - | Changing it replays animateIn. |
| prop | type | default | description |
|---|---|---|---|
lowKey | string | - | Field holding the lower bound of each row. |
highKey | string | - | Field holding the upper bound of each row. |
curveType | CurveType | 'linear' | Curve through the points. |
colorClassName | string | 'accent-chart-3' | Uniwind color class for the band. |
fillOpacity | number | 0.18 | Opacity of the band fill. |
edgeOpacity | number | 0.55 | Opacity of the bound lines; 0 hides them. |
strokeWidth | number | 1 | Width of the bound lines. |
Same as on LineChart.