View as Markdown

API reference: @salmonui/charts/stock-chart

StockChartPropsinterface

import type { StockChartProps } from '@salmonui/charts/stock-chart';
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;
}
StockChartProps members (88, 57 inherited)
NameSignatureDescription
datareadonly data: NonNullable<ChartProps['data']>;
xFieldreadonly xField: string;
openFieldoptionalreadonly openField?: string | undefined;
highFieldoptionalreadonly highField?: string | undefined;
lowFieldoptionalreadonly lowField?: string | undefined;
closeFieldreadonly closeField: string;
volumeFieldoptionalreadonly volumeField?: string | undefined;
nameoptionalreadonly name?: string | undefined;
seriesTypeoptionalreadonly seriesType?: StockSeriesType | undefined;
defaultSeriesTypeoptionalreadonly defaultSeriesType?: StockSeriesType | undefined;
onSeriesTypeChangeoptionalreadonly onSeriesTypeChange?: ((type: StockSeriesType, event: StockChangeEvent<'toolbar'>) => void) | undefined;
rangeoptionalreadonly range?: RangeValue | undefined;
defaultRangeoptionalreadonly defaultRange?: RangeValue | undefined;
onRangeChangeoptionalreadonly onRangeChange?: ((range: RangeValue, event: StockChangeEvent<string>) => void) | undefined;
periodsoptionalreadonly periods?: readonly Period[] | undefined;
periodoptionalreadonly period?: string | null | undefined;

Selected period id (null: none). A selected period holds the range at the data end; a controlled range wins.

defaultPeriodoptionalreadonly defaultPeriod?: string | null | undefined;
onPeriodChangeoptionalreadonly onPeriodChange?: ((period: string | null, event: StockChangeEvent<string>) => void) | undefined;
periodSelectoroptionalreadonly periodSelector?: boolean | { readonly position?: 'top' | 'bottom'; } | undefined;
navigatoroptionalreadonly navigator?: boolean | Partial<RangeSelectorProps> | undefined;
indicatorsoptionalreadonly indicators?: readonly IndicatorKind[] | undefined;
defaultIndicatorsoptionalreadonly defaultIndicators?: readonly IndicatorKind[] | undefined;
onIndicatorsChangeoptionalreadonly onIndicatorsChange?: ((kinds: readonly IndicatorKind[], event: StockChangeEvent<'toolbar'>) => void) | undefined;
trendlinesoptionalreadonly trendlines?: readonly TrendlineKind[] | undefined;
defaultTrendlinesoptionalreadonly defaultTrendlines?: readonly TrendlineKind[] | undefined;
onTrendlinesChangeoptionalreadonly onTrendlinesChange?: ((kinds: readonly TrendlineKind[], event: StockChangeEvent<'toolbar'>) => void) | undefined;
toolbaroptionalreadonly toolbar?: false | { readonly seriesTypes?: readonly StockSeriesType[] | undefined; readonly indicators?: readonly IndicatorKind[] | undefined; readonly trendlines?: readonly TrendlineKind[] | undefined; readonly export?: readonly StockExportFormat[] | undefined; } | undefined;
eventsoptionalreadonly events?: readonly StockEvent[] | undefined;
renderEventoptionalreadonly renderEvent?: ((event: StockEvent) => ReactNode) | undefined;
customRangeoptionalreadonly customRange?: boolean | undefined;

A date range field in the toolbar; its days are UTC calendar days.

stockTextoptionalreadonly 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;
aria-labeloptionalinheritedaria-label?: string;

Accessible name of the chart; wins over title and the generated summary.

aria-labelledbyoptionalinheritedaria-labelledby?: string;

Id of the element naming the chart; wins over aria-label.

xAxisoptionalinheritedxAxis?: ChartAxisOptions;
yAxisoptionalinheritedyAxis?: ChartAxisOptions;
axesoptionalinheritedaxes?: readonly (ChartAxisOptions & { readonly id: string; readonly direction: "x" | "y"; })[];

Additional axes referenced by series.xAxis / series.yAxis (id required).

panesoptionalinheritedpanes?: { readonly rows?: readonly ChartPaneSize[]; readonly columns?: readonly ChartPaneSize[]; };
orientationoptionalinheritedorientation?: "horizontal" | "vertical";
coordinateoptionalinheritedcoordinate?: "cartesian" | "polar" | "radar";

Polar (circles) or radar (polygons) coordinates; x is the angle, y the radius.

radiusoptionalinheritedradius?: number;

Polar radius as a fraction (0..1) of the largest circle that fits.

featuresoptionalinheritedfeatures?: readonly ChartFeature[];

Preloaded features from @salmonui/charts/chart/features: polar renders polar charts on the server.

groupingoptionalinheritedgrouping?: "overlap" | "sideBySide";
titleoptionalinheritedtitle?: string;
subtitleoptionalinheritedsubtitle?: string;
descriptionoptionalinheriteddescription?: string;
legendoptionalinheritedlegend?: boolean | ChartLegendOptions;
tooltipoptionalinheritedtooltip?: boolean | ChartTooltipOptions;
crosshairoptionalinheritedcrosshair?: boolean | ChartCrosshairOptions;
zoomoptionalinheritedzoom?: boolean | ChartZoomOptions;
onVisibleRangeChangeoptionalinheritedonVisibleRangeChange?: ((change: { readonly axisId: string; readonly range: readonly [number, number]; }) => void);

The committed visible range of a continuous axis changed: fetch data for it. Fires on commit, never per frame.

hiddenSeriesoptionalinheritedhiddenSeries?: readonly string[];
defaultHiddenSeriesoptionalinheriteddefaultHiddenSeries?: readonly string[];
onHiddenSeriesChangeoptionalinheritedonHiddenSeriesChange?: ((ids: readonly string[], event: ChartChangeEvent<"legend">) => void);
selectionoptionalinheritedselection?: boolean | { readonly mode?: "cluster" | "lasso" | "point" | "range" | "series"; readonly multiple?: boolean; readonly axis?: "x" | "xy" | "y"; };
onRangeSelectoptionalinheritedonRangeSelect?: ((selection: { readonly ranges: Readonly<Record<string, readonly [number, number]>>; readonly points: readonly ChartPointRef[]; }, event: ChartChangeEvent<"lasso" | "range">) => void);

Range and lasso selection finished: ranges per axis id (range mode) and the enclosed points.

selectedPointsoptionalinheritedselectedPoints?: readonly ChartPointRef[];
defaultSelectedPointsoptionalinheriteddefaultSelectedPoints?: readonly ChartPointRef[];
onSelectedPointsChangeoptionalinheritedonSelectedPointsChange?: ((points: readonly ChartPointRef[], event: ChartChangeEvent<"click" | "keyboard" | "lasso" | "range" | "sync">) => void);
highlightoptionalinheritedhighlight?: "cluster" | "point" | "series" | false;
onPointClickoptionalinheritedonPointClick?: ((ctx: ChartPointContext, event: MouseEvent<Element, MouseEvent>) => void);
onPlotClickoptionalinheritedonPlotClick?: ((point: ChartPlotPoint, event: MouseEvent<Element, MouseEvent>) => void);

Any click on the plot, with data coordinates.

onPlotPointerMoveoptionalinheritedonPlotPointerMove?: ((point: ChartPlotPoint, event: PointerEvent<Element>) => void);

Pointer moves over the plot, with data coordinates; called per move (keep it cheap).

onPointHoveroptionalinheritedonPointHover?: ((ctx: ChartPointContext | null) => void);
onPointChangeoptionalinheritedonPointChange?: ((change: { readonly seriesId: string; readonly index: number; readonly value: number; }, event: ChartChangeEvent<"drag" | "keyboard">) => void);

An editable point was dragged or moved by keyboard.

onPointDoubleClickoptionalinheritedonPointDoubleClick?: ((ctx: ChartPointContext, event: MouseEvent<Element, MouseEvent>) => void);
onAxisLabelClickoptionalinheritedonAxisLabelClick?: ((ctx: ChartAxisLabelContext, event: MouseEvent<Element, MouseEvent>) => void);

A tick label was clicked.

onAxisLabelGroupClickoptionalinheritedonAxisLabelGroupClick?: ((ctx: { readonly axisId: string; readonly group: number; readonly level: number; readonly label: string; }, event: MouseEvent<Element, MouseEvent>) => void);

A multi-level label cell was clicked.

onResizeoptionalinheritedonResize?: ((size: { readonly width: number; readonly height: number; }) => void);
annotationsoptionalinheritedannotations?: readonly ChartAnnotation[];
stackLabelsoptionalinheritedstackLabels?: boolean | { readonly format?: ChartFormat | undefined; };
paletteoptionalinheritedpalette?: readonly string[];
colorRangesoptionalinheritedcolorRanges?: readonly ChartColorRange[];

Point colors by y value range, shared with legend.mode: 'range' | 'gradient'.

rendereroptionalinheritedrenderer?: "auto" | "canvas" | "svg";
decimationoptionalinheriteddecimation?: "auto" | "lttb" | "minMax" | false;
accessibleTableoptionalinheritedaccessibleTable?: boolean;
showDataTableoptionalinheritedshowDataTable?: boolean;
renderEmptyoptionalinheritedrenderEmpty?: (() => ReactNode);
animatedoptionalinheritedanimated?: boolean;
localeoptionalinheritedlocale?: string;
timeZoneoptionalinheritedtimeZone?: string;
textoptionalinheritedtext?: Partial<ChartText>;
widthoptionalinheritedwidth?: number;
heightoptionalinheritedheight?: number;

Drawing height in px (default 300).

classNameoptionalinheritedclassName?: string;
styleoptionalinheritedstyle?: CSSProperties;
exportWritersoptionalinheritedexportWriters?: VizExportWriters;

Loaders of the PDF and XLSX writers: dynamic imports of

@salmonui

/export graphics and xlsx subpaths.

refoptionalinheritedref?: Ref<ChartApi>;
childrenoptionalinheritedchildren?: ReactNode;