# @salmonui/charts/stock-chart API reference

> 9 exported symbols of @salmonui/charts/stock-chart: 1 component, 1 function, 3 interfaces and 4 types.

Canonical: https://salmonui.dev/docs/reference/charts/stock-chart

```ts
import { … } from '@salmonui/charts/stock-chart';
```

## Components

### StockChart

Kind: component

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockChart

```ts
function StockChart(props: StockChartProps): ReactNode;
```

Props: [`StockChartProps`](https://salmonui.dev/docs/reference/charts/stock-chart/StockChartProps) (its members are the props)

## Functions

### indicatorSeries

Kind: function

Page: https://salmonui.dev/docs/reference/charts/stock-chart/indicatorSeries

```ts
function indicatorSeries(kind: IndicatorKind, data: readonly Record<string, unknown>[], f: {
    x: string;
    open?: string | undefined;
    high?: string | undefined;
    low?: string | undefined;
    close: string;
    volume?: string | undefined;
}): ChartSeriesOptions[];
```

Indicator series computed from the OHLC columns on a secondary `indicator` axis.

## Interfaces

### StockChangeEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockChangeEvent

```ts
interface StockChangeEvent<R extends string> {
    readonly source: 'pointer' | 'keyboard' | 'touch' | 'api';
    readonly reason: R;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `readonly source: 'pointer' \| 'keyboard' \| 'touch' \| 'api';` |  |  |
| `reason` | `readonly reason: R;` |  |  |

### StockChartProps

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockChartProps

```ts
interface StockChartProps extends Omit<ChartProps, 'series' | 'zoomRange' | 'defaultZoomRange' | 'onZoomRangeChange' | 'indicators'> {
    readonly data: NonNullable<ChartProps['data']>;
    readonly xField: string;
    readonly openField?: string | undefined;
    readonly highField?: string | undefined;
    readonly lowField?: string | undefined;
    readonly closeField: string;
    readonly volumeField?: string | undefined;
    readonly name?: string | undefined;
    readonly seriesType?: StockSeriesType | undefined;
    readonly defaultSeriesType?: StockSeriesType | undefined;
    readonly onSeriesTypeChange?: ((type: StockSeriesType, event: StockChangeEvent<'toolbar'>) => void) | undefined;
    readonly range?: RangeValue | undefined;
    readonly defaultRange?: RangeValue | undefined;
    readonly onRangeChange?: ((range: RangeValue, event: StockChangeEvent<string>) => void) | undefined;
    readonly periods?: readonly Period[] | undefined;
    readonly period?: string | null | undefined;
    readonly defaultPeriod?: string | null | undefined;
    readonly onPeriodChange?: ((period: string | null, event: StockChangeEvent<string>) => void) | undefined;
    readonly periodSelector?: boolean | {
        readonly position?: 'top' | 'bottom';
    } | undefined;
    readonly navigator?: boolean | Partial<RangeSelectorProps> | undefined;
    readonly indicators?: readonly IndicatorKind[] | undefined;
    readonly defaultIndicators?: readonly IndicatorKind[] | undefined;
    readonly onIndicatorsChange?: ((kinds: readonly IndicatorKind[], event: StockChangeEvent<'toolbar'>) => void) | undefined;
    readonly trendlines?: readonly TrendlineKind[] | undefined;
    readonly defaultTrendlines?: readonly TrendlineKind[] | undefined;
    readonly onTrendlinesChange?: ((kinds: readonly TrendlineKind[], event: StockChangeEvent<'toolbar'>) => void) | undefined;
    readonly toolbar?: false | {
        readonly seriesTypes?: readonly StockSeriesType[] | undefined;
        readonly indicators?: readonly IndicatorKind[] | undefined;
        readonly trendlines?: readonly TrendlineKind[] | undefined;
        readonly export?: readonly StockExportFormat[] | undefined;
    } | undefined;
    readonly events?: readonly StockEvent[] | undefined;
    readonly renderEvent?: ((event: StockEvent) => ReactNode) | undefined;
    readonly customRange?: boolean | undefined;
    readonly stockText?: Partial<{
        readonly seriesType: string;
        readonly indicators: string;
        readonly trendlines: string;
        readonly export: string;
        readonly toolbar: string;
        readonly reset: string;
        readonly customRange: string;
        readonly period: string;
        readonly allPeriod: string;
        readonly events: string;
    }> | undefined;
}
```

Members (88):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `data` | `readonly data: NonNullable<ChartProps['data']>;` |  |  |
| `xField` | `readonly xField: string;` |  |  |
| `openField` | `readonly openField?: string \| undefined;` | optional |  |
| `highField` | `readonly highField?: string \| undefined;` | optional |  |
| `lowField` | `readonly lowField?: string \| undefined;` | optional |  |
| `closeField` | `readonly closeField: string;` |  |  |
| `volumeField` | `readonly volumeField?: string \| undefined;` | optional |  |
| `name` | `readonly name?: string \| undefined;` | optional |  |
| `seriesType` | `readonly seriesType?: StockSeriesType \| undefined;` | optional |  |
| `defaultSeriesType` | `readonly defaultSeriesType?: StockSeriesType \| undefined;` | optional |  |
| `onSeriesTypeChange` | `readonly onSeriesTypeChange?: ((type: StockSeriesType, event: StockChangeEvent<'toolbar'>) => void) \| undefined;` | optional |  |
| `range` | `readonly range?: RangeValue \| undefined;` | optional |  |
| `defaultRange` | `readonly defaultRange?: RangeValue \| undefined;` | optional |  |
| `onRangeChange` | `readonly onRangeChange?: ((range: RangeValue, event: StockChangeEvent<string>) => void) \| undefined;` | optional |  |
| `periods` | `readonly periods?: readonly Period[] \| undefined;` | optional |  |
| `period` | `readonly period?: string \| null \| undefined;` | optional | Selected period id (`null`: none). A selected period holds the range at the data end; a controlled `range` wins. |
| `defaultPeriod` | `readonly defaultPeriod?: string \| null \| undefined;` | optional |  |
| `onPeriodChange` | `readonly onPeriodChange?: ((period: string \| null, event: StockChangeEvent<string>) => void) \| undefined;` | optional |  |
| `periodSelector` | `readonly periodSelector?: boolean \| {     readonly position?: 'top' \| 'bottom'; } \| undefined;` | optional |  |
| `navigator` | `readonly navigator?: boolean \| Partial<RangeSelectorProps> \| undefined;` | optional |  |
| `indicators` | `readonly indicators?: readonly IndicatorKind[] \| undefined;` | optional |  |
| `defaultIndicators` | `readonly defaultIndicators?: readonly IndicatorKind[] \| undefined;` | optional |  |
| `onIndicatorsChange` | `readonly onIndicatorsChange?: ((kinds: readonly IndicatorKind[], event: StockChangeEvent<'toolbar'>) => void) \| undefined;` | optional |  |
| `trendlines` | `readonly trendlines?: readonly TrendlineKind[] \| undefined;` | optional |  |
| `defaultTrendlines` | `readonly defaultTrendlines?: readonly TrendlineKind[] \| undefined;` | optional |  |
| `onTrendlinesChange` | `readonly onTrendlinesChange?: ((kinds: readonly TrendlineKind[], event: StockChangeEvent<'toolbar'>) => void) \| undefined;` | optional |  |
| `toolbar` | `readonly toolbar?: false \| {     readonly seriesTypes?: readonly StockSeriesType[] \| undefined;     readonly indicators?: readonly IndicatorKind[] \| undefined;     readonly trendlines?: readonly TrendlineKind[] \| undefined;     readonly export?: readonly StockExportFormat[] \| undefined; } \| undefined;` | optional |  |
| `events` | `readonly events?: readonly StockEvent[] \| undefined;` | optional |  |
| `renderEvent` | `readonly renderEvent?: ((event: StockEvent) => ReactNode) \| undefined;` | optional |  |
| `customRange` | `readonly customRange?: boolean \| undefined;` | optional | A date range field in the toolbar; its days are UTC calendar days. |
| `stockText` | `readonly stockText?: Partial<{     readonly seriesType: string;     readonly indicators: string;     readonly trendlines: string;     readonly export: string;     readonly toolbar: string;     readonly reset: string;     readonly customRange: string;     readonly period: string;     readonly allPeriod: string;     readonly events: string; }> \| undefined;` | optional |  |
| `aria-label` | `aria-label?: string;` | optional, inherited | Accessible name of the chart; wins over `title` and the generated summary. |
| `aria-labelledby` | `aria-labelledby?: string;` | optional, inherited | Id of the element naming the chart; wins over `aria-label`. |
| `xAxis` | `xAxis?: ChartAxisOptions;` | optional, inherited |  |
| `yAxis` | `yAxis?: ChartAxisOptions;` | optional, inherited |  |
| `axes` | `axes?: readonly (ChartAxisOptions & { readonly id: string; readonly direction: "x" \| "y"; })[];` | optional, inherited | Additional axes referenced by `series.xAxis` / `series.yAxis` (id required). |
| `panes` | `panes?: { readonly rows?: readonly ChartPaneSize[]; readonly columns?: readonly ChartPaneSize[]; };` | optional, inherited |  |
| `orientation` | `orientation?: "horizontal" \| "vertical";` | optional, inherited |  |
| `coordinate` | `coordinate?: "cartesian" \| "polar" \| "radar";` | optional, inherited | Polar (circles) or radar (polygons) coordinates; x is the angle, y the radius. |
| `radius` | `radius?: number;` | optional, inherited | Polar radius as a fraction (0..1) of the largest circle that fits. |
| `features` | `features?: readonly ChartFeature[];` | optional, inherited | Preloaded features from `@salmonui/charts/chart/features`: `polar` renders polar charts on the server. |
| `grouping` | `grouping?: "overlap" \| "sideBySide";` | optional, inherited |  |
| `title` | `title?: string;` | optional, inherited |  |
| `subtitle` | `subtitle?: string;` | optional, inherited |  |
| `description` | `description?: string;` | optional, inherited |  |
| `legend` | `legend?: boolean \| ChartLegendOptions;` | optional, inherited |  |
| `tooltip` | `tooltip?: boolean \| ChartTooltipOptions;` | optional, inherited |  |
| `crosshair` | `crosshair?: boolean \| ChartCrosshairOptions;` | optional, inherited |  |
| `zoom` | `zoom?: boolean \| ChartZoomOptions;` | optional, inherited |  |
| `onVisibleRangeChange` | `onVisibleRangeChange?: ((change: { readonly axisId: string; readonly range: readonly [number, number]; }) => void);` | optional, inherited | The committed visible range of a continuous axis changed: fetch data for it. Fires on commit, never per frame. |
| `hiddenSeries` | `hiddenSeries?: readonly string[];` | optional, inherited |  |
| `defaultHiddenSeries` | `defaultHiddenSeries?: readonly string[];` | optional, inherited |  |
| `onHiddenSeriesChange` | `onHiddenSeriesChange?: ((ids: readonly string[], event: ChartChangeEvent<"legend">) => void);` | optional, inherited |  |
| `selection` | `selection?: boolean \| { readonly mode?: "cluster" \| "lasso" \| "point" \| "range" \| "series"; readonly multiple?: boolean; readonly axis?: "x" \| "xy" \| "y"; };` | optional, inherited |  |
| `onRangeSelect` | `onRangeSelect?: ((selection: { readonly ranges: Readonly<Record<string, readonly [number, number]>>; readonly points: readonly ChartPointRef[]; }, event: ChartChangeEvent<"lasso" \| "range">) => void);` | optional, inherited | Range and lasso selection finished: `ranges` per axis id (range mode) and the enclosed points. |
| `selectedPoints` | `selectedPoints?: readonly ChartPointRef[];` | optional, inherited |  |
| `defaultSelectedPoints` | `defaultSelectedPoints?: readonly ChartPointRef[];` | optional, inherited |  |
| `onSelectedPointsChange` | `onSelectedPointsChange?: ((points: readonly ChartPointRef[], event: ChartChangeEvent<"click" \| "keyboard" \| "lasso" \| "range" \| "sync">) => void);` | optional, inherited |  |
| `highlight` | `highlight?: "cluster" \| "point" \| "series" \| false;` | optional, inherited |  |
| `onPointClick` | `onPointClick?: ((ctx: ChartPointContext, event: MouseEvent<Element, MouseEvent>) => void);` | optional, inherited |  |
| `onPlotClick` | `onPlotClick?: ((point: ChartPlotPoint, event: MouseEvent<Element, MouseEvent>) => void);` | optional, inherited | Any click on the plot, with data coordinates. |
| `onPlotPointerMove` | `onPlotPointerMove?: ((point: ChartPlotPoint, event: PointerEvent<Element>) => void);` | optional, inherited | Pointer moves over the plot, with data coordinates; called per move (keep it cheap). |
| `onPointHover` | `onPointHover?: ((ctx: ChartPointContext \| null) => void);` | optional, inherited |  |
| `onPointChange` | `onPointChange?: ((change: { readonly seriesId: string; readonly index: number; readonly value: number; }, event: ChartChangeEvent<"drag" \| "keyboard">) => void);` | optional, inherited | An editable point was dragged or moved by keyboard. |
| `onPointDoubleClick` | `onPointDoubleClick?: ((ctx: ChartPointContext, event: MouseEvent<Element, MouseEvent>) => void);` | optional, inherited |  |
| `onAxisLabelClick` | `onAxisLabelClick?: ((ctx: ChartAxisLabelContext, event: MouseEvent<Element, MouseEvent>) => void);` | optional, inherited | A tick label was clicked. |
| `onAxisLabelGroupClick` | `onAxisLabelGroupClick?: ((ctx: { readonly axisId: string; readonly group: number; readonly level: number; readonly label: string; }, event: MouseEvent<Element, MouseEvent>) => void);` | optional, inherited | A multi-level label cell was clicked. |
| `onResize` | `onResize?: ((size: { readonly width: number; readonly height: number; }) => void);` | optional, inherited |  |
| `annotations` | `annotations?: readonly ChartAnnotation[];` | optional, inherited |  |
| `stackLabels` | `stackLabels?: boolean \| { readonly format?: ChartFormat \| undefined; };` | optional, inherited |  |
| `palette` | `palette?: readonly string[];` | optional, inherited |  |
| `colorRanges` | `colorRanges?: readonly ChartColorRange[];` | optional, inherited | Point colors by y value range, shared with `legend.mode: 'range' \| 'gradient'`. |
| `renderer` | `renderer?: "auto" \| "canvas" \| "svg";` | optional, inherited |  |
| `decimation` | `decimation?: "auto" \| "lttb" \| "minMax" \| false;` | optional, inherited |  |
| `accessibleTable` | `accessibleTable?: boolean;` | optional, inherited |  |
| `showDataTable` | `showDataTable?: boolean;` | optional, inherited |  |
| `renderEmpty` | `renderEmpty?: (() => ReactNode);` | optional, inherited |  |
| `animated` | `animated?: boolean;` | optional, inherited |  |
| `locale` | `locale?: string;` | optional, inherited |  |
| `timeZone` | `timeZone?: string;` | optional, inherited |  |
| `text` | `text?: Partial<ChartText>;` | optional, inherited |  |
| `width` | `width?: number;` | optional, inherited |  |
| `height` | `height?: number;` | optional, inherited | Drawing height in px (default 300). |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `exportWriters` | `exportWriters?: VizExportWriters;` | optional, inherited | Loaders of the PDF and XLSX writers: dynamic imports of |
| `ref` | `ref?: Ref<ChartApi>;` | optional, inherited |  |
| `children` | `children?: ReactNode;` | optional, inherited |  |

### StockEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockEvent

```ts
interface StockEvent {
    readonly date: number | string | Date;
    readonly label: string;
    readonly description?: string | undefined;
    readonly shape?: 'circle' | 'square' | 'flag' | 'pin' | 'triangle' | 'invertedTriangle' | 'triangleRight' | 'triangleLeft' | 'arrowUp' | 'arrowDown' | 'arrowLeft' | 'arrowRight' | 'text' | undefined;
    readonly seriesIds?: readonly string[] | undefined;
}
```

Members (5):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `date` | `readonly date: number \| string \| Date;` |  |  |
| `label` | `readonly label: string;` |  |  |
| `description` | `readonly description?: string \| undefined;` | optional |  |
| `shape` | `readonly shape?: 'circle' \| 'square' \| 'flag' \| 'pin' \| 'triangle' \| 'invertedTriangle' \| 'triangleRight' \| 'triangleLeft' \| 'arrowUp' \| 'arrowDown' \| 'arrowLeft' \| 'arrowRight' \| 'text' \| undefined;` | optional |  |
| `seriesIds` | `readonly seriesIds?: readonly string[] \| undefined;` | optional | Series the event marks (default `['price']`; `'volume'` places it on the volume bars). |

## Types

### IndicatorKind

Kind: type

Page: https://salmonui.dev/docs/reference/charts/stock-chart/IndicatorKind

```ts
type IndicatorKind = 'sma' | 'ema' | 'tma' | 'momentum' | 'rsi' | 'atr' | 'accumulationDistribution' | 'bollinger' | 'macd' | 'stochastic';
```

### StockExportFormat

Kind: type

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockExportFormat

```ts
type StockExportFormat = 'png' | 'jpeg' | 'svg' | 'csv' | 'xlsx' | 'pdf' | 'print';
```

`pdf` and `xlsx` need `exportWriters.pdf` / `exportWriters.xlsx`; without the loader the item is left out.

### StockSeriesType

Kind: type

Page: https://salmonui.dev/docs/reference/charts/stock-chart/StockSeriesType

```ts
type StockSeriesType = Extract<ChartSeriesType, 'candle' | 'ohlc' | 'hilo' | 'line' | 'area' | 'column'>;
```

### TrendlineKind

Kind: type

Page: https://salmonui.dev/docs/reference/charts/stock-chart/TrendlineKind

```ts
type TrendlineKind = ChartTrendline['kind'];
```
