# @salmonui/charts/gauge API reference

> 24 exported symbols of @salmonui/charts/gauge: 3 components, 13 interfaces and 8 types.

Canonical: https://salmonui.dev/docs/reference/charts/gauge

```ts
import { … } from '@salmonui/charts/gauge';
```

## Components

### Gauge

Kind: component

Page: https://salmonui.dev/docs/reference/charts/gauge/Gauge

```ts
function Gauge(props: GaugeProps): ReactNode;
```

Props: [`GaugeProps`](https://salmonui.dev/docs/reference/charts/gauge/GaugeProps) (its members are the props)

### GaugeAxis

Kind: component

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeAxis

```ts
function GaugeAxis(_props: GaugeAxis): null;

interface GaugeAxis {
    readonly id?: string | undefined;
    readonly min?: number | undefined;
    readonly max?: number | undefined;
    readonly startAngle?: number | undefined;
    readonly endAngle?: number | undefined;
    readonly direction?: GaugeDirection | undefined;
    readonly radius?: number | undefined;
    readonly reversed?: boolean | undefined;
    readonly position?: 'start' | 'end' | undefined;
    readonly edgeLabels?: 'shift' | 'hide' | undefined;
    readonly ticks?: GaugeTicks | undefined;
    readonly labels?: GaugeLabels | undefined;
    readonly ranges?: readonly GaugeRange[] | undefined;
    readonly annotations?: readonly GaugeAnnotation[] | undefined;
    readonly line?: boolean | undefined;
    readonly formatLabel?: ((value: number) => string) | undefined;
}
```

The JSX forms of `axes` and `pointers` (same fields as an entry).
They render nothing: `Gauge` reads the props of its direct children, in
order, so `axis` indexes count `GaugeAxis` children.

### GaugePointer

Kind: component

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugePointer

```ts
function GaugePointer(_props: GaugePointer): null;

interface GaugePointer {
    readonly id?: string | undefined;
    readonly axis?: number | undefined;
    readonly type?: GaugePointerType | undefined;
    readonly value?: number | undefined;
    readonly defaultValue?: number | undefined;
    readonly length?: number | undefined;
    readonly tail?: number | undefined;
    readonly cap?: number | undefined;
    readonly width?: number | undefined;
    readonly shape?: GaugeMarkerShape | undefined;
    readonly text?: string | undefined;
    readonly placement?: 'near' | 'center' | 'far' | undefined;
    readonly position?: GaugeTickPosition | undefined;
    readonly color?: string | undefined;
    readonly draggable?: boolean | undefined;
    readonly step?: number | undefined;
    readonly label?: string | undefined;
    readonly valueText?: ((value: number) => string) | undefined;
    readonly render?: ((ctx: {
        readonly value: number;
        readonly x: number;
        readonly y: number;
    }) => unknown) | undefined;
}
```

## Interfaces

### GaugeAnnotation

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeAnnotation

```ts
interface GaugeAnnotation {
    readonly id?: string | undefined;
    readonly angle?: number | undefined;
    readonly radius?: number | undefined;
    readonly value?: number | undefined;
    readonly x?: number | undefined;
    readonly y?: number | undefined;
    readonly content: unknown;
    readonly rotate?: boolean | undefined;
    readonly label?: string | undefined;
}
```

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `angle` | `readonly angle?: number \| undefined;` | optional | Circular: angle in degrees (clockwise from 12 o'clock) and radius as a fraction of the axis radius. |
| `radius` | `readonly radius?: number \| undefined;` | optional |  |
| `value` | `readonly value?: number \| undefined;` | optional | Linear: position along the axis in data units, plus a pixel offset. |
| `x` | `readonly x?: number \| undefined;` | optional |  |
| `y` | `readonly y?: number \| undefined;` | optional |  |
| `content` | `readonly content: unknown;` |  |  |
| `rotate` | `readonly rotate?: boolean \| undefined;` | optional |  |
| `label` | `readonly label?: string \| undefined;` | optional | Tooltip text (`tooltip.targets` with `'annotation'`). |

### GaugeApi

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeApi

```ts
interface GaugeApi {
    readonly element: HTMLElement | null;
    export(options?: GaugeExportOptions): Promise<void>;
    toBlob(format?: 'png' | 'jpeg' | 'svg'): Promise<Blob>;
    toDataURL(format?: 'png' | 'jpeg' | 'svg'): Promise<string>;
    toSVGString(): string;
    print(): Promise<void>;
    focus(): void;
}
```

Instance reached through `ref`.

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `readonly element: HTMLElement \| null;` |  |  |
| `export` | `export(options?: GaugeExportOptions): Promise<void>;` |  |  |
| `toBlob` | `toBlob(format?: 'png' \| 'jpeg' \| 'svg'): Promise<Blob>;` |  |  |
| `toDataURL` | `toDataURL(format?: 'png' \| 'jpeg' \| 'svg'): Promise<string>;` |  |  |
| `toSVGString` | `toSVGString(): string;` |  |  |
| `print` | `print(): Promise<void>;` |  |  |
| `focus` | `focus(): void;` |  | Focuses the first slider thumb (draggable pointer or range end). |

### GaugeChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeChangeEvent

```ts
interface GaugeChangeEvent {
    readonly source: GaugeChangeSource;
    readonly reason: 'drag' | 'keyboard' | 'release' | 'legend';
}
```

Frozen change event.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: GaugeChangeSource;` |  |  |
| `reason` | `readonly reason: 'drag' \| 'keyboard' \| 'release' \| 'legend';` |  |  |

### GaugeExportOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeExportOptions

```ts
interface GaugeExportOptions {
    readonly format?: 'png' | 'jpeg' | 'svg' | undefined;
    readonly fileName?: string | undefined;
    readonly scale?: number | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `format` | `readonly format?: 'png' \| 'jpeg' \| 'svg' \| undefined;` | optional |  |
| `fileName` | `readonly fileName?: string \| undefined;` | optional |  |
| `scale` | `readonly scale?: number \| undefined;` | optional |  |

### GaugeLabels

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeLabels

```ts
interface GaugeLabels {
    readonly position?: 'inside' | 'outside' | undefined;
    readonly rotate?: boolean | undefined;
    readonly hide?: 'first' | 'last' | undefined;
    readonly showLast?: boolean | undefined;
    readonly overlap?: 'hide' | 'show' | undefined;
    readonly format?: Intl.NumberFormatOptions | undefined;
    readonly hidden?: boolean | undefined;
}
```

Members (7):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `position` | `readonly position?: 'inside' \| 'outside' \| undefined;` | optional |  |
| `rotate` | `readonly rotate?: boolean \| undefined;` | optional | Rotate labels along the arc (circular). |
| `hide` | `readonly hide?: 'first' \| 'last' \| undefined;` | optional |  |
| `showLast` | `readonly showLast?: boolean \| undefined;` | optional | Label the maximum even when it is not on the interval. |
| `overlap` | `readonly overlap?: 'hide' \| 'show' \| undefined;` | optional | `'hide'` (default) drops labels that would overlap the previous one. |
| `format` | `readonly format?: Intl.NumberFormatOptions \| undefined;` | optional |  |
| `hidden` | `readonly hidden?: boolean \| undefined;` | optional |  |

### GaugeLegendOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeLegendOptions

```ts
interface GaugeLegendOptions {
    readonly position?: 'top' | 'bottom' | undefined;
    readonly toggle?: boolean | undefined;
    readonly title?: string | undefined;
}
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `position` | `readonly position?: 'top' \| 'bottom' \| undefined;` | optional |  |
| `toggle` | `readonly toggle?: boolean \| undefined;` | optional | Clicking an item hides its range (default true). |
| `title` | `readonly title?: string \| undefined;` | optional |  |

### GaugePointerValueChange

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugePointerValueChange

```ts
interface GaugePointerValueChange {
    readonly pointerId: string;
    readonly value: number;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pointerId` | `readonly pointerId: string;` |  |  |
| `value` | `readonly value: number;` |  |  |

### GaugeProps

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeProps

```ts
interface GaugeProps extends GaugeDomProps {
    readonly shape?: GaugeShape | undefined;
    readonly orientation?: 'horizontal' | 'vertical' | undefined;
    readonly container?: GaugeContainer | undefined;
    readonly axes?: readonly GaugeAxis[] | undefined;
    readonly pointers?: readonly GaugePointer[] | undefined;
    readonly children?: ReactNode;
    readonly width?: number | undefined;
    readonly height?: number | undefined;
    readonly center?: readonly [
        number,
        number
    ] | undefined;
    readonly rangeGap?: number | undefined;
    readonly title?: string | undefined;
    readonly subtitle?: string | undefined;
    readonly description?: string | undefined;
    readonly locale?: string | undefined;
    readonly text?: Partial<GaugeText> | undefined;
    readonly palette?: readonly string[] | undefined;
    readonly legend?: boolean | GaugeLegendOptions | undefined;
    readonly hiddenRanges?: readonly string[] | undefined;
    readonly defaultHiddenRanges?: readonly string[] | undefined;
    readonly onHiddenRangesChange?: ((ids: readonly string[], event: GaugeChangeEvent) => void) | undefined;
    readonly tooltip?: boolean | {
        readonly targets?: readonly GaugeTooltipTarget[] | undefined;
        readonly render?: ((ctx: GaugeTooltipContext) => ReactNode) | undefined;
    } | undefined;
    readonly onPointerValueChange?: ((change: GaugePointerValueChange, event: GaugeChangeEvent) => void) | undefined;
    readonly onPointerValueCommit?: ((change: GaugePointerValueChange, event: GaugeChangeEvent) => void) | undefined;
    readonly onRangeChange?: ((change: GaugeRangeChange, event: GaugeChangeEvent) => void) | undefined;
    readonly animated?: boolean | undefined;
    readonly showDataTable?: boolean | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly ref?: Ref<GaugeApi> | undefined;
}
```

Members (29):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `shape` | `readonly shape?: GaugeShape \| undefined;` | optional |  |
| `orientation` | `readonly orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional | Linear gauges: default `'horizontal'`. |
| `container` | `readonly container?: GaugeContainer \| undefined;` | optional | Linear gauges: the track drawn behind pointers (default `'normal'`). |
| `axes` | `readonly axes?: readonly GaugeAxis[] \| undefined;` | optional | Axes (default one axis 0 to 100); or `GaugeAxis` children, read when `axes` is absent. |
| `pointers` | `readonly pointers?: readonly GaugePointer[] \| undefined;` | optional | Pointers; or `GaugePointer` children, read when `pointers` is absent. |
| `children` | `readonly children?: ReactNode;` | optional | `GaugeAxis` and `GaugePointer` elements (the JSX form of `axes` and `pointers`). |
| `width` | `readonly width?: number \| undefined;` | optional | Drawing size in px; the SVG scales to its container through `viewBox`. |
| `height` | `readonly height?: number \| undefined;` | optional |  |
| `center` | `readonly center?: readonly [     number,     number ] \| undefined;` | optional | Circular center as fractions of the drawing (default `[0.5, 0.5]`). |
| `rangeGap` | `readonly rangeGap?: number \| undefined;` | optional | Gap between the axis line and inside ranges, in px (default 0). |
| `title` | `readonly title?: string \| undefined;` | optional |  |
| `subtitle` | `readonly subtitle?: string \| undefined;` | optional |  |
| `description` | `readonly description?: string \| undefined;` | optional | Replaces the automatic summary. |
| `locale` | `readonly locale?: string \| undefined;` | optional |  |
| `text` | `readonly text?: Partial<GaugeText> \| undefined;` | optional | Built-in text (over the nearest `LocaleProvider`'s `gauge` entry). |
| `palette` | `readonly palette?: readonly string[] \| undefined;` | optional | Data colors for ranges without a color. |
| `legend` | `readonly legend?: boolean \| GaugeLegendOptions \| undefined;` | optional | Range legend. |
| `hiddenRanges` | `readonly hiddenRanges?: readonly string[] \| undefined;` | optional |  |
| `defaultHiddenRanges` | `readonly defaultHiddenRanges?: readonly string[] \| undefined;` | optional |  |
| `onHiddenRangesChange` | `readonly onHiddenRangesChange?: ((ids: readonly string[], event: GaugeChangeEvent) => void) \| undefined;` | optional |  |
| `tooltip` | `readonly tooltip?: boolean \| {     readonly targets?: readonly GaugeTooltipTarget[] \| undefined;     readonly render?: ((ctx: GaugeTooltipContext) => ReactNode) \| undefined; } \| undefined;` | optional |  |
| `onPointerValueChange` | `readonly onPointerValueChange?: ((change: GaugePointerValueChange, event: GaugeChangeEvent) => void) \| undefined;` | optional | Called during a drag and per keyboard step with the proposed value. |
| `onPointerValueCommit` | `readonly onPointerValueCommit?: ((change: GaugePointerValueChange, event: GaugeChangeEvent) => void) \| undefined;` | optional | Called on release (and per keyboard step). |
| `onRangeChange` | `readonly onRangeChange?: ((change: GaugeRangeChange, event: GaugeChangeEvent) => void) \| undefined;` | optional | A draggable range end moved (drag frames, release, keyboard steps); ranges are reactive props, so apply it. |
| `animated` | `readonly animated?: boolean \| undefined;` | optional | Pointer entrance and update transition after hydration (default true); off under `prefers-reduced-motion`. |
| `showDataTable` | `readonly showDataTable?: boolean \| undefined;` | optional | Shows the accessible data table under the gauge. |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<GaugeApi> \| undefined;` | optional |  |

### GaugeRange

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeRange

```ts
interface GaugeRange {
    readonly id?: string | undefined;
    readonly from: number;
    readonly to: number;
    readonly width?: number | readonly [
        number,
        number
    ] | undefined;
    readonly position?: GaugeTickPosition | undefined;
    readonly color?: string | undefined;
    readonly label?: string | undefined;
    readonly draggable?: boolean | undefined;
    readonly step?: number | undefined;
}
```

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `from` | `readonly from: number;` |  |  |
| `to` | `readonly to: number;` |  |  |
| `width` | `readonly width?: number \| readonly [     number,     number ] \| undefined;` | optional | Band width in px, or `[start, end]` for a tapered band. Default 10. |
| `position` | `readonly position?: GaugeTickPosition \| undefined;` | optional |  |
| `color` | `readonly color?: string \| undefined;` | optional | Data color; default the categorical palette slot. |
| `label` | `readonly label?: string \| undefined;` | optional | Legend and tooltip text; default `from–to`. |
| `draggable` | `readonly draggable?: boolean \| undefined;` | optional | Both ends become slider thumbs; `onRangeChange` reports the moved range. |
| `step` | `readonly step?: number \| undefined;` | optional | Keyboard and drag step of the thumbs (default 1 % of the axis span). |

### GaugeRangeChange

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeRangeChange

```ts
interface GaugeRangeChange {
    readonly rangeId: string;
    readonly from: number;
    readonly to: number;
}
```

`onRangeChange` payload: the range with its moved end.

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `rangeId` | `readonly rangeId: string;` |  |  |
| `from` | `readonly from: number;` |  |  |
| `to` | `readonly to: number;` |  |  |

### GaugeText

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeText

```ts
interface GaugeText {
    readonly gauge: string;
    readonly pointer: (gauge: string, n: number) => string;
    readonly ranges: string;
}
```

Built-in text of a Gauge (`text` prop; the `gauge` entry of a `LocaleProvider` catalog).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `gauge` | `readonly gauge: string;` |  | Name of the gauge and its meter when there is no `title`. Default `"Gauge"`. |
| `pointer` | `readonly pointer: (gauge: string, n: number) => string;` |  | Name of pointer `n` (from 1) of a gauge with several unlabelled pointers. |
| `ranges` | `readonly ranges: string;` |  | Legend name without `legend.title`. |

### GaugeTicks

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeTicks

```ts
interface GaugeTicks {
    readonly interval?: number | undefined;
    readonly minor?: number | undefined;
    readonly position?: GaugeTickPosition | undefined;
    readonly rangeColor?: boolean | undefined;
    readonly hidden?: boolean | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `interval` | `readonly interval?: number \| undefined;` | optional | Major tick interval; default a nice step for about 5 to 10 ticks. |
| `minor` | `readonly minor?: number \| undefined;` | optional | Minor tick interval (default none). |
| `position` | `readonly position?: GaugeTickPosition \| undefined;` | optional |  |
| `rangeColor` | `readonly rangeColor?: boolean \| undefined;` | optional | Color ticks inside a range with that range's color. |
| `hidden` | `readonly hidden?: boolean \| undefined;` | optional |  |

### GaugeTooltipContext

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeTooltipContext

```ts
interface GaugeTooltipContext {
    readonly target: GaugeTooltipTarget;
    readonly id: string;
    readonly value?: number | undefined;
    readonly from?: number | undefined;
    readonly to?: number | undefined;
    readonly label: string;
}
```

Members (6):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `target` | `readonly target: GaugeTooltipTarget;` |  |  |
| `id` | `readonly id: string;` |  |  |
| `value` | `readonly value?: number \| undefined;` | optional |  |
| `from` | `readonly from?: number \| undefined;` | optional |  |
| `to` | `readonly to?: number \| undefined;` | optional |  |
| `label` | `readonly label: string;` |  |  |

## Types

### GaugeChangeSource

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeChangeSource

```ts
type GaugeChangeSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

### GaugeContainer

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeContainer

```ts
type GaugeContainer = 'none' | 'normal' | 'thermometer' | 'rounded';
```

### GaugeDirection

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeDirection

```ts
type GaugeDirection = 'clockwise' | 'counterclockwise';
```

### GaugeMarkerShape

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeMarkerShape

```ts
type GaugeMarkerShape = 'circle' | 'rectangle' | 'triangle' | 'invertedTriangle' | 'diamond' | 'arrow' | 'invertedArrow' | 'text';
```

### GaugePointerType

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugePointerType

```ts
type GaugePointerType = 'needle' | 'bar' | 'marker';
```

### GaugeShape

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeShape

```ts
type GaugeShape = 'circular' | 'linear';
```

### GaugeTickPosition

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeTickPosition

```ts
type GaugeTickPosition = 'inside' | 'outside' | 'cross';
```

### GaugeTooltipTarget

Kind: type

Page: https://salmonui.dev/docs/reference/charts/gauge/GaugeTooltipTarget

```ts
type GaugeTooltipTarget = 'pointer' | 'range' | 'annotation';
```
