# React Native Combo Chart: Bars and Lines (Pro)

> A React Native combo chart for iOS, Android and the web: bars and lines or areas over the same categories, a second value axis on the right, stacked bars, dashed targets, tooltips for every series, legend toggles, animated data and screen-reader summaries.

# 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.

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

## Live data

```tsx live
import { useState } from 'react';
import { View } from 'react-native';
import { Button } from 'patine-ui';
import { ComboChart } from '@patine-ui/pro';

const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'];
const roll = () => months.map((month) => {
  const revenue = 20000 + Math.round(Math.random() * 30000);
  const cost = Math.round(revenue * (0.45 + Math.random() * 0.35));
  return { month, revenue, cost, margin: (revenue - cost) / revenue };
});

export default function Example() {
  const [data, setData] = useState(roll);
  return (
    <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>
  );
}
```

## 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.

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

const data = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].map((day, i) => ({
  day,
  online: 40 + ((i * 17) % 30),
  store: 20 + ((i * 11) % 25),
  target: 75,
  trend: 55 + i * 4,
}));

export default function Example() {
  return (
    <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](./charts#shared-props), the [cartesian props](./charts#cartesian-props), and:

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `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. |
| `stacked` | `boolean` | `false` | Stack the bar series. |
| `curve` | `Curve` | `'monotone'` | The lines' curve. |
| `rightFormatter` | `(value: number) => string` | the value format | The right axis's labels. |
