# @salmonui/charts/range-selector API reference

> 11 exported symbols of @salmonui/charts/range-selector: 2 components, 1 function, 6 interfaces and 2 types.

Canonical: https://salmonui.dev/docs/reference/charts/range-selector

```ts
import { … } from '@salmonui/charts/range-selector';
```

## Components

### PeriodSelector

Kind: component

Page: https://salmonui.dev/docs/reference/charts/range-selector/PeriodSelector

```ts
function PeriodSelector(props: PeriodSelectorProps): ReactNode;
```

Props: [`PeriodSelectorProps`](https://salmonui.dev/docs/reference/charts/range-selector/PeriodSelectorProps) (its members are the props)

### RangeSelector

Kind: component

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeSelector

```ts
function RangeSelector(props: RangeSelectorProps): ReactNode;
```

Props: [`RangeSelectorProps`](https://salmonui.dev/docs/reference/charts/range-selector/RangeSelectorProps) (its members are the props)

## Functions

### periodRange

Kind: function

Page: https://salmonui.dev/docs/reference/charts/range-selector/periodRange

```ts
function periodRange(period: Period, end: number, min: number, timeZone?: string): [
    number,
    number
];
```

The [start, end] a period selects for data ending at `end` and starting at
`min` (epoch ms or numbers). `ytd` starts on January 1 of the end's year in
`timeZone`; the result never starts before `min`.

## Interfaces

### Period

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/Period

```ts
interface Period {
    readonly id: string;
    readonly unit: PeriodUnit;
    readonly count?: number | undefined;
    readonly label: string;
}
```

Members (4):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `id` | `readonly id: string;` |  |  |
| `unit` | `readonly unit: PeriodUnit;` |  |  |
| `count` | `readonly count?: number \| undefined;` | optional | Number of units (ignored by `ytd` and `all`). Default 1. |
| `label` | `readonly label: string;` |  |  |

### PeriodSelectorProps

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/PeriodSelectorProps

```ts
interface PeriodSelectorProps {
    readonly periods: readonly Period[];
    readonly value?: string | null | undefined;
    readonly defaultValue?: string | null | undefined;
    readonly onValueChange?: ((value: string | null, event: {
        readonly source: 'pointer' | 'keyboard' | 'touch' | 'api';
        readonly reason: string;
    }) => void) | undefined;
    readonly 'aria-label'?: string | undefined;
    readonly size?: 'sm' | 'md' | 'lg' | undefined;
    readonly disabled?: boolean | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
}
```

Members (9):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `periods` | `readonly periods: readonly Period[];` |  |  |
| `value` | `readonly value?: string \| null \| undefined;` | optional |  |
| `defaultValue` | `readonly defaultValue?: string \| null \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: string \| null, event: {     readonly source: 'pointer' \| 'keyboard' \| 'touch' \| 'api';     readonly reason: string; }) => void) \| undefined;` | optional |  |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional | Accessible name of the radio group. Default "Period". |
| `size` | `readonly size?: 'sm' \| 'md' \| 'lg' \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |

### RangeChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeChangeEvent

```ts
interface RangeChangeEvent {
    readonly source: 'pointer' | 'keyboard' | 'touch' | 'api';
    readonly reason: 'thumb' | 'band' | 'track' | 'keyboard' | 'period' | 'reset';
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'pointer' \| 'keyboard' \| 'touch' \| 'api';` |  |  |
| `reason` | `readonly reason: 'thumb' \| 'band' \| 'track' \| 'keyboard' \| 'period' \| 'reset';` |  |  |

### RangeSelectorApi

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeSelectorApi

```ts
interface RangeSelectorApi {
    readonly element: HTMLDivElement | null;
    focus(): void;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `element` | `readonly element: HTMLDivElement \| null;` |  |  |
| `focus` | `focus(): void;` |  |  |

### RangeSelectorProps

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeSelectorProps

```ts
interface RangeSelectorProps extends Omit<RangeModelInput, 'min' | 'max'> {
    readonly data?: readonly ChartDatum[] | undefined;
    readonly series?: readonly RangeSeries[] | undefined;
    readonly min?: number | Date | undefined;
    readonly max?: number | Date | undefined;
    readonly value?: RangeValue | undefined;
    readonly defaultValue?: RangeValue | undefined;
    readonly onValueChange?: ((value: RangeValue, event: RangeChangeEvent) => void) | undefined;
    readonly onValueCommit?: ((value: RangeValue, event: RangeChangeEvent) => void) | undefined;
    readonly snap?: boolean | 'interval' | undefined;
    readonly tooltip?: boolean | 'always' | {
        readonly format?: ChartFormat | ((value: number) => string);
    } | undefined;
    readonly periods?: readonly Period[] | undefined;
    readonly periodSelector?: boolean | {
        readonly position?: 'top' | 'bottom';
    } | undefined;
    readonly gridLines?: boolean | undefined;
    readonly ticks?: boolean | undefined;
    readonly name?: string | undefined;
    readonly disabled?: boolean | undefined;
    readonly 'aria-label'?: string | undefined;
    readonly text?: Partial<{
        readonly start: string;
        readonly end: string;
        readonly band: string;
        readonly range: (from: string, to: string) => string;
    }> | undefined;
    readonly width?: number | undefined;
    readonly height?: number | undefined;
    readonly onResize?: ((size: {
        readonly width: number;
        readonly height: number;
    }) => void) | undefined;
    readonly animated?: boolean | undefined;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly ref?: Ref<RangeSelectorApi> | undefined;
}
```

Members (37):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `readonly data?: readonly ChartDatum[] \| undefined;` | optional |  |
| `series` | `readonly series?: readonly RangeSeries[] \| undefined;` | optional |  |
| `min` | `readonly min?: number \| Date \| undefined;` | optional |  |
| `max` | `readonly max?: number \| Date \| undefined;` | optional |  |
| `value` | `readonly value?: RangeValue \| undefined;` | optional |  |
| `defaultValue` | `readonly defaultValue?: RangeValue \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: RangeValue, event: RangeChangeEvent) => void) \| undefined;` | optional | During a drag, once per frame; also after keyboard and period changes. |
| `onValueCommit` | `readonly onValueCommit?: ((value: RangeValue, event: RangeChangeEvent) => void) \| undefined;` | optional | On release (and after every keyboard step). |
| `snap` | `readonly snap?: boolean \| 'interval' \| undefined;` | optional |  |
| `tooltip` | `readonly tooltip?: boolean \| 'always' \| {     readonly format?: ChartFormat \| ((value: number) => string); } \| undefined;` | optional |  |
| `periods` | `readonly periods?: readonly Period[] \| undefined;` | optional |  |
| `periodSelector` | `readonly periodSelector?: boolean \| {     readonly position?: 'top' \| 'bottom'; } \| undefined;` | optional |  |
| `gridLines` | `readonly gridLines?: boolean \| undefined;` | optional |  |
| `ticks` | `readonly ticks?: boolean \| undefined;` | optional |  |
| `name` | `readonly name?: string \| undefined;` | optional |  |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `aria-label` | `readonly 'aria-label'?: string \| undefined;` | optional |  |
| `text` | `readonly text?: Partial<{     readonly start: string;     readonly end: string;     readonly band: string;     readonly range: (from: string, to: string) => string; }> \| undefined;` | optional |  |
| `width` | `readonly width?: number \| undefined;` | optional |  |
| `height` | `readonly height?: number \| undefined;` | optional | Drawing height in px. Without it the height comes from CSS: the surface fills a root whose height CSS fixes, else 80 px. |
| `onResize` | `readonly onResize?: ((size: {     readonly width: number;     readonly height: number; }) => void) \| undefined;` | optional | Called after a measured size change. |
| `animated` | `readonly animated?: boolean \| undefined;` | optional | Entrance and update transitions (`@salmonui/charts/viz-animations.css`); default true. |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `ref` | `readonly ref?: Ref<RangeSelectorApi> \| undefined;` | optional |  |
| `xField` | `xField?: string;` | optional, inherited |  |
| `yField` | `yField?: string;` | optional, inherited |  |
| `scale` | `scale?: "linear" \| "log" \| "time";` | optional, inherited |  |
| `interval` | `interval?: number \| TimeInterval;` | optional, inherited |  |
| `base` | `base?: number;` | optional, inherited |  |
| `format` | `format?: ChartFormat;` | optional, inherited |  |
| `formatLabel` | `formatLabel?: ((value: number) => string);` | optional, inherited |  |
| `labelPosition` | `labelPosition?: "inside" \| "outside";` | optional, inherited |  |
| `labelOverlap` | `labelOverlap?: "hide" \| "none" \| "rotate45" \| "rotate90" \| "stagger" \| "trim" \| "wrap";` | optional, inherited |  |
| `groupLabels` | `groupLabels?: { readonly unit: TimeUnit; readonly align?: "center" \| "start" \| undefined; readonly format?: ChartFormat \| undefined; };` | optional, inherited |  |
| `locale` | `locale?: string;` | optional, inherited |  |
| `timeZone` | `timeZone?: string;` | optional, inherited |  |

### RangeSeries

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeSeries

```ts
interface RangeSeries {
    readonly type?: 'line' | 'area' | 'stepLine' | undefined;
    readonly data?: readonly ChartDatum[] | undefined;
    readonly xField?: string | undefined;
    readonly yField?: string | undefined;
    readonly color?: string | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `type` | `readonly type?: 'line' \| 'area' \| 'stepLine' \| undefined;` | optional |  |
| `data` | `readonly data?: readonly ChartDatum[] \| undefined;` | optional |  |
| `xField` | `readonly xField?: string \| undefined;` | optional |  |
| `yField` | `readonly yField?: string \| undefined;` | optional |  |
| `color` | `readonly color?: string \| undefined;` | optional |  |

## Types

### PeriodUnit

Kind: type

Page: https://salmonui.dev/docs/reference/charts/range-selector/PeriodUnit

```ts
type PeriodUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'ytd' | 'all';
```

### RangeValue

Kind: type

Page: https://salmonui.dev/docs/reference/charts/range-selector/RangeValue

```ts
type RangeValue = readonly [
    number,
    number
];
```

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `0` | `0: number;` | inherited |  |
| `1` | `1: number;` | inherited |  |
| `length` | `length: 2;` | inherited |  |
