Skip to main content
Version: 4.0

lightweight-charts

Enumerations

Interfaces

Functions

createChart

createChart(container, options?): IChartApi

This function is the main entry point of the Lightweight Charting Library.

Parameters

NameTypeDescription
containerstring | HTMLElementID of HTML element or element itself
options?DeepPartial<ChartOptions>Any subset of options to be applied at start.

Returns

IChartApi

An interface to the created chart


isBusinessDay

isBusinessDay(time): time is BusinessDay

Check if a time value is a business day object.

Parameters

NameTypeDescription
timeTimeThe time to check.

Returns

time is BusinessDay

true if time is a BusinessDay object, false otherwise.


isUTCTimestamp

isUTCTimestamp(time): time is UTCTimestamp

Check if a time value is a UTC timestamp number.

Parameters

NameTypeDescription
timeTimeThe time to check.

Returns

time is UTCTimestamp

true if time is a UTCTimestamp number, false otherwise.


version

version(): string

Returns the current version as a string. For example '3.3.0'.

Returns

string

Type Aliases

AreaSeriesOptions

Ƭ AreaSeriesOptions: SeriesOptions<AreaStyleOptions>

Represents area series options.


AreaSeriesPartialOptions

Ƭ AreaSeriesPartialOptions: SeriesPartialOptions<AreaStyleOptions>

Represents area series options where all properties are optional.


AutoscaleInfoProvider

Ƭ AutoscaleInfoProvider: (baseImplementation: () => AutoscaleInfo | null) => AutoscaleInfo | null

Type declaration

▸ (baseImplementation): AutoscaleInfo | null

A custom function used to get autoscale information.

Parameters
NameTypeDescription
baseImplementation() => AutoscaleInfo | nullThe default implementation of autoscale algorithm, you can use it to adjust the result.
Returns

AutoscaleInfo | null


Background

Ƭ Background: SolidColor | VerticalGradientColor

Represents the background color of the chart.


BarPrice

Ƭ BarPrice: Nominal<number, "BarPrice">

Represents a price as a number.


BarSeriesOptions

Ƭ BarSeriesOptions: SeriesOptions<BarStyleOptions>

Represents bar series options.


BarSeriesPartialOptions

Ƭ BarSeriesPartialOptions: SeriesPartialOptions<BarStyleOptions>

Represents bar series options where all properties are options.


BaseValueType

Ƭ BaseValueType: BaseValuePrice

Represents a type of a base value of baseline series type.


BaselineSeriesOptions

Ƭ BaselineSeriesOptions: SeriesOptions<BaselineStyleOptions>

Structure describing baseline series options.


BaselineSeriesPartialOptions

Ƭ BaselineSeriesPartialOptions: SeriesPartialOptions<BaselineStyleOptions>

Represents baseline series options where all properties are options.


CandlestickSeriesOptions

Ƭ CandlestickSeriesOptions: SeriesOptions<CandlestickStyleOptions>

Represents candlestick series options.


CandlestickSeriesPartialOptions

Ƭ CandlestickSeriesPartialOptions: SeriesPartialOptions<CandlestickStyleOptions>

Represents candlestick series options where all properties are optional.


Coordinate

Ƭ Coordinate: Nominal<number, "Coordinate">

Represents a coordiate as a number.


CreatePriceLineOptions

Ƭ CreatePriceLineOptions: Partial<PriceLineOptions> & Pick<PriceLineOptions, "price">

Price line options for the createPriceLine method.

price is required, while the rest of the options are optional.


DeepPartial

Ƭ DeepPartial<T>: { [P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends readonly (infer X)[] ? readonly DeepPartial<X>[] : DeepPartial<T[P]> }

Represents a type T where every property is optional.

Type parameters

Name
T

HistogramSeriesOptions

Ƭ HistogramSeriesOptions: SeriesOptions<HistogramStyleOptions>

Represents histogram series options.


HistogramSeriesPartialOptions

Ƭ HistogramSeriesPartialOptions: SeriesPartialOptions<HistogramStyleOptions>

Represents histogram series options where all properties are optional.


HorzAlign

Ƭ HorzAlign: "left" | "center" | "right"

Represents a horizontal alignment.


LineSeriesOptions

Ƭ LineSeriesOptions: SeriesOptions<LineStyleOptions>

Represents line series options.


LineSeriesPartialOptions

Ƭ LineSeriesPartialOptions: SeriesPartialOptions<LineStyleOptions>

Represents line series options where all properties are optional.


LineWidth

Ƭ LineWidth: 1 | 2 | 3 | 4

Represents the width of a line.


Logical

Ƭ Logical: Nominal<number, "Logical">

Represents the to or from number in a logical range.


LogicalRange

Ƭ LogicalRange: Range<Logical>

A logical range is an object with 2 properties: from and to, which are numbers and represent logical indexes on the time scale.

The starting point of the time scale's logical range is the first data item among all series. Before that point all indexes are negative, starting from that point - positive.

Indexes might have fractional parts, for instance 4.2, due to the time-scale being continuous rather than discrete.

Integer part of the logical index means index of the fully visible bar. Thus, if we have 5.2 as the last visible logical index (to field), that means that the last visible bar has index 5, but we also have partially visible (for 20%) 6th bar. Half (e.g. 1.5, 3.5, 10.5) means exactly a middle of the bar.


LogicalRangeChangeEventHandler

Ƭ LogicalRangeChangeEventHandler: (logicalRange: LogicalRange | null) => void

Type declaration

▸ (logicalRange): void

A custom function used to handle changes to the time scale's logical range.

Parameters
NameType
logicalRangeLogicalRange | null
Returns

void


MouseEventHandler

Ƭ MouseEventHandler: (param: MouseEventParams) => void

Type declaration

▸ (param): void

A custom function use to handle mouse events.

Parameters
NameType
paramMouseEventParams
Returns

void


Nominal

Ƭ Nominal<T, Name>: T & { [species]: Name }

This is the generic type useful for declaring a nominal type, which does not structurally matches with the base type and the other types declared over the same base type

Example

type Index = Nominal<number, 'Index'>;
// let i: Index = 42; // this fails to compile
let i: Index = 42 as Index; // OK

Example

type TagName = Nominal<string, 'TagName'>;

Type parameters

NameType
TT
Nameextends string

OverlayPriceScaleOptions

Ƭ OverlayPriceScaleOptions: Omit<PriceScaleOptions, "visible" | "autoScale">

Represents overlay price scale options.


PriceFormat

Ƭ PriceFormat: PriceFormatBuiltIn | PriceFormatCustom

Represents information used to format prices.


PriceFormatterFn

Ƭ PriceFormatterFn: (priceValue: BarPrice) => string

Type declaration

▸ (priceValue): string

A function used to format a BarPrice as a string.

Parameters
NameType
priceValueBarPrice
Returns

string


SeriesMarkerPosition

Ƭ SeriesMarkerPosition: "aboveBar" | "belowBar" | "inBar"

Represents the position of a series marker relative to a bar.


SeriesMarkerShape

Ƭ SeriesMarkerShape: "circle" | "square" | "arrowUp" | "arrowDown"

Represents the shape of a series marker.


SeriesOptions

Ƭ SeriesOptions<T>: T & SeriesOptionsCommon

Represents the intersection of a series type T's options and common series options.

See

SeriesOptionsCommon for common options.

Type parameters

Name
T

SeriesPartialOptions

Ƭ SeriesPartialOptions<T>: DeepPartial<T & SeriesOptionsCommon>

Represents a SeriesOptions where every property is optional.

Type parameters

Name
T

SeriesType

Ƭ SeriesType: keyof SeriesOptionsMap

Represents a type of series.

See

SeriesOptionsMap


SizeChangeEventHandler

Ƭ SizeChangeEventHandler: (width: number, height: number) => void

Type declaration

▸ (width, height): void

A custom function used to handle changes to the time scale's size.

Parameters
NameType
widthnumber
heightnumber
Returns

void


TickMarkFormatter

Ƭ TickMarkFormatter: (time: Time, tickMarkType: TickMarkType, locale: string) => string | null

Type declaration

▸ (time, tickMarkType, locale): string | null

The TickMarkFormatter is used to customize tick mark labels on the time scale.

This function should return time as a string formatted according to tickMarkType type (year, month, etc) and locale.

Note that the returned string should be the shortest possible value and should have no more than 8 characters. Otherwise, the tick marks will overlap each other.

If the formatter function returns null then the default tick mark formatter will be used as a fallback.

Example

const customFormatter = (time, tickMarkType, locale) => {
// your code here
};
Parameters
NameType
timeTime
tickMarkTypeTickMarkType
localestring
Returns

string | null


Time

Ƭ Time: UTCTimestamp | BusinessDay | string

The Time type is used to represent the time of data items.

Values can be a UTCTimestamp, a BusinessDay, or a business day string in ISO format.

Example

const timestamp = 1529899200; // Literal timestamp representing 2018-06-25T04:00:00.000Z
const businessDay = { year: 2019, month: 6, day: 1 }; // June 1, 2019
const businessDayString = '2021-02-03'; // Business day string literal

TimeFormatterFn

Ƭ TimeFormatterFn: (time: Time) => string

Type declaration

▸ (time): string

A custom function used to override formatting of a time to a string.

Parameters
NameType
timeTime
Returns

string


TimeRange

Ƭ TimeRange: Range<Time>

Represents a Time range.


TimeRangeChangeEventHandler

Ƭ TimeRangeChangeEventHandler: (timeRange: TimeRange | null) => void

Type declaration

▸ (timeRange): void

A custom function used to handle changes to the time scale's time range.

Parameters
NameType
timeRangeTimeRange | null
Returns

void


UTCTimestamp

Ƭ UTCTimestamp: Nominal<number, "UTCTimestamp">

Represents a time as a UNIX timestamp.

If your chart displays an intraday interval you should use a UNIX Timestamp.

Note that JavaScript Date APIs like Date.now return a number of milliseconds but UTCTimestamp expects a number of seconds.

Note that to prevent errors, you should cast the numeric type of the time to UTCTimestamp type from the package (value as UTCTimestamp) in TypeScript code.

Example

const timestamp = 1529899200 as UTCTimestamp; // Literal timestamp representing 2018-06-25T04:00:00.000Z
const timestamp2 = (Date.now() / 1000) as UTCTimestamp;

VertAlign

Ƭ VertAlign: "top" | "center" | "bottom"

Represents a vertical alignment.


VisiblePriceScaleOptions

Ƭ VisiblePriceScaleOptions: PriceScaleOptions

Represents a visible price scale's options.

See

PriceScaleOptions