UNPKG

@amcharts/amcharts5

Version:
184 lines 6.67 kB
import type { XYSeries, IXYSeriesDataItem } from "../../xy/series/XYSeries"; import type { StockLegend } from "../StockLegend"; import type { StockChart } from "../StockChart"; import type { DataItem } from "../../../core/render/Component"; import type { Color } from "../../../core/util/Color"; import { Container, IContainerSettings, IContainerPrivate, IContainerEvents } from "../../../core/render/Container"; import { MultiDisposer } from "../../../core/util/Disposer"; export interface IIndicatorEditableSetting { /** * Setting key. */ key: string; /** * Name of the setting (displayed in edit modal). * * Settings with the same name will be grouped in modal. */ name: string; /** * Type of the control to show for editing the setting in modal. */ type: "color" | "number" | "dropdown" | "checkbox" | "text"; /** * Minimum numeric value allowable in this field. * * @since 5.8.1 */ minValue?: number; /** * Maximum numeric value allowable in this field. * * @since 5.20.0 */ maxValue?: number; /** * Step for the numeric input. A step of `1` also marks the setting as an * integer, so typed decimals are rounded to whole numbers. * * @since 5.20.0 */ step?: number; /** * Display multiplier for the settings modal only. The value shown/edited in * the UI is `stored value × scale`, and it is divided back on save. Use it * when a setting's stored unit is awkward to show — e.g. Acceleration Bands * `factor` is stored in thousandths, so `scale: 1000` displays the * conventional `1` (= single band width) instead of `0.001`. * * Does NOT affect the stored/serialized value, the API, or `minValue`/ * `maxValue`/`step` — those all stay in stored units. * * @since 5.20.0 */ scale?: number; /** * If `type: "dropdown"`, `options` should contain a list of items it. */ options?: Array<string | { value: number | string; text: string; extTarget?: string; extTargetValue?: number | string; extTargetMinValue?: number; /** @since 5.20.0 */ extTargetMaxValue?: number; /** @since 5.20.0 */ extTargetStep?: number; }>; } export interface IIndicatorSettings extends IContainerSettings { /** * An instance of target [[StockChart]]. */ stockChart: StockChart; /** * A main series indicator will be based on. */ stockSeries: XYSeries; /** * A volume series indicator will be based on, if it requires one. */ volumeSeries?: XYSeries; /** * If set to a reference to [[StockLegend]], indicator will add itself into * the legend. */ legend?: StockLegend; /** * Period. */ period?: number; /** * A value field to use. */ field?: "open" | "close" | "low" | "high" | "hl/2" | "hlc/3" | "hlcc/4" | "ohlc/4"; /** * Indicator name, e.g. "Moving Average". */ name?: string; /** * Short name for the indicator, e.g. "MA" (for "Moving Average"). * * Mainly used for the legend. */ shortName?: string; /** * A color to use for the indicator series. */ seriesColor?: Color; /** * Should indicator settings modal be opened automatically when indicator * is added to a chart via [[IndicatorControl]]. * * @default true * @since 5.10.6 */ autoOpenSettings?: boolean; } export interface IIndicatorPrivate extends IContainerPrivate { } export interface IIndicatorEvents extends IContainerEvents { } /** * Base class for [[StockChart]] indicators. * * @see {@link https://www.amcharts.com/docs/v5/charts/stock/indicators/} for more info */ export declare abstract class Indicator extends Container { static className: string; static classNames: Array<string>; _settings: IIndicatorSettings; _privateSettings: IIndicatorPrivate; _events: IIndicatorEvents; _editableSettings: IIndicatorEditableSetting[]; series: XYSeries; protected _dataDirty: boolean; protected _sDP?: MultiDisposer; protected _vDP?: MultiDisposer; /** * Clamps numeric settings that carry `minValue`/`maxValue`/`step` limits in * `_editableSettings` back into their allowed range, so out-of-range values * (from the settings modal, deserialized configs, or the API) can never reach * the heavy `prepareData()` — which, for e.g. Volume Profile, would otherwise * freeze the page. A `step` of `1` marks an integer setting, so typed decimals * are rounded. Called with `force` on add/deserialize (nothing is "dirty" * yet); otherwise only dirty keys are checked. */ _clampSettings(force?: boolean): void; /** * Assigns numeric limits to an editable setting by key. Used for entries that * are inherited from a base indicator (e.g. overbought/oversold) whose range * differs per subclass. */ protected _setEditableSettingBounds(key: string, minValue?: number, maxValue?: number, step?: number): void; _prepareChildren(): void; protected _markDataDirty(): void; markDataDirty(): void; _updateChildren(): void; protected _dispose(): void; hide(duration?: number): Promise<any>; show(duration?: number): Promise<any>; protected _handleLegend(series: XYSeries): void; protected _updateSeriesColor(series?: XYSeries, color?: Color, contextName?: string): void; setCustomData(name: string, value?: any): void; /** * @ignore */ prepareData(): void; protected _getValue(dataItem: DataItem<IXYSeriesDataItem>): number | undefined; /** * @ignore */ protected _getDataArray(dataItems: Array<DataItem<any>>): Array<any>; /** * @ignore */ protected _getTypicalPrice(dataItems: Array<DataItem<any>>): Array<any>; protected _sma(data: Array<any>, period: number, field: string, toField: string): void; protected _wma(data: Array<any>, period: number, field: string, toField: string): void; protected _ema(data: Array<any>, period: number, field: string, toField: string): void; protected _dema(data: Array<any>, period: number, field: string, toField: string): void; protected _tema(data: Array<any>, period: number, field: string, toField: string): void; } //# sourceMappingURL=Indicator.d.ts.map