Interface: IChartApiBase<HorzScaleItem>
The main interface of a single chart.
Type parameters
Name | Type |
---|---|
HorzScaleItem | Time |
Hierarchy
IChartApiBase
Methods
remove
▸ remove(): void
Removes the chart object including all DOM elements. This is an irreversible operation, you cannot do anything with the chart after removing it.
Returns
void
resize
▸ resize(width
, height
, forceRepaint?
): 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.
Parameters
Name | Type | Description |
---|---|---|
width | number | Target width of the chart. |
height | number | Target height of the chart. |
forceRepaint? | boolean | True to initiate resize immediately. One could need this to get screenshot immediately after resize. |
Returns
void
addCustomSeries
▸ addCustomSeries<TData
, TOptions
, TPartialOptions
>(customPaneView
, customOptions?
): ISeriesApi
<"Custom"
, HorzScaleItem
, TData
| WhitespaceData
<HorzScaleItem
>, TOptions
, TPartialOptions
>
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.
Type parameters
Name | Type |
---|---|
TData | extends CustomData <HorzScaleItem , TData > |
TOptions | extends CustomSeriesOptions |
TPartialOptions | extends DeepPartial <TOptions & SeriesOptionsCommon > = DeepPartial <TOptions & SeriesOptionsCommon > |
Parameters
Name | Type | Description |
---|---|---|
customPaneView | ICustomSeriesPaneView <HorzScaleItem , TData , TOptions > | A custom series pane view which implements the custom renderer. |
customOptions? | DeepPartial <TOptions & SeriesOptionsCommon > | Customization parameters of the series being created. js const series = chart.addCustomSeries(myCustomPaneView); |
Returns
ISeriesApi
<"Custom"
, HorzScaleItem
, TData
| WhitespaceData
<HorzScaleItem
>, TOptions
, TPartialOptions
>
addAreaSeries
▸ addAreaSeries(areaOptions?
): ISeriesApi
<"Area"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | AreaData
<HorzScaleItem
>, AreaSeriesOptions
, DeepPartial
<AreaStyleOptions
& SeriesOptionsCommon
>>
Creates an area series with specified parameters.
Example
const series = chart.addAreaSeries();
Parameters
Name | Type | Description |
---|---|---|
areaOptions? | DeepPartial <AreaStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Area"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | AreaData
<HorzScaleItem
>, AreaSeriesOptions
, DeepPartial
<AreaStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
addBaselineSeries
▸ addBaselineSeries(baselineOptions?
): ISeriesApi
<"Baseline"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | BaselineData
<HorzScaleItem
>, BaselineSeriesOptions
, DeepPartial
<BaselineStyleOptions
& SeriesOptionsCommon
>>
Creates a baseline series with specified parameters.
Example
const series = chart.addBaselineSeries();
Parameters
Name | Type | Description |
---|---|---|
baselineOptions? | DeepPartial <BaselineStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Baseline"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | BaselineData
<HorzScaleItem
>, BaselineSeriesOptions
, DeepPartial
<BaselineStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
addBarSeries
▸ addBarSeries(barOptions?
): ISeriesApi
<"Bar"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | BarData
<HorzScaleItem
>, BarSeriesOptions
, DeepPartial
<BarStyleOptions
& SeriesOptionsCommon
>>
Creates a bar series with specified parameters.
Example
const series = chart.addBarSeries();
Parameters
Name | Type | Description |
---|---|---|
barOptions? | DeepPartial <BarStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Bar"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | BarData
<HorzScaleItem
>, BarSeriesOptions
, DeepPartial
<BarStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
addCandlestickSeries
▸ addCandlestickSeries(candlestickOptions?
): ISeriesApi
<"Candlestick"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | CandlestickData
<HorzScaleItem
>, CandlestickSeriesOptions
, DeepPartial
<CandlestickStyleOptions
& SeriesOptionsCommon
>>
Creates a candlestick series with specified parameters.
Example
const series = chart.addCandlestickSeries();
Parameters
Name | Type | Description |
---|---|---|
candlestickOptions? | DeepPartial <CandlestickStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Candlestick"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | CandlestickData
<HorzScaleItem
>, CandlestickSeriesOptions
, DeepPartial
<CandlestickStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
addHistogramSeries
▸ addHistogramSeries(histogramOptions?
): ISeriesApi
<"Histogram"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | HistogramData
<HorzScaleItem
>, HistogramSeriesOptions
, DeepPartial
<HistogramStyleOptions
& SeriesOptionsCommon
>>
Creates a histogram series with specified parameters.
Example
const series = chart.addHistogramSeries();
Parameters
Name | Type | Description |
---|---|---|
histogramOptions? | DeepPartial <HistogramStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Histogram"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | HistogramData
<HorzScaleItem
>, HistogramSeriesOptions
, DeepPartial
<HistogramStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
addLineSeries
▸ addLineSeries(lineOptions?
): ISeriesApi
<"Line"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | LineData
<HorzScaleItem
>, LineSeriesOptions
, DeepPartial
<LineStyleOptions
& SeriesOptionsCommon
>>
Creates a line series with specified parameters.
Example
const series = chart.addLineSeries();
Parameters
Name | Type | Description |
---|---|---|
lineOptions? | DeepPartial <LineStyleOptions & SeriesOptionsCommon > | Customization parameters of the series being created. |
Returns
ISeriesApi
<"Line"
, HorzScaleItem
, WhitespaceData
<HorzScaleItem
> | LineData
<HorzScaleItem
>, LineSeriesOptions
, DeepPartial
<LineStyleOptions
& SeriesOptionsCommon
>>
An interface of the created series.
removeSeries
▸ removeSeries(seriesApi
): void
Removes a series of any type. This is an irreversible operation, you cannot do anything with the series after removing it.
Example
chart.removeSeries(series);
Parameters
Name | Type |
---|---|
seriesApi | ISeriesApi <keyof SeriesOptionsMap , HorzScaleItem , CustomData <HorzScaleItem > | WhitespaceData <HorzScaleItem > | AreaData <HorzScaleItem > | BaselineData <HorzScaleItem > | BarData <HorzScaleItem > | CandlestickData <HorzScaleItem > | HistogramData <HorzScaleItem > | LineData <HorzScaleItem > | CustomSeriesWhitespaceData <HorzScaleItem >, CustomSeriesOptions | AreaSeriesOptions | BaselineSeriesOptions | BarSeriesOptions | CandlestickSeriesOptions | HistogramSeriesOptions | LineSeriesOptions , DeepPartial <AreaStyleOptions & SeriesOptionsCommon > | DeepPartial <BaselineStyleOptions & SeriesOptionsCommon > | DeepPartial <BarStyleOptions & SeriesOptionsCommon > | DeepPartial <CandlestickStyleOptions & SeriesOptionsCommon > | DeepPartial <HistogramStyleOptions & SeriesOptionsCommon > | DeepPartial <LineStyleOptions & SeriesOptionsCommon > | DeepPartial <CustomStyleOptions & SeriesOptionsCommon >> |
Returns
void
subscribeClick
▸ subscribeClick(handler
): void
Subscribe to the chart click event.
Example
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);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Handler to be called on mouse click. |
Returns
void
unsubscribeClick
▸ unsubscribeClick(handler
): void
Unsubscribe a handler that was previously subscribed using subscribeClick.
Example
chart.unsubscribeClick(myClickHandler);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Previously subscribed handler |
Returns
void
subscribeDblClick
▸ subscribeDblClick(handler
): void
Subscribe to the chart double-click event.
Example
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);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Handler to be called on mouse double-click. |
Returns
void
unsubscribeDblClick
▸ unsubscribeDblClick(handler
): void
Unsubscribe a handler that was previously subscribed using subscribeDblClick.
Example
chart.unsubscribeDblClick(myDblClickHandler);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Previously subscribed handler |
Returns
void
subscribeCrosshairMove
▸ subscribeCrosshairMove(handler
): void
Subscribe to the crosshair move event.
Example
function myCrosshairMoveHandler(param) {
if (!param.point) {
return;
}
console.log(`Crosshair moved to ${param.point.x}, ${param.point.y}. The time is ${param.time}.`);
}
chart.subscribeCrosshairMove(myCrosshairMoveHandler);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Handler to be called on crosshair move. |
Returns
void
unsubscribeCrosshairMove
▸ unsubscribeCrosshairMove(handler
): void
Unsubscribe a handler that was previously subscribed using subscribeCrosshairMove.
Example
chart.unsubscribeCrosshairMove(myCrosshairMoveHandler);
Parameters
Name | Type | Description |
---|---|---|
handler | MouseEventHandler <HorzScaleItem > | Previously subscribed handler |
Returns
void
priceScale
▸ priceScale(priceScaleId
): IPriceScaleApi
Returns API to manipulate a price scale.
Parameters
Name | Type | Description |
---|---|---|
priceScaleId | string | ID of the price scale. |
Returns
Price scale API.
timeScale
▸ timeScale(): ITimeScaleApi
<HorzScaleItem
>
Returns API to manipulate the time scale
Returns
ITimeScaleApi
<HorzScaleItem
>
Target API
applyOptions
▸ applyOptions(options
): void
Applies new options to the chart
Parameters
Name | Type | Description |
---|---|---|
options | DeepPartial <ChartOptionsImpl <HorzScaleItem >> | Any subset of options. |
Returns
void
options
▸ options(): Readonly
<ChartOptionsImpl
<HorzScaleItem
>>
Returns currently applied options
Returns
Readonly
<ChartOptionsImpl
<HorzScaleItem
>>
Full set of currently applied options, including defaults
takeScreenshot
▸ takeScreenshot(): HTMLCanvasElement
Make a screenshot of the chart with all the elements excluding crosshair.
Returns
HTMLCanvasElement
A canvas with the chart drawn on. Any Canvas
methods like toDataURL()
or toBlob()
can be used to serialize the result.
autoSizeActive
▸ autoSizeActive(): boolean
Returns the active state of the autoSize
option. This can be used to check
whether the chart is handling resizing automatically with a ResizeObserver
.
Returns
boolean
Whether the autoSize
option is enabled and the active.
chartElement
▸ chartElement(): HTMLDivElement
Returns the generated div element containing the chart. This can be used for adding your own additional event listeners, or for measuring the elements dimensions and position within the document.
Returns
HTMLDivElement
generated div element containing the chart.
setCrosshairPosition
▸ setCrosshairPosition(price
, horizontalPosition
, seriesApi
): void
Set the crosshair position within the chart.
Usually the crosshair position is set automatically by the user's actions. However in some cases you may want to set it explicitly.
For example if you want to synchronise the crosshairs of two separate charts.
Parameters
Returns
void
clearCrosshairPosition
▸ clearCrosshairPosition(): void
Clear the crosshair position within the chart.
Returns
void
paneSize
▸ paneSize(): PaneSize
Returns the dimensions of the chart pane (the plot surface which excludes time and price scales). This would typically only be useful for plugin development.
Returns
Dimensions of the chart pane