unity-lightweight-charts
Version:
Performant financial charts built with HTML5 canvas
1,819 lines (1,817 loc) • 139 kB
TypeScript
// Generated by dts-bundle-generator v8.0.1
import { CanvasRenderingTarget2D } from 'fancy-canvas';
declare abstract class DataSource implements IDataSource {
protected _priceScale: PriceScale | null;
private _zorder;
zorder(): number;
setZorder(zorder: number): void;
priceScale(): PriceScale | null;
setPriceScale(priceScale: PriceScale | null): void;
abstract priceAxisViews(pane?: Pane, priceScale?: PriceScale): readonly IPriceAxisView[];
abstract paneViews(pane?: Pane): readonly IPaneView[];
labelPaneViews(pane?: Pane): readonly IPaneView[];
timeAxisViews(): readonly ITimeAxisView[];
visible(): boolean;
abstract updateAllViews(): void;
}
declare class AutoscaleInfoImpl {
private readonly _priceRange;
private readonly _margins;
constructor(priceRange: PriceRangeImpl | null, margins?: AutoScaleMargins | null);
priceRange(): PriceRangeImpl | null;
margins(): AutoScaleMargins | null;
toRaw(): AutoscaleInfo | null;
static fromRaw(raw: AutoscaleInfo | null): AutoscaleInfoImpl | null;
}
declare class Crosshair extends DataSource {
private _pane;
private _price;
private _index;
private _visible;
private readonly _model;
private _priceAxisViews;
private readonly _timeAxisView;
private readonly _markersPaneView;
private _subscribed;
private readonly _currentPosPriceProvider;
private readonly _options;
private readonly _paneView;
private _x;
private _y;
private _originX;
private _originY;
constructor(model: IChartModelBase, options: CrosshairOptions);
options(): Readonly<CrosshairOptions>;
saveOriginCoord(x: Coordinate, y: Coordinate): void;
clearOriginCoord(): void;
originCoordX(): Coordinate;
originCoordY(): Coordinate;
setPosition(index: TimePointIndex, price: number, pane: Pane): void;
appliedIndex(): TimePointIndex;
appliedX(): Coordinate;
appliedY(): Coordinate;
visible(): boolean;
clearPosition(): void;
paneViews(pane: Pane): readonly IPaneView[];
horzLineVisible(pane: Pane): boolean;
vertLineVisible(): boolean;
priceAxisViews(pane: Pane, priceScale: PriceScale): IPriceAxisView[];
timeAxisViews(): readonly ITimeAxisView[];
pane(): Pane | null;
updateAllViews(): void;
private _priceScaleByPane;
private _tryToUpdateViews;
private _tryToUpdateData;
private _setIndexToLastSeriesBarIndex;
private _createPriceAxisViewOnDemand;
}
declare class CustomPriceLine {
private readonly _series;
private readonly _priceLineView;
private readonly _priceAxisView;
private readonly _panePriceAxisView;
private readonly _options;
constructor(series: ISeries<SeriesType>, options: PriceLineOptions);
applyOptions(options: Partial<PriceLineOptions>): void;
options(): PriceLineOptions;
paneView(): IPaneView;
labelPaneView(): IPaneView;
priceAxisView(): IPriceAxisView;
update(): void;
yCoord(): Coordinate | null;
}
declare class Grid {
private _paneView;
constructor(pane: Pane);
paneView(): IUpdatablePaneView;
}
declare class Pane implements IDestroyable {
private readonly _timeScale;
private readonly _model;
private readonly _grid;
private _dataSources;
private _overlaySourcesByScaleId;
private _height;
private _width;
private _stretchFactor;
private _cachedOrderedSources;
private _destroyed;
private _leftPriceScale;
private _rightPriceScale;
constructor(timeScale: ITimeScale, model: IChartModelBase);
applyScaleOptions(options: DeepPartial<ChartOptionsBase>): void;
priceScaleById(id: string): PriceScale | null;
destroy(): void;
stretchFactor(): number;
setStretchFactor(factor: number): void;
model(): IChartModelBase;
width(): number;
height(): number;
setWidth(width: number): void;
setHeight(height: number): void;
dataSources(): readonly IPriceDataSource[];
isOverlay(source: IPriceDataSource): boolean;
addDataSource(source: IPriceDataSource, targetScaleId: string, zOrder?: number): void;
removeDataSource(source: IPriceDataSource): void;
priceScalePosition(priceScale: PriceScale): PriceScalePosition;
leftPriceScale(): PriceScale;
rightPriceScale(): PriceScale;
startScalePrice(priceScale: PriceScale, x: number): void;
scalePriceTo(priceScale: PriceScale, x: number): void;
endScalePrice(priceScale: PriceScale): void;
startScrollPrice(priceScale: PriceScale, x: number): void;
scrollPriceTo(priceScale: PriceScale, x: number): void;
endScrollPrice(priceScale: PriceScale): void;
updateAllSources(): void;
defaultPriceScale(): PriceScale;
defaultVisiblePriceScale(): PriceScale | null;
recalculatePriceScale(priceScale: PriceScale | null): void;
resetPriceScale(priceScale: PriceScale): void;
momentaryAutoScale(): void;
recalculate(): void;
orderedSources(): readonly IPriceDataSource[];
onDestroyed(): ISubscription;
grid(): Grid;
private _recalculatePriceScaleImpl;
private _getZOrderMinMax;
private _insertDataSource;
private _onPriceScaleModeChanged;
private _createPriceScale;
}
declare class PlotList<PlotRowType extends PlotRow = PlotRow> {
private _items;
private _minMaxCache;
private _rowSearchCache;
last(): PlotRowType | null;
firstIndex(): TimePointIndex | null;
lastIndex(): TimePointIndex | null;
size(): number;
isEmpty(): boolean;
contains(index: TimePointIndex): boolean;
valueAt(index: TimePointIndex): PlotRowType | null;
search(index: TimePointIndex, searchMode?: MismatchDirection): PlotRowType | null;
rows(): readonly PlotRowType[];
minMaxOnRangeCached(start: TimePointIndex, end: TimePointIndex, plots: readonly PlotRowValueIndex[]): MinMax | null;
setData(plotRows: readonly PlotRowType[]): void;
private _indexAt;
private _valueAt;
private _search;
private _searchNearestLeft;
private _searchNearestRight;
private _bsearch;
private _lowerbound;
private _upperbound;
private _plotMinMax;
private _minMaxOnRangeCachedImpl;
}
declare class PriceAxisRendererOptionsProvider {
private readonly _chartModel;
private readonly _rendererOptions;
constructor(chartModel: IChartModelBase);
options(): Readonly<PriceAxisViewRendererOptions>;
private _textColor;
private _paneBackgroundColor;
private _fontSize;
private _fontFamily;
}
declare class PriceRangeImpl {
private _minValue;
private _maxValue;
constructor(minValue: number, maxValue: number);
equals(pr: PriceRangeImpl | null): boolean;
clone(): PriceRangeImpl;
minValue(): number;
maxValue(): number;
length(): number;
isEmpty(): boolean;
merge(anotherRange: PriceRangeImpl | null): PriceRangeImpl;
scaleAroundCenter(coeff: number): void;
shift(delta: number): void;
toRaw(): PriceRange;
static fromRaw(raw: PriceRange | null): PriceRangeImpl | null;
}
declare class PriceScale {
private readonly _id;
private readonly _layoutOptions;
private readonly _localizationOptions;
private readonly _options;
private _height;
private _internalHeightCache;
private _priceRange;
private _priceRangeSnapshot;
private _invalidatedForRange;
private _marginAbove;
private _marginBelow;
private _markBuilder;
private _onMarksChanged;
private _modeChanged;
private _dataSources;
private _cachedOrderedSources;
private _marksCache;
private _scaleStartPoint;
private _scrollStartPoint;
private _formatter;
private _logFormula;
constructor(id: string, options: PriceScaleOptions, layoutOptions: LayoutOptions, localizationOptions: LocalizationOptionsBase);
id(): string;
options(): Readonly<PriceScaleOptions>;
applyOptions(options: DeepPartial<PriceScaleOptions>): void;
isAutoScale(): boolean;
isLog(): boolean;
isPercentage(): boolean;
isIndexedTo100(): boolean;
mode(): PriceScaleState;
setMode(newMode: Partial<PriceScaleState>): void;
modeChanged(): ISubscription<PriceScaleState, PriceScaleState>;
fontSize(): number;
height(): number;
setHeight(value: number): void;
internalHeight(): number;
priceRange(): PriceRangeImpl | null;
setPriceRange(newPriceRange: PriceRangeImpl | null, isForceSetValue?: boolean): void;
isEmpty(): boolean;
invertedCoordinate(coordinate: number): number;
priceToCoordinate(price: number, baseValue: number): Coordinate;
pointsArrayToCoordinates<T extends PricedValue>(points: T[], baseValue: number, visibleRange?: SeriesItemsIndexesRange): void;
barPricesToCoordinates<T extends BarPrices & BarCoordinates>(pricesList: T[], baseValue: number, visibleRange?: SeriesItemsIndexesRange): void;
coordinateToPrice(coordinate: Coordinate, baseValue: number): BarPrice;
logicalToPrice(logical: number, baseValue: number): BarPrice;
dataSources(): readonly IPriceDataSource[];
orderedSources(): readonly IPriceDataSource[];
addDataSource(source: IPriceDataSource): void;
removeDataSource(source: IPriceDataSource): void;
firstValue(): number | null;
isInverted(): boolean;
marks(): PriceMark[];
onMarksChanged(): ISubscription;
startScale(x: number): void;
scaleTo(x: number): void;
endScale(): void;
startScroll(x: number): void;
scrollTo(x: number): void;
endScroll(): void;
formatter(): IPriceFormatter;
formatPrice(price: number, firstValue: number): string;
formatLogical(logical: number): string;
formatPriceAbsolute(price: number): string;
formatPricePercentage(price: number, baseValue: number): string;
sourcesForAutoScale(): readonly IPriceDataSource[];
recalculatePriceRange(visibleBars: RangeImpl<TimePointIndex>): void;
updateAllViews(): void;
updateFormatter(): void;
invalidateSourcesCache(): void;
/**
* @returns The {@link IPriceDataSource} that will be used as the "formatter source" (take minMove for formatter).
*/
private _formatterSource;
private _topMarginPx;
private _bottomMarginPx;
private _makeSureItIsValid;
private _invalidateInternalHeightCache;
private _logicalToCoordinate;
private _coordinateToLogical;
private _onIsInvertedChanged;
private _recalculatePriceRangeImpl;
private _getCoordinateTransformer;
private _formatValue;
private _formatPrice;
private _formatPercentage;
}
declare class RangeImpl<T extends number> {
private readonly _left;
private readonly _right;
constructor(left: T, right: T);
left(): T;
right(): T;
count(): number;
contains(index: T): boolean;
equals(other: RangeImpl<T>): boolean;
}
declare class TextWidthCache {
private readonly _maxSize;
private _actualSize;
private _usageTick;
private _oldestTick;
private _tick2Labels;
private _cache;
constructor(size?: number);
reset(): void;
measureText(ctx: CanvasCtxLike, text: string, optimizationReplacementRe?: RegExp): number;
yMidCorrection(ctx: CanvasCtxLike, text: string, optimizationReplacementRe?: RegExp): number;
private _getMetrics;
}
declare class TimeAxisViewRenderer implements ITimeAxisViewRenderer {
private _data;
constructor();
setData(data: TimeAxisViewRendererData): void;
draw(target: CanvasRenderingTarget2D, rendererOptions: TimeAxisViewRendererOptions): void;
}
declare class Watermark extends DataSource {
private readonly _paneView;
private readonly _options;
constructor(model: IChartModelBase, options: WatermarkOptions);
priceAxisViews(): readonly IPriceAxisView[];
paneViews(): readonly IPaneView[];
options(): Readonly<WatermarkOptions>;
updateAllViews(): void;
}
export declare const customSeriesDefaultOptions: CustomSeriesOptions;
/**
* Plot's index in plot list tuple for series
*/
export declare const enum PlotRowValueIndex {
Open = 0,
High = 1,
Low = 2,
Close = 3
}
/**
* Represents a type of color.
*/
export declare enum ColorType {
/** Solid color */
Solid = "solid",
/** Vertical gradient color */
VerticalGradient = "gradient"
}
/**
* Represents the crosshair mode.
*/
export declare enum CrosshairMode {
/**
* This mode allows crosshair to move freely on the chart.
*/
Normal = 0,
/**
* This mode sticks crosshair's horizontal line to the price value of a single-value series or to the close price of OHLC-based series.
*/
Magnet = 1,
/**
* This mode disables rendering of the crosshair.
*/
Hidden = 2
}
/**
* Represents the type of the last price animation for series such as area or line.
*/
export declare enum LastPriceAnimationMode {
/**
* Animation is always disabled
*/
Disabled = 0,
/**
* Animation is always enabled.
*/
Continuous = 1,
/**
* Animation is active after new data.
*/
OnDataUpdate = 2
}
/**
* Represents the possible line styles.
*/
export declare enum LineStyle {
/**
* A solid line.
*/
Solid = 0,
/**
* A dotted line.
*/
Dotted = 1,
/**
* A dashed line.
*/
Dashed = 2,
/**
* A dashed line with bigger dashes.
*/
LargeDashed = 3,
/**
* A dotted line with more space between dots.
*/
SparseDotted = 4
}
/**
* Represents the possible line types.
*/
export declare enum LineType {
/**
* A line.
*/
Simple = 0,
/**
* A stepped line.
*/
WithSteps = 1,
/**
* A curved line.
*/
Curved = 2
}
/**
* Search direction if no data found at provided index
*/
export declare enum MismatchDirection {
/**
* Search the nearest left item
*/
NearestLeft = -1,
/**
* Do not search
*/
None = 0,
/**
* Search the nearest right item
*/
NearestRight = 1
}
/**
* Represents the source of data to be used for the horizontal price line.
*/
export declare enum PriceLineSource {
/**
* Use the last bar data.
*/
LastBar = 0,
/**
* Use the last visible data of the chart viewport.
*/
LastVisible = 1
}
/**
* Represents the price scale mode.
*/
export declare enum PriceScaleMode {
/**
* Price scale shows prices. Price range changes linearly.
*/
Normal = 0,
/**
* Price scale shows prices. Price range changes logarithmically.
*/
Logarithmic = 1,
/**
* Price scale shows percentage values according the first visible value of the price scale.
* The first visible value is 0% in this mode.
*/
Percentage = 2,
/**
* The same as percentage mode, but the first value is moved to 100.
*/
IndexedTo100 = 3
}
/**
* Represents the type of a tick mark on the time axis.
*/
export declare enum TickMarkType {
/**
* The start of the year (e.g. it's the first tick mark in a year).
*/
Year = 0,
/**
* The start of the month (e.g. it's the first tick mark in a month).
*/
Month = 1,
/**
* A day of the month.
*/
DayOfMonth = 2,
/**
* A time without seconds.
*/
Time = 3,
/**
* A time with seconds.
*/
TimeWithSeconds = 4
}
/**
* Determine how to exit the tracking mode.
*
* By default, mobile users will long press to deactivate the scroll and have the ability to check values and dates.
* Another press is required to activate the scroll, be able to move left/right, zoom, etc.
*/
export declare enum TrackingModeExitMode {
/**
* Tracking Mode will be deactivated on touch end event.
*/
OnTouchEnd = 0,
/**
* Tracking Mode will be deactivated on the next tap event.
*/
OnNextTap = 1
}
/**
* This function is the simplified main entry point of the Lightweight Charting Library with time points for the horizontal scale.
*
* @param container - ID of HTML element or element itself
* @param options - Any subset of options to be applied at start.
* @returns An interface to the created chart
*/
export declare function createChart(container: string | HTMLElement, options?: DeepPartial<ChartOptions>): IChartApi;
/**
* This function is the main entry point of the Lightweight Charting Library. If you are using time values
* for the horizontal scale then it is recommended that you rather use the {@link createChart} function.
*
* @template HorzScaleItem - type of points on the horizontal scale
* @template THorzScaleBehavior - type of horizontal axis strategy that encapsulate all the specific behaviors of the horizontal scale type
*
* @param container - ID of HTML element or element itself
* @param horzScaleBehavior - Horizontal scale behavior
* @param options - Any subset of options to be applied at start.
* @returns An interface to the created chart
*/
export declare function createChartEx<HorzScaleItem, THorzScaleBehavior extends IHorzScaleBehavior<HorzScaleItem>>(container: string | HTMLElement, horzScaleBehavior: THorzScaleBehavior, options?: DeepPartial<ReturnType<THorzScaleBehavior["options"]>>): IChartApiBase<HorzScaleItem>;
/**
* Provides the default implementation of the horizontal scale (time-based) that can be used as a base for extending the horizontal scale with custom behavior.
* This allows for the introduction of custom functionality without re-implementing the entire {@link IHorzScaleBehavior}<{@link Time}> interface.
*
* For further details, refer to the {@link createChartEx} chart constructor method.
*
* @returns An uninitialized class implementing the {@link IHorzScaleBehavior}<{@link Time}> interface
*/
export declare function defaultHorzScaleBehavior(): new () => IHorzScaleBehavior<Time>;
/**
* Check if a time value is a business day object.
*
* @param time - The time to check.
* @returns `true` if `time` is a {@link BusinessDay} object, false otherwise.
*/
export declare function isBusinessDay(time: Time): time is BusinessDay;
/**
* Check if a time value is a UTC timestamp number.
*
* @param time - The time to check.
* @returns `true` if `time` is a {@link UTCTimestamp} number, false otherwise.
*/
export declare function isUTCTimestamp(time: Time): time is UTCTimestamp;
/**
* Returns the current version as a string. For example `'3.3.0'`.
*/
export declare function version(): string;
export interface AreaBarColorerStyle extends CommonBarColorerStyle, AreaFillColorerStyle, LineStrokeColorerStyle {
}
/**
* Structure describing a single item of data for area series
*/
export interface AreaData<HorzScaleItem = Time> extends SingleValueData<HorzScaleItem> {
/**
* Optional line color value for certain data item. If missed, color from options is used
*/
lineColor?: string;
/**
* Optional top color value for certain data item. If missed, color from options is used
*/
topColor?: string;
/**
* Optional bottom color value for certain data item. If missed, color from options is used
*/
bottomColor?: string;
}
export interface AreaFillColorerStyle {
topColor: string;
bottomColor: string;
}
export interface AreaPlotRow extends PlotRow {
lineColor?: string;
topColor?: string;
bottomColor?: string;
}
/**
* Represents style options for an area series.
*/
export interface AreaStyleOptions {
/**
* Color of the top part of the area.
*
* @defaultValue `'rgba( 46, 220, 135, 0.4)'`
*/
topColor: string;
/**
* Color of the bottom part of the area.
*
* @defaultValue `'rgba( 40, 221, 100, 0)'`
*/
bottomColor: string;
/**
* Invert the filled area. Fills the area above the line if set to true.
*
* @defaultValue `false`
*/
invertFilledArea: boolean;
/**
* Line color.
*
* @defaultValue `'#33D778'`
*/
lineColor: string;
/**
* Line style.
*
* @defaultValue {@link LineStyle.Solid}
*/
lineStyle: LineStyle;
/**
* Line width in pixels.
*
* @defaultValue `3`
*/
lineWidth: LineWidth;
/**
* Line type.
*
* @defaultValue {@link LineType.Simple}
*/
lineType: LineType;
/**
* Show series line.
*
* @defaultValue `true`
*/
lineVisible: boolean;
/**
* Show circle markers on each point.
*
* @defaultValue `false`
*/
pointMarkersVisible: boolean;
/**
* Circle markers radius in pixels.
*
* @defaultValue `undefined`
*/
pointMarkersRadius?: number;
/**
* Show the crosshair marker.
*
* @defaultValue `true`
*/
crosshairMarkerVisible: boolean;
/**
* Crosshair marker radius in pixels.
*
* @defaultValue `4`
*/
crosshairMarkerRadius: number;
/**
* Crosshair marker border color. An empty string falls back to the color of the series under the crosshair.
*
* @defaultValue `''`
*/
crosshairMarkerBorderColor: string;
/**
* The crosshair marker background color. An empty string falls back to the color of the series under the crosshair.
*
* @defaultValue `''`
*/
crosshairMarkerBackgroundColor: string;
/**
* Crosshair marker border width in pixels.
*
* @defaultValue `2`
*/
crosshairMarkerBorderWidth: number;
/**
* Last price animation mode.
*
* @defaultValue {@link LastPriceAnimationMode.Disabled}
*/
lastPriceAnimation: LastPriceAnimationMode;
}
/**
* Represents the margin used when updating a price scale.
*/
export interface AutoScaleMargins {
/** The number of pixels for bottom margin */
below: number;
/** The number of pixels for top margin */
above: number;
}
/**
* Represents information used to update a price scale.
*/
export interface AutoscaleInfo {
/**
* Price range.
*/
priceRange: PriceRange;
/**
* Scale margins.
*/
margins?: AutoScaleMargins;
}
/**
* Represents options for how the time and price axes react to mouse double click.
*/
export interface AxisDoubleClickOptions {
/**
* Enable resetting scaling the time axis by double-clicking the left mouse button.
*
* @defaultValue `true`
*/
time: boolean;
/**
* Enable reseting scaling the price axis by by double-clicking the left mouse button.
*
* @defaultValue `true`
*/
price: boolean;
}
/**
* Represents options for how the time and price axes react to mouse movements.
*/
export interface AxisPressedMouseMoveOptions {
/**
* Enable scaling the time axis by holding down the left mouse button and moving the mouse.
*
* @defaultValue `true`
*/
time: boolean;
/**
* Enable scaling the price axis by holding down the left mouse button and moving the mouse.
*
* @defaultValue `true`
*/
price: boolean;
}
export interface BarColorerStyle extends CommonBarColorerStyle {
}
/**
* Represents the y-axis coordinates of a bar's open, high, low, close prices.
*/
export interface BarCoordinates {
openY: Coordinate;
highY: Coordinate;
lowY: Coordinate;
closeY: Coordinate;
}
/**
* Structure describing a single item of data for bar series
*/
export interface BarData<HorzScaleItem = Time> extends OhlcData<HorzScaleItem> {
/**
* Optional color value for certain data item. If missed, color from options is used
*/
color?: string;
}
export interface BarPlotRow extends PlotRow {
readonly color?: string;
}
/**
* Represents a bar's open, high, low, close (OHLC) prices.
*/
export interface BarPrices {
/**
* The open price.
*/
open: BarPrice;
/**
* The high price.
*/
high: BarPrice;
/**
* The low price.
*/
low: BarPrice;
/**
* The close price.
*/
close: BarPrice;
}
/**
* Represents style options for a bar series.
*/
export interface BarStyleOptions {
/**
* Color of rising bars.
*
* @defaultValue `'#26a69a'`
*/
upColor: string;
/**
* Color of falling bars.
*
* @defaultValue `'#ef5350'`
*/
downColor: string;
/**
* Show open lines on bars.
*
* @defaultValue `true`
*/
openVisible: boolean;
/**
* Show bars as sticks.
*
* @defaultValue `true`
*/
thinBars: boolean;
}
export interface BarStylesMap {
Bar: BarColorerStyle;
Candlestick: CandlesticksColorerStyle;
Area: AreaBarColorerStyle;
Baseline: BaselineBarColorerStyle;
Line: LineBarColorerStyle;
Histogram: HistogramBarColorerStyle;
Custom: CustomBarColorerStyle;
}
/**
* Represents a range of bars and the number of bars outside the range.
*/
export interface BarsInfo<HorzScaleItem> extends Partial<Range<HorzScaleItem>> {
/**
* The number of bars before the start of the range.
* Positive value means that there are some bars before (out of logical range from the left) the {@link Range.from} logical index in the series.
* Negative value means that the first series' bar is inside the passed logical range, and between the first series' bar and the {@link Range.from} logical index are some bars.
*/
barsBefore: number;
/**
* The number of bars after the end of the range.
* Positive value in the `barsAfter` field means that there are some bars after (out of logical range from the right) the {@link Range.to} logical index in the series.
* Negative value means that the last series' bar is inside the passed logical range, and between the last series' bar and the {@link Range.to} logical index are some bars.
*/
barsAfter: number;
}
/**
* Represents a type of priced base value of baseline series type.
*/
export interface BaseValuePrice {
/**
* Distinguished type value.
*/
type: "price";
/**
* Price value.
*/
price: number;
}
export interface BaselineBarColorerStyle extends CommonBarColorerStyle, BaselineStrokeColorerStyle, BaselineFillColorerStyle {
}
/**
* Structure describing a single item of data for baseline series
*/
export interface BaselineData<HorzScaleItem = Time> extends SingleValueData<HorzScaleItem> {
/**
* Optional top area top fill color value for certain data item. If missed, color from options is used
*/
topFillColor1?: string;
/**
* Optional top area bottom fill color value for certain data item. If missed, color from options is used
*/
topFillColor2?: string;
/**
* Optional top area line color value for certain data item. If missed, color from options is used
*/
topLineColor?: string;
/**
* Optional bottom area top fill color value for certain data item. If missed, color from options is used
*/
bottomFillColor1?: string;
/**
* Optional bottom area bottom fill color value for certain data item. If missed, color from options is used
*/
bottomFillColor2?: string;
/**
* Optional bottom area line color value for certain data item. If missed, color from options is used
*/
bottomLineColor?: string;
}
export interface BaselineFillColorerStyle {
topFillColor1: string;
topFillColor2: string;
bottomFillColor2: string;
bottomFillColor1: string;
}
export interface BaselinePlotRow extends PlotRow {
topFillColor1?: string;
topFillColor2?: string;
topLineColor?: string;
bottomFillColor1?: string;
bottomFillColor2?: string;
bottomLineColor?: string;
}
export interface BaselineStrokeColorerStyle {
topLineColor: string;
bottomLineColor: string;
}
/**
* Represents style options for a baseline series.
*/
export interface BaselineStyleOptions {
/**
* Base value of the series.
*
* @defaultValue `{ type: 'price', price: 0 }`
*/
baseValue: BaseValueType;
/**
* The first color of the top area.
*
* @defaultValue `'rgba(38, 166, 154, 0.28)'`
*/
topFillColor1: string;
/**
* The second color of the top area.
*
* @defaultValue `'rgba(38, 166, 154, 0.05)'`
*/
topFillColor2: string;
/**
* The line color of the top area.
*
* @defaultValue `'rgba(38, 166, 154, 1)'`
*/
topLineColor: string;
/**
* The first color of the bottom area.
*
* @defaultValue `'rgba(239, 83, 80, 0.05)'`
*/
bottomFillColor1: string;
/**
* The second color of the bottom area.
*
* @defaultValue `'rgba(239, 83, 80, 0.28)'`
*/
bottomFillColor2: string;
/**
* The line color of the bottom area.
*
* @defaultValue `'rgba(239, 83, 80, 1)'`
*/
bottomLineColor: string;
/**
* Line width.
*
* @defaultValue `3`
*/
lineWidth: LineWidth;
/**
* Line style.
*
* @defaultValue {@link LineStyle.Solid}
*/
lineStyle: LineStyle;
/**
* Line type.
*
* @defaultValue {@link LineType.Simple}
*/
lineType: LineType;
/**
* Show series line.
*
* @defaultValue `true`
*/
lineVisible: boolean;
/**
* Show circle markers on each point.
*
* @defaultValue `false`
*/
pointMarkersVisible: boolean;
/**
* Circle markers radius in pixels.
*
* @defaultValue `undefined`
*/
pointMarkersRadius?: number;
/**
* Show the crosshair marker.
*
* @defaultValue `true`
*/
crosshairMarkerVisible: boolean;
/**
* Crosshair marker radius in pixels.
*
* @defaultValue `4`
*/
crosshairMarkerRadius: number;
/**
* Crosshair marker border color. An empty string falls back to the color of the series under the crosshair.
*
* @defaultValue `''`
*/
crosshairMarkerBorderColor: string;
/**
* The crosshair marker background color. An empty string falls back to the color of the series under the crosshair.
*
* @defaultValue `''`
*/
crosshairMarkerBackgroundColor: string;
/**
* Crosshair marker border width in pixels.
*
* @defaultValue `2`
*/
crosshairMarkerBorderWidth: number;
/**
* Last price animation mode.
*
* @defaultValue {@link LastPriceAnimationMode.Disabled}
*/
lastPriceAnimation: LastPriceAnimationMode;
}
/**
* Represents a time as a day/month/year.
*
* @example
* ```js
* const day = { year: 2019, month: 6, day: 1 }; // June 1, 2019
* ```
*/
export interface BusinessDay {
/**
* The year.
*/
year: number;
/**
* The month.
*/
month: number;
/**
* The day.
*/
day: number;
}
/**
* Structure describing a single item of data for candlestick series
*/
export interface CandlestickData<HorzScaleItem = Time> extends OhlcData<HorzScaleItem> {
/**
* Optional color value for certain data item. If missed, color from options is used
*/
color?: string;
/**
* Optional border color value for certain data item. If missed, color from options is used
*/
borderColor?: string;
/**
* Optional wick color value for certain data item. If missed, color from options is used
*/
wickColor?: string;
}
export interface CandlestickPlotRow extends PlotRow {
readonly color?: string;
readonly borderColor?: string;
readonly wickColor?: string;
}
/**
* Represents style options for a candlestick series.
*/
export interface CandlestickStyleOptions {
/**
* Color of rising candles.
*
* @defaultValue `'#26a69a'`
*/
upColor: string;
/**
* Color of falling candles.
*
* @defaultValue `'#ef5350'`
*/
downColor: string;
/**
* Enable high and low prices candle wicks.
*
* @defaultValue `true`
*/
wickVisible: boolean;
/**
* Enable candle borders.
*
* @defaultValue `true`
*/
borderVisible: boolean;
/**
* Border color.
*
* @defaultValue `'#378658'`
*/
borderColor: string;
/**
* Border color of rising candles.
*
* @defaultValue `'#26a69a'`
*/
borderUpColor: string;
/**
* Border color of falling candles.
*
* @defaultValue `'#ef5350'`
*/
borderDownColor: string;
/**
* Wick color.
*
* @defaultValue `'#737375'`
*/
wickColor: string;
/**
* Wick color of rising candles.
*
* @defaultValue `'#26a69a'`
*/
wickUpColor: string;
/**
* Wick color of falling candles.
*
* @defaultValue `'#ef5350'`
*/
wickDownColor: string;
}
export interface CandlesticksColorerStyle extends CommonBarColorerStyle {
barBorderColor: string;
barWickColor: string;
}
/**
* Represents common chart options
*/
export interface ChartOptionsBase {
/**
* Width of the chart in pixels
*
* @defaultValue If `0` (default) or none value provided, then a size of the widget will be calculated based its container's size.
*/
width: number;
/**
* Height of the chart in pixels
*
* @defaultValue If `0` (default) or none value provided, then a size of the widget will be calculated based its container's size.
*/
height: number;
/**
* Setting this flag to `true` will make the chart watch the chart container's size and automatically resize the chart to fit its container whenever the size changes.
*
* This feature requires [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) class to be available in the global scope.
* Note that calling code is responsible for providing a polyfill if required. If the global scope does not have `ResizeObserver`, a warning will appear and the flag will be ignored.
*
* Please pay attention that `autoSize` option and explicit sizes options `width` and `height` don't conflict with one another.
* If you specify `autoSize` flag, then `width` and `height` options will be ignored unless `ResizeObserver` has failed. If it fails then the values will be used as fallback.
*
* The flag `autoSize` could also be set with and unset with `applyOptions` function.
* ```js
* const chart = LightweightCharts.createChart(document.body, {
* autoSize: true,
* });
* ```
*/
autoSize: boolean;
/**
* Watermark options.
*
* A watermark is a background label that includes a brief description of the drawn data. Any text can be added to it.
*
* Please make sure you enable it and set an appropriate font color and size to make your watermark visible in the background of the chart.
* We recommend a semi-transparent color and a large font. Also note that watermark position can be aligned vertically and horizontally.
*/
watermark: WatermarkOptions;
/**
* Layout options
*/
layout: LayoutOptions;
/**
* Left price scale options
*/
leftPriceScale: VisiblePriceScaleOptions;
/**
* Right price scale options
*/
rightPriceScale: VisiblePriceScaleOptions;
/**
* Overlay price scale options
*/
overlayPriceScales: OverlayPriceScaleOptions;
/**
* Time scale options
*/
timeScale: HorzScaleOptions;
/**
* The crosshair shows the intersection of the price and time scale values at any point on the chart.
*
*/
crosshair: CrosshairOptions;
/**
* A grid is represented in the chart background as a vertical and horizontal lines drawn at the levels of visible marks of price and the time scales.
*/
grid: GridOptions;
/**
* Scroll options, or a boolean flag that enables/disables scrolling
*/
handleScroll: HandleScrollOptions | boolean;
/**
* Scale options, or a boolean flag that enables/disables scaling
*/
handleScale: HandleScaleOptions | boolean;
/**
* Kinetic scroll options
*/
kineticScroll: KineticScrollOptions;
/** @inheritDoc TrackingModeOptions
*/
trackingMode: TrackingModeOptions;
showAddButton: boolean;
/**
* Basic localization options
*/
localization: LocalizationOptionsBase;
}
/**
* Structure describing options of the chart. Series options are to be set separately
*/
export interface ChartOptionsImpl<HorzScaleItem> extends ChartOptionsBase {
/**
* Localization options.
*/
localization: LocalizationOptions<HorzScaleItem>;
}
export interface CommonBarColorerStyle {
barColor: string;
}
/** Structure describing a crosshair line (vertical or horizontal) */
export interface CrosshairLineOptions {
/**
* Crosshair line color.
*
* @defaultValue `'#758696'`
*/
color: string;
/**
* Crosshair line width.
*
* @defaultValue `1`
*/
width: LineWidth;
/**
* Crosshair line style.
*
* @defaultValue {@link LineStyle.LargeDashed}
*/
style: LineStyle;
/**
* Display the crosshair line.
*
* Note that disabling crosshair lines does not disable crosshair marker on Line and Area series.
* It can be disabled by using `crosshairMarkerVisible` option of a relevant series.
*
* @see {@link LineStyleOptions.crosshairMarkerVisible}
* @see {@link AreaStyleOptions.crosshairMarkerVisible}
* @see {@link BaselineStyleOptions.crosshairMarkerVisible}
* @defaultValue `true`
*/
visible: boolean;
/**
* Display the crosshair label on the relevant scale.
*
* @defaultValue `true`
*/
labelVisible: boolean;
/**
* Crosshair label background color.
*
* @defaultValue `'#4c525e'`
*/
labelBackgroundColor: string;
}
/** Structure describing crosshair options */
export interface CrosshairOptions {
/**
* Crosshair mode
*
* @defaultValue {@link CrosshairMode.Magnet}
*/
mode: CrosshairMode;
/**
* Vertical line options.
*/
vertLine: CrosshairLineOptions;
/**
* Horizontal line options.
*/
horzLine: CrosshairLineOptions;
}
export interface CustomBarColorerStyle extends CommonBarColorerStyle {
}
/**
* Renderer data for an item within the custom series.
*/
export interface CustomBarItemData<HorzScaleItem, TData extends CustomData<HorzScaleItem> = CustomData<HorzScaleItem>> {
/**
* Horizontal coordinate for the item. Measured from the left edge of the pane in pixels.
*/
x: number;
/**
* Time scale index for the item. This isn't the timestamp but rather the logical index.
*/
time: number;
/**
* Original data for the item.
*/
originalData: TData;
/**
* Color assigned for the item, typically used for price line and price scale label.
*/
barColor: string;
}
/**
* Base structure describing a single item of data for a custom series.
*
* This type allows for any properties to be defined
* within the interface. It is recommended that you extend this interface with
* the required data structure.
*/
export interface CustomData<HorzScaleItem = Time> extends CustomSeriesWhitespaceData<HorzScaleItem> {
/**
* If defined then this color will be used for the price line and price scale line
* for this specific data item of the custom series.
*/
color?: string;
}
export interface CustomPlotRow extends PlotRow {
data: Record<string, unknown>;
readonly color?: string;
}
export interface CustomPriceLineClickedEventParams {
customPriceLine: CustomPriceLine;
}
export interface CustomPriceLineDraggedEventParams {
customPriceLine: CustomPriceLine;
fromPriceString: string;
}
/**
* Represents a whitespace data item, which is a data point without a value.
*/
export interface CustomSeriesWhitespaceData<HorzScaleItem> {
/**
* The time of the data.
*/
time: HorzScaleItem;
/**
* Additional custom values which will be ignored by the library, but
* could be used by plugins.
*/
customValues?: Record<string, unknown>;
}
/**
* Represents style options for a custom series.
*/
export interface CustomStyleOptions {
/**
* Color used for the price line and price scale label.
*/
color: string;
}
export interface FirstValue {
value: number;
timePoint: InternalHorzScaleItem;
}
/** Grid line options. */
export interface GridLineOptions {
/**
* Line color.
*
* @defaultValue `'#D6DCDE'`
*/
color: string;
/**
* Line style.
*
* @defaultValue {@link LineStyle.Solid}
*/
style: LineStyle;
/**
* Display the lines.
*
* @defaultValue `true`
*/
visible: boolean;
}
/** Structure describing grid options. */
export interface GridOptions {
/**
* Vertical grid line options.
*/
vertLines: GridLineOptions;
/**
* Horizontal grid line options.
*/
horzLines: GridLineOptions;
}
/**
* Represents options for how the chart is scaled by the mouse and touch gestures.
*/
export interface HandleScaleOptions {
/**
* Enable scaling with the mouse wheel.
*
* @defaultValue `true`
*/
mouseWheel: boolean;
/**
* Enable scaling with pinch/zoom gestures.
*
* @defaultValue `true`
*/
pinch: boolean;
/**
* Enable scaling the price and/or time scales by holding down the left mouse button and moving the mouse.
*/
axisPressedMouseMove: AxisPressedMouseMoveOptions | boolean;
/**
* Enable resetting scaling by double-clicking the left mouse button.
*/
axisDoubleClickReset: AxisDoubleClickOptions | boolean;
}
/**
* Represents options for how the chart is scrolled by the mouse and touch gestures.
*/
export interface HandleScrollOptions {
/**
* Enable scrolling with the mouse wheel.
*
* @defaultValue `true`
*/
mouseWheel: boolean;
/**
* Enable scrolling by holding down the left mouse button and moving the mouse.
*
* @defaultValue `true`
*/
pressedMouseMove: boolean;
/**
* Enable horizontal touch scrolling.
*
* When enabled the chart handles touch gestures that would normally scroll the webpage horizontally.
*
* @defaultValue `true`
*/
horzTouchDrag: boolean;
/**
* Enable vertical touch scrolling.
*
* When enabled the chart handles touch gestures that would normally scroll the webpage vertically.
*
* @defaultValue `true`
*/
vertTouchDrag: boolean;
}
export interface HistogramBarColorerStyle extends CommonBarColorerStyle {
}
/**
* Structure describing a single item of data for histogram series
*/
export interface HistogramData<HorzScaleItem = Time> extends SingleValueData<HorzScaleItem> {
/**
* Optional color value for certain data item. If missed, color from options is used
*/
color?: string;
}
export interface HistogramPlotRow extends PlotRow {
readonly color?: string;
}
/**
* Represents style options for a histogram series.
*/
export interface HistogramStyleOptions {
/**
* Column color.
*
* @defaultValue `'#26a69a'`
*/
color: string;
/**
* Initial level of histogram columns.
*
* @defaultValue `0`
*/
base: number;
}
/**
* Options for the time scale; the horizontal scale at the bottom of the chart that displays the time of data.
*/
export interface HorzScaleOptions {
/**
* The margin space in bars from the right side of the chart.
*
* @defaultValue `0`
*/
rightOffset: number;
/**
* The space between bars in pixels.
*
* @defaultValue `6`
*/
barSpacing: number;
/**
* The minimum space between bars in pixels.
*
* @defaultValue `0.5`
*/
minBarSpacing: number;
/**
* Prevent scrolling to the left of the first bar.
*
* @defaultValue `false`
*/
fixLeftEdge: boolean;
/**
* Prevent scrolling to the right of the most recent bar.
*
* @defaultValue `false`
*/
fixRightEdge: boolean;
/**
* Prevent changing the visible time range during chart resizing.
*
* @defaultValue `false`
*/
lockVisibleTimeRangeOnResize: boolean;
/**
* Prevent the hovered bar from moving when scrolling.
*
* @defaultValue `false`
*/
rightBarStaysOnScroll: boolean;
/**
* Show the time scale border.
*
* @defaultValue `true`
*/
borderVisible: boolean;
/**
* The time scale border color.
*
* @defaultValue `'#2B2B43'`
*/
borderColor: string;
/**
* Show the time scale.
*
* @defaultValue `true`
*/
visible: boolean;
/**
* Show the time, not just the date, in the time scale and vertical crosshair label.
*
* @defaultValue `false`
*/
timeVisible: boolean;
/**
* Show seconds in the time scale and vertical crosshair label in `hh:mm:ss` format for intraday data.
*
* @defaultValue `true`
*/
secondsVisible: boolean;
/**
* Shift the visible range to the right (into the future) by the number of new bars when new data is added.
*
* Note that this only applies when the last bar is visible.
*
* @defaultValue `true`
*/
shiftVisibleRangeOnNewBar: boolean;
/**
* Allow the visible range to be shifted to the right when a new bar is added which
* is replacing an existing whitespace time point on the chart.
*
* Note that this only applies when the last bar is visible & `shiftVisibleRangeOnNewBar` is enabled.
*
* @defaultValue `false`
*/
allowShiftVisibleRangeOnWhitespaceReplacement: boolean;
/**
* Draw small vertical line on time axis labels.
*
* @defaultValue `false`
*/
ticksVisible: boolean;
/**
* Maximum tick mark label length. Used to override the default 8 character maximum length.
*
* @defaultValue `undefined`
*/
tickMarkMaxCharacterLength?: number;
/**
* Changes horizontal scale marks generation.
* With this flag equal to `true`, marks of the same weight are either all drawn or none are drawn at all.
*/
uniformDistribution: boolean;
/**
* Define a minimum height for the time scale.
* Note: This value will be exceeded if the
* time scale needs more space to display it's contents.
*
* Setting a minimum height could be useful for ensuring that
* multiple charts positioned in a horizontal stack each have
* an identical time scale height, or for plugins which
* require a bit more space within the time scale pane.
*
* @defaultValue 0
*/
minimumHeight: number;
/**
* Allow major time scale labels to be rendered in a bolder font weight.
*
* @defaultValue true
*/
allowBoldLabels: boolean;
}
export interface HoveredObject {
hitTestData?: unknown;
externalId?: string;
}
export interface HoveredSource {
source: IPriceDataSource;
object?: HoveredObject;
}
export interface IAxisRenderer {
draw(target: CanvasRenderingTarget2D, isHovered: boolean, hitTestData?: unknown): void;
drawBackground?(target: CanvasRenderingTarget2D, isHovered: boolean, hitTestData?: unknown): void;
}
export interface IAxisView {
renderer(): IAxisRenderer | null;
}
/**
* The main interface of a single chart using time for horizontal scale.
*/
export interface IChartApi extends IChartApiBase<Time> {
/**
* Applies new options to the chart
*
* @param options - Any subset of options.
*/
applyOptions(options: DeepPartial<ChartOptions>): void;
}
/**
* The main interface of a single chart.
*/
export interface IChartApiBase<HorzScaleItem = Time> {
/**
* Removes the chart object including all DOM elements. This is an irreversible operation, you cannot do anything with the chart after removing it.
*/
remove(): void;
/**
* Sets fixed size of the chart. By default chart takes up 100% of its container.
*
* If chart has the `autoSize` option enabled, and the ResizeObserver is available then
* the width and height values will be ignored.
*
* @param width - Target width of the chart.
* @param height - Target height of the chart.
* @param forceRepaint - True to initiate resize immediately. One could need this to get screenshot immediately after resize.
*/
resize(width: number, height: number, forceRepaint?: boolean): void;
/**
* Creates a custom series with specified parameters.
*
* A custom series is a generic series which can be extended with a custom renderer to
* implement chart types which the library doesn't support by default.
*
* @param customPaneView - A custom series pane view which implements the custom renderer.
* @param customOptions - Customization parameters of the series being created.
* ```js
* const series = chart.addCustomSeries(myCustomPaneView);
* ```
*/
addCustomSeries<TData extends CustomData<HorzScaleItem>, TOptions extends CustomSeriesOptions, TPartialOptions extends SeriesPartialOptions<TOptions> = SeriesPartialOptions<TOptions>>(customPaneView: ICustomSeriesPaneView<HorzScaleItem, TData, TOptions>, customOptions?: SeriesPartialOptions<TOptions>): ISeriesApi<"Custom", HorzScaleItem, TData | WhitespaceData<HorzScaleItem>, TOptions, TPartialOptions>;
/**
* Creates an area series with specified parameters.
*
* @param areaOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addAreaSeries();
* ```
*/
addAreaSeries(areaOptions?: AreaSeriesPartialOptions): ISeriesApi<"Area", HorzScaleItem>;
/**
* Creates a baseline series with specified parameters.
*
* @param baselineOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addBaselineSeries();
* ```
*/
addBaselineSeries(baselineOptions?: BaselineSeriesPartialOptions): ISeriesApi<"Baseline", HorzScaleItem>;
/**
* Creates a bar series with specified parameters.
*
* @param barOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addBarSeries();
* ```
*/
addBarSeries(barOptions?: BarSeriesPartialOptions): ISeriesApi<"Bar", HorzScaleItem>;
/**
* Creates a candlestick series with specified parameters.
*
* @param candlestickOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addCandlestickSeries();
* ```
*/
addCandlestickSeries(candlestickOptions?: CandlestickSeriesPartialOptions): ISeriesApi<"Candlestick", HorzScaleItem>;
/**
* Creates a histogram series with specified parameters.
*
* @param histogramOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addHistogramSeries();
* ```
*/
addHistogramSeries(histogramOptions?: HistogramSeriesPartialOptions): ISeriesApi<"Histogram", HorzScaleItem>;
/**
* Creates a line series with specified parameters.
*
* @param lineOptions - Customization parameters of the series being created.
* @returns An interface of the created series.
* @example
* ```js
* const series = chart.addLineSeries();
* ```
*/
addLineSeries(lineOptions?: LineSeriesPartialOptions): ISeriesApi<"Line", HorzScaleItem>;
/**
* Removes a series of any type. This is an irreversible operation, you cannot do anything with the series after removing it.
*
* @example
* ```js
* chart.removeSeries(series);
* ```
*/
removeSeries(seriesApi: ISeriesApi<SeriesType, HorzScaleItem>): void;
/**
* Subscribe to the chart click event.
*
* @param handler - Handler to be called on mouse click.
* @example
* ```js
* function myClickHandler(param) {
* if (!param.point) {
* return;
* }
*
* console.log(`Click at ${param.point.x}, ${param.point.y}. The time is ${param.time}.`);
* }
*
* chart.subscribeClick(myClickHandler);
* ```
*/
subscribeClick(handler: MouseEventHandler<HorzScaleItem>): void;
/**
* Unsubscribe a handler that was previously subscribed using {@link subscribeClick}.
*
* @param handler - Previously subscribed handler
* @example
* ```js
* chart.unsubscribeClick(myClickHandler);
* ```
*/
unsubscribeClick(handler: MouseEventHandler<HorzScaleItem>): void;
/**
* Subscribe to the chart double-click event.
*
* @param handler - Handler to be called on mouse double-click.
* @example
* ```js
* function myDblClickHandler(param) {
* if (!param.point) {
* return;
* }
*
* console.log(`Double Click at ${param.point.x}, ${param.point.y}. The time is ${param.time}.`);
* }
*
* chart.subscribeDblClick(myDblClickHandler);
* ```
*/
subscribeDblClick(handler: MouseEventHandler<HorzScaleItem>): void;
/**
* Unsubscribe a handler that was previously subscribed using {@link subscribeDblClick}.
*
* @param handler - Previously subscribed handler
* @example
* ```js
* chart.unsubscribeDblClick(myDblClickHandler);
* ```
*/
unsubscribeDblClick(handler: MouseEventHandler<HorzScaleItem>): void;
/**
* Subscribe to the crosshair move event.
*
* @param handler - Handler to be called on crosshair move.
* @example