The HorizontalBarGroup component is used within a CartesianChart with orientation="horizontal" to render multiple numeric series as separate bars within the same category row.
Key behaviors:
- Each category group is centered on the category's position.
- Bars within a group are offset vertically.
- Positive values extend to the right from zero; negative values extend to the left.
- For stacked horizontal bars instead of grouped ones, use
HorizontalStackedBar.
import { CartesianChart, HorizontalBarGroup } from "victory-native";
const DATA = [
{ category: "North", product: 72, services: 44 },
{ category: "West", product: 58, services: 62 },
{ category: "South", product: 41, services: 38 },
];
export function MyChart() {
return (
<CartesianChart
orientation="horizontal"
data={DATA}
xKey="category"
yKeys={["product", "services"]}
domain={{ x: [0, 100] }}
domainPadding={{ top: 32, bottom: 32, right: 24 }}
xAxis={{ tickCount: 5 }}
yAxis={[{ yKeys: ["product", "services"] }]}
>
{({ points, chartBounds }) => (
<HorizontalBarGroup
chartBounds={chartBounds}
betweenGroupPadding={0.35}
withinGroupPadding={0.2}
roundedCorners={{ topRight: 6, bottomRight: 6 }}
>
<HorizontalBarGroup.Bar points={points.product} color="teal" />
<HorizontalBarGroup.Bar points={points.services} color="purple" />
</HorizontalBarGroup>
)}
</CartesianChart>
);
}