# Gauge

> A half-circle meter for one number. A native Pyzed component for Python desktop GUIs, with a live preview, code examples and its API.

Source: https://albakore.github.io/pyzed/library/gauge/

:::tip[In plain words]
A half circle like a car's speedometer that shows one number.
:::

Shows one number between `min` and `max` on an arc, like a speedometer: CPU use, temperature, a score. `thresholds` recolor the arc as the value climbs.

`ui.gauge` · Category: [Data](https://albakore.github.io/pyzed/library/#data) · [Full reference →](https://albakore.github.io/pyzed/reference/ui/#gauge)

**Code:**

```python
pz.row([
    ui.gauge(42, unit="%", label="CPU"),
    ui.gauge(78, unit="°C", label="GPU", thresholds=[(70, "warning"), (90, "error")]),
], spacing=24)
```

:::note[New]
This component was added recently. Tell us how it works for you in the [issue tracker](https://github.com/albakore/pyzed/issues).
:::

## When to use

- On dashboards, for a value with a known range and limits.
- For a value over time, use a [Line chart](https://albakore.github.io/pyzed/library/line-chart/).

## Usage

```python
import pyzed as pz
from pyzed import ui

pz.row([
    ui.gauge(42, unit="%", label="CPU"),
    ui.gauge(78, unit="°C", label="GPU", thresholds=[(70, "warning"), (90, "error")]),
], spacing=24)
```

## Variants

:::note[About these captures]
Each capture is recorded by pyzed itself, off-screen at 2x, in Pyzed Dark or Pyzed Light to match this site's theme, and cropped to the component so it shows at its real size. The pointer hovers, presses or types into it; a component that does not react to the pointer cycles through a few themes. With reduced motion you see the first frame. Open **Code** under a capture to see the snippet that draws it; free names such as `on_save` stand for your own callbacks.
:::

### Options

```python
ui.gauge(64, unit="%")
```

```python
ui.gauge(88, max=200, unit=" km/h", label="Speed", size=180)
```

```python
ui.gauge(93, unit="%", label="Disk", thresholds=[(70, "warning"), (90, "error")])
```

```python
ui.gauge(7.5, max=10, label="Score", tint="success")
```

## Events

Gauge has no events of its own: it shows what you give it. Like every widget it also has the **18 common events** (`click`, `double_click`, `right_click`, `mouse_enter`, `drag`, `key_down`, `resize`…), attached with `.on(...)`: see [Events](https://albakore.github.io/pyzed/guides/events/) and [Events of every component](https://albakore.github.io/pyzed/library/events/).

## Properties and API

### `ui.gauge`

```python
gauge(
    value,
    *,
    min=0.0,
    max=100.0,
    size=140,
    thickness=12,
    unit='',
    label=None,
    tint='accent',
    thresholds=None,
    theme=None,
)
```

A half-circle meter for one number, like a speedometer. `thresholds` recolor the arc as the value climbs.

| Property | Default | Description |
| --- | --- | --- |
| `value` | *required* | The number shown. |
| `min` | `0.0` | Value at the left end. |
| `max` | `100.0` | Value at the right end. |
| `size` | `140` | Width in pixels. |
| `thickness` | `12` | Width of the arc. |
| `unit` | `""` | Text after the number (`"%"`, `"°C"`). |
| `label` | `None` | Text under the number. |
| `tint` | `"accent"` | Semantic color: `"accent"`, `"error"`, `"warning"`, `"success"`, `"info"` or a token. |
| `thresholds` | `None` | `(from_value, color)` pairs, such as `[(70, "warning"), (90, "error")]`. |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

[Full reference →](https://albakore.github.io/pyzed/reference/ui/#gauge)

## Related

- [Progress ring](https://albakore.github.io/pyzed/library/progress-ring/): A round progress bar.
- [Stat](https://albakore.github.io/pyzed/library/stat/): A dashboard number with change and sparkline.
- [Donut](https://albakore.github.io/pyzed/library/donut/): A donut chart with a label in the middle.
