Skip to main content

Combo chart Pro

Bars and lines over the same categories: revenue as bars with the margin as a line, orders against a target, rainfall against temperature. Each series picks its type ('bar', 'line' or 'area'); a line with axis: 'right' reads against its own value axis on the right, so a percentage can ride over dollars.

import { ComboChart } from '@patine-ui/pro';

Live data​

Loading…
<View style={{ width: 380, gap: 8 }}>
  <Button size="sm" variant="outline" onPress={() => setData(roll())} style={{ alignSelf: 'flex-end' }}>Shuffle</Button>
  <ComboChart
    data={data}
    xKey="month"
    series={[
      { key: 'revenue', label: 'Revenue' },
      { key: 'cost', label: 'Cost' },
      { key: 'margin', label: 'Margin', type: 'line', axis: 'right' },
    ]}
    valueFormat="currency"
    rightFormatter={(v) => `${Math.round(v * 100)}%`}
    accessibilityLabel="Revenue, cost and margin by month"
  />
</View>

Try the props​

Props
valueFormat
grid
legendPosition
design
<ComboChart
data={sales}
xKey="month"
series={[{ key: 'revenue', label: 'Revenue' }, { key: 'cost', label: 'Cost' }, { key: 'margin', label: 'Margin', type: 'line', axis: 'right' }]}
rightFormatter={(v) => `${Math.round(v * 100)}%`}
valueFormat="currency"
/>

Example: orders against a target​

A shop's week: online and in-store orders stack in each day's bar, the area under them is the trend, and the dashed line is the daily target.

Loading…
<ComboChart
  stacked
  data={data}
  xKey="day"
  series={[
    { key: 'online', label: 'Online' },
    { key: 'store', label: 'In store' },
    { key: 'trend', label: 'Trend', type: 'area' },
    { key: 'target', label: 'Target', type: 'line', dashed: true },
  ]}
  legendPosition="top"
  style={{ width: '100%', maxWidth: 380 }}
/>

Props​

The shared chart props, the cartesian props, and:

PropTypeDefaultDescription
series[].type'bar' | 'line' | 'area''bar'How the series draws.
series[].axis'left' | 'right''left'Lines and areas only: read against a second axis on the right.
stackedbooleanfalseStack the bar series.
curveCurve'monotone'The lines' curve.
rightFormatter(value: number) => stringthe value formatThe right axis's labels.