lightweight-charts
Enumerations
- ColorType
- CrosshairMode
- LastPriceAnimationMode
- LineStyle
- LineType
- PriceLineSource
- PriceScaleMode
- TickMarkType
- TrackingModeExitMode
Interfaces
- AreaStyleOptions
- AutoScaleMargins
- AutoscaleInfo
- AxisPressedMouseMoveOptions
- BarData
- BarPrices
- BarStyleOptions
- BarsInfo
- BaseValuePrice
- BaselineStyleOptions
- BusinessDay
- CandlestickData
- CandlestickStyleOptions
- ChartOptions
- CrosshairLineOptions
- CrosshairOptions
- GridLineOptions
- GridOptions
- HandleScaleOptions
- HandleScrollOptions
- HistogramData
- HistogramStyleOptions
- IChartApi
- IPriceFormatter
- IPriceLine
- IPriceScaleApi
- ISeriesApi
- ITimeScaleApi
- KineticScrollOptions
- LayoutOptions
- LineData
- LineStyleOptions
- LocalizationOptions
- MouseEventParams
- OhlcData
- Point
- PriceFormatBuiltIn
- PriceFormatCustom
- PriceLineOptions
- PriceRange
- PriceScaleMargins
- PriceScaleOptions
- Range
- SeriesDataItemTypeMap
- SeriesMarker
- SeriesOptionsCommon
- SeriesOptionsMap
- SeriesPartialOptionsMap
- SingleValueData
- SolidColor
- TimeScaleOptions
- TrackingModeOptions
- VerticalGradientColor
- WatermarkOptions
- WhitespaceData
Functions
createChart
▸ createChart(container
, options?
): IChartApi
This function is the main entry point of the Lightweight Charting Library.
Parameters
Name | Type | Description |
---|---|---|
container | string | HTMLElement | ID of HTML element or element itself |
options? | DeepPartial <ChartOptions > | Any subset of options to be applied at start. |
Returns
An interface to the created chart
isBusinessDay
▸ isBusinessDay(time
): time is BusinessDay
Check if a time value is a business day object.
Parameters
Name | Type | Description |
---|---|---|
time | Time | The 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
Name | Type | Description |
---|---|---|
time | Time | The 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
Name | Type | Description |
---|---|---|
baseImplementation | () => AutoscaleInfo | null | The 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
.
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
Name | Type |
---|---|
logicalRange | LogicalRange | null |
Returns
void
MouseEventHandler
Ƭ MouseEventHandler: (param
: MouseEventParams
) => void
Type declaration
▸ (param
): void
A custom function use to handle mouse events.
Parameters
Name | Type |
---|---|
param | MouseEventParams |
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
Name | Type |
---|---|
T | T |
Name | extends 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
Name | Type |
---|---|
priceValue | BarPrice |
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
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
Name | Type |
---|---|
width | number |
height | number |
Returns
void
TickMarkFormatter
Ƭ TickMarkFormatter: (time
: UTCTimestamp
| BusinessDay
, tickMarkType
: TickMarkType
, locale
: string
) => string
Type declaration
▸ (time
, tickMarkType
, locale
): string
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.
Example
const customFormatter = (time, tickMarkType, locale) => {
// your code here
};
Parameters
Name | Type |
---|---|
time | UTCTimestamp | BusinessDay |
tickMarkType | TickMarkType |
locale | string |
Returns
string
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
: BusinessDay
| UTCTimestamp
) => string
Type declaration
▸ (time
): string
A custom function used to override formatting of a time to a string.
Parameters
Name | Type |
---|---|
time | BusinessDay | UTCTimestamp |
Returns
string
TimeRange
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
Name | Type |
---|---|
timeRange | TimeRange | null |
Returns
void
UTCTimestamp
Ƭ UTCTimestamp: Nominal
<number
, "UTCTimestamp"
>
Represents a time a 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
References
LasPriceAnimationMode
Renames and re-exports LastPriceAnimationMode