# React Native Gauge Chart (Pro)

> A React Native gauge for iOS, Android and the web: one value on a speedometer arc with colored ranges, a target mark, a filled arc or a needle that sweeps to each new value, and a screen-reader summary of the value, its share and its range.

# Gauge Pro

One value against its range: a health score, a credit score, storage used, a speed. `segments` color the track by range (poor, fair, good) and the fill takes the color of the range it's in, with the range's name under the value. `target` marks a goal on the track, and `showNeedle` swaps the fill for a needle. The arc sweeps to each new value.

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

## Live data

```tsx live
import { useEffect, useState } from 'react';
import { View } from 'react-native';
import { GaugeChart } from '@patine-ui/pro';

const health = [
  { to: 40, label: 'Poor', color: '#DC2626' },
  { to: 70, label: 'Fair', color: '#D97706' },
  { to: 100, label: 'Good', color: '#16A34A' },
];

export default function Example() {
  const [score, setScore] = useState(72);
  useEffect(() => {
    const id = setInterval(() => setScore(() => Math.round(15 + Math.random() * 85)), 1800);
    return () => clearInterval(id);
  }, []);
  return (
    <View style={{ width: 380, flexDirection: 'row', gap: 12 }}>
      <GaugeChart value={score} segments={health} target={80} accessibilityLabel="Account health" height={170} style={{ flex: 1 }} />
      <GaugeChart value={score} segments={health} showNeedle accessibilityLabel="Account health" height={170} style={{ flex: 1 }} />
    </View>
  );
}
```

## Example: a monthly budget

A spending app's Groceries budget: the gauge fills with what's spent, turns amber past 80% and red past the limit, and the needle-free arc keeps it readable at a glance. Add an expense to watch it move.

```tsx live wide
import { useState } from 'react';
import { View } from 'react-native';
import { Button, HStack, Text } from 'patine-ui';
import { GaugeChart } from '@patine-ui/pro';

const LIMIT = 450;

export default function Example() {
  const [spent, setSpent] = useState(318);
  return (
    <View style={{ width: '100%', maxWidth: 360, gap: 8 }}>
      <Text weight="semibold">Groceries · November</Text>
      <GaugeChart
        value={spent}
        max={LIMIT * 1.2}
        segments={[
          { to: LIMIT * 0.8, color: '#16A34A', label: 'On track' },
          { to: LIMIT, color: '#D97706', label: 'Close to the limit' },
          { to: LIMIT * 1.2, color: '#DC2626', label: 'Over budget' },
        ]}
        target={LIMIT}
        label={`€${spent} of €${LIMIT}`}
        height={180}
        accessibilityLabel={`Groceries: €${spent} of €${LIMIT}`}
      />
      <HStack gap="sm" justify="center">
        <Button size="sm" variant="outline" onPress={() => setSpent((s) => s + 42)}>Add €42 shop</Button>
        <Button size="sm" variant="ghost" onPress={() => setSpent(318)}>Reset</Button>
      </HStack>
    </View>
  );
}
```

## Gallery

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

export default function Example() {
  return (
    <View style={{ width: 380, flexDirection: 'row', gap: 12 }}>
      <GaugeChart value={0.68} max={1} valueFormat="percent" label="Storage" startAngle={-90} endAngle={90} height={110} style={{ flex: 1 }} />
      <GaugeChart value={742} min={300} max={850} label="Credit score" thickness={0.08} height={150} style={{ flex: 1 }} />
    </View>
  );
}
```

## Props

The [shared chart props](./charts#shared-props) except `data`, the legend and tooltip props, and:

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` | `number` | — | |
| `min` / `max` | `number` | `0` / `100` | |
| `segments` | `{ to, color?, label? }[]` | — | Colored ranges, each from the last one's end up to `to`. |
| `target` | `number` | — | A mark on the track. |
| `label` | `string` | the range's label | Under the value. |
| `startAngle` / `endAngle` | `number` | `-120` / `120` | Degrees clockwise from 12 o'clock. `-90`/`90` is a half circle. |
| `thickness` | `number` | `0.16` | The track's width as a share of the radius. |
| `showNeedle` | `boolean` | `false` | A needle over the colored ranges instead of a filled arc. |
| `showMinMax` | `boolean` | `true` | `min` and `max` at the arc's ends. |
| `color` | `string` | the range's, or primary | The fill. |
| `height` | `number` | `200` | |
