A React Native composed chart that combines bar, line, and area series for multi-metric mobile dashboards.
ComposedChartruns 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 { ComposedChart } from 'heroui-native-pro';<ComposedChart data={...} xKey="...">
<ComposedChart.Grid />
<ComposedChart.XAxis />
<ComposedChart.YAxis />
<ComposedChart.YAxis side="right" />
<ComposedChart.Bar dataKey="..." />
<ComposedChart.Area dataKey="..." />
<ComposedChart.Range lowKey="..." highKey="..." />
<ComposedChart.Line dataKey="..." axis="right" />
<ComposedChart.Crosshair />
<ComposedChart.Indicator dataKey="..." />
<ComposedChart.Tooltip />
</ComposedChart>BarChart.Bar: grouped, or stacked with a shared stack id.LineChart and AreaChart.side="right" labels the right axis.LineChart.Plot a series against the right axis with axis="right", and label it with a YAxis side="right".
<ComposedChart data={REVENUE_ORDERS} xKey="month" className="h-[220px]">
<ComposedChart.Grid />
<ComposedChart.XAxis />
<ComposedChart.YAxis format={formatThousands} />
<ComposedChart.YAxis side="right" />
<ComposedChart.Bar dataKey="revenue" barSize={16} />
<ComposedChart.Line
dataKey="orders"
axis="right"
curveType="monotoneX"
colorClassName="accent-foreground"
/>
</ComposedChart>The right axis shares the left axis's grid lines. Its range is chosen so that every grid line gets a round value (for example 300, 400 … 900) and its data still fits.
yDomainRight lists values the right axis must cover besides its data. A percentage axis that should run from 0 to 100:
<ComposedChart data={AI_SHARE} xKey="day" yDomainRight={{ min: 0, max: 100 }}>
<ComposedChart.YAxis side="right" format={formatPercent} />
<ComposedChart.Line dataKey="aiPct" axis="right" />
</ComposedChart>yDomain fixes either end of the left axis. Like on BarChart, the left axis includes zero when the chart has bars, and its ends are rounded out to whole ticks.
<ComposedChart.Bar dataKey="ide" stack="code" colorClassName="accent-chart-4" />
<ComposedChart.Bar dataKey="cli" stack="code" colorClassName="accent-chart-2" />
<ComposedChart.Bar dataKey="other" stack="code" colorClassName="accent-chart-1" />
<ComposedChart.Line dataKey="aiPct" axis="right" /><ComposedChart data={SESSIONS} xKey="month" className="h-[220px]">
<ComposedChart.Area dataKey="sessions" curveType="monotoneX" />
<ComposedChart.Line dataKey="sessions" curveType="monotoneX" />
<ComposedChart.Line
dataKey="target"
curveType="monotoneX"
colorClassName="accent-chart-1"
dashed={[6, 3]}
/>
</ComposedChart>Build the content from ChartTooltipLabel and ChartTooltipValue. With a worklet format (or none) their text is written from the UI thread (see Tooltip text on the UI thread); the tooltip's position follows on the UI thread too.
import { ChartTooltipLabel, ChartTooltipValue } from 'heroui-native-pro';
<ComposedChart.Crosshair />
<ComposedChart.Indicator dataKey="orders" />
<ComposedChart.Tooltip className="gap-1 rounded-xl bg-overlay p-2.5">
<ChartTooltipLabel xKey="month" className="text-xs font-semibold" />
<ChartTooltipValue dataKey="revenue" format={formatThousands} />
<ChartTooltipValue dataKey="orders" />
</ComposedChart.Tooltip>import { Card } from 'heroui-native';
import { ComposedChart, formatCompact } from 'heroui-native-pro';
import { View } from 'react-native';
const DATA = [
{ month: 'Jan', orders: 320, revenue: 4200 },
{ month: 'Feb', orders: 450, revenue: 5800 },
{ month: 'Mar', orders: 380, revenue: 4900 },
{ month: 'Apr', orders: 520, revenue: 7200 },
{ month: 'May', orders: 480, revenue: 6100 },
{ month: 'Jun', orders: 600, revenue: 8400 },
];
const formatThousands = (value: number) => {
'worklet';
return `$${formatCompact(value)}`;
};
export default function RevenueOrdersChart() {
return (
<View className="flex-1 justify-center px-5">
<Card>
<Card.Header>
<Card.Title>Revenue & Orders</Card.Title>
</Card.Header>
<Card.Body>
<ComposedChart data={DATA} xKey="month" className="h-[220px]">
<ComposedChart.Grid />
<ComposedChart.XAxis />
<ComposedChart.YAxis format={formatThousands} />
<ComposedChart.YAxis side="right" />
<ComposedChart.Bar dataKey="revenue" barSize={16} />
<ComposedChart.Line
dataKey="orders"
axis="right"
curveType="monotoneX"
colorClassName="accent-foreground"
/>
<ComposedChart.Crosshair />
<ComposedChart.Indicator
dataKey="orders"
colorClassName="accent-foreground"
/>
<ComposedChart.Tooltip dataKey="revenue" format={formatThousands} />
</ComposedChart>
</Card.Body>
</Card>
</View>
);
}Same props as LineChart, plus:
| prop | type | default | description |
|---|---|---|---|
yDomainRight | { min?: number; max?: number } | - | Values the right axis must cover besides its data (its ends stay round). |
domainPadding | number | 0 | Pixels between the plot edges and the outermost values. |
Same as BarChart.Bar.
Same as LineChart.Line, AreaChart.Area and AreaChart.Range, plus:
| prop | type | default | description |
|---|---|---|---|
axis | 'left' | 'right' | 'left' | Y-axis the series is plotted against. |
Same as LineChart.YAxis, plus:
| prop | type | default | description |
|---|---|---|---|
side | 'left' | 'right' | 'left' | right labels the right axis, on the left axis's grid lines. |
Same as on LineChart.