IChartWidgetApi
The main chart API.
This interface can be retrieved by using the following widget (IChartingLibraryWidget) methods:
chart
(IChartingLibraryWidget.chart)activeChart
(IChartingLibraryWidget.activeChart)
Methods
applyStudyTemplate
Apply a study template to the chart.
Signature
applyStudyTemplate(template: object) => void
Parameters
Name | Type | Description |
---|---|---|
template | object | A study template object. |
Returns
void
availableZOrderOperations
Get an object with operations available for the specified set of entities.
Signature
availableZOrderOperations(sources: readonly EntityId[]) => AvailableZOrderOperations
Parameters
Name | Type | Description |
---|---|---|
sources | readonly EntityId[] | An array of entity IDs. |
Returns
barTimeToEndOfPeriod
Get the bar time to the end of the period
Signature
barTimeToEndOfPeriod(unixTime: number) => number
Parameters
Name | Type | Description |
---|---|---|
unixTime | number | date timestamp |
Returns
number
bringForward
Move the sources one level up in the Z-order.
Signature
bringForward(sources: readonly EntityId[]) => void
Parameters
Name | Type | Description |
---|---|---|
sources | readonly EntityId[] | An array of source IDs. |
Returns
void
bringToFront
Move the sources to the top of the Z-order.
Signature
bringToFront(sources: readonly EntityId[]) => void
Parameters
Name | Type | Description |
---|---|---|
sources | readonly EntityId[] | An array of source IDs. |
Returns
void
canZoomOut
Check if the chart can be zoomed out using the zoomOut method.
Signature
canZoomOut() => boolean
Returns
true
if the chart can be zoomed out.
boolean
cancelSelectBar
Cancel any active bar selection requests.
Signature
cancelSelectBar() => void
Returns
void
chartType
Returns the main series style type.
console.log(widget.activeChart().chartType());
Signature
chartType() => SeriesType
Returns
clearMarks
Remove marks from the chart.
Signature
clearMarks(marksToClear?: ClearMarksMode) => void
Parameters
Name | Type | Description |
---|---|---|
marksToClear? | ClearMarksMode | type of marks to clear. If nothing is specified both bar & timescale marks will be removed. |
Returns
void
createAnchoredShape
Create a new anchored drawing. Anchored drawings maintain their position when the chart's visible range changes.
Signature
createAnchoredShape<TOverrides>(position: PositionPercents, options: CreateAnchoredShapeOptions<TOverrides>) => EntityId
Type parameters
Name | Type |
---|---|
TOverrides | extends object |
Parameters
Name | Type | Description |
---|---|---|
position | PositionPercents | Percent-based x and y position of the new drawing, relative to the top left of the chart. |
options | CreateAnchoredShapeOptions<TOverrides> | An options object for the new drawing. |
Returns
createExecutionShape
Creates a new trade execution on the chart.
Signature
createExecutionShape(options?: UndoOptions) => IExecutionLineAdapter
Parameters
Name | Type | Description |
---|---|---|
options? | UndoOptions | Optional undo options. |
Returns
An API object for interacting with the execution.
createMultipointShape
Create a new multi point drawing.
Signature
createMultipointShape<TOverrides>(points: ShapePoint[], options: CreateMultipointShapeOptions<TOverrides>) => EntityId
Type parameters
Name | Type |
---|---|
TOverrides | extends object |
Parameters
Name | Type | Description |
---|---|---|
points | ShapePoint[] | An array of points that define the drawing. |
options | CreateMultipointShapeOptions<TOverrides> | An options object for the new drawing. |
Returns
The ID of the new drawing if it was created successfully, or null otherwise.
createOrderLine
Create a new trading order on the chart.
Signature
createOrderLine(options?: UndoOptions) => IOrderLineAdapter
Parameters
Name | Type | Description |
---|---|---|
options? | UndoOptions | Optional undo options. |
Returns
An API object for interacting with the order.
createPositionLine
Creates a new trading position on the chart.
Signature
createPositionLine(options?: UndoOptions) => IPositionLineAdapter
Parameters
Name | Type | Description |
---|---|---|
options? | UndoOptions | Optional undo options. |
Returns
An API object for interacting with the position.
createShape
Create a new single point drawing.
Signature
createShape<TOverrides>(point: ShapePoint, options: CreateShapeOptions<TOverrides>) => EntityId
Type parameters
Name | Type |
---|---|
TOverrides | extends object |
Parameters
Name | Type | Description |
---|---|---|
point | ShapePoint | A point. The location of the new drawing. |
options | CreateShapeOptions<TOverrides> | An options object for the new drawing. |
Returns
The ID of the new drawing if it was created successfully, or null otherwise.
createStudy
Signature
createStudy<TOverrides>(name: string, forceOverlay?: boolean, lock?: boolean, inputs?: Record<string, StudyInputValue>, overrides?: TOverrides, options?: CreateStudyOptions) => Promise<EntityId>
Type parameters
Name | Type |
---|---|
TOverrides | extends StudyOverrides |
Parameters
Name | Type | Description |
---|---|---|
name | string | name of an indicator as shown in the Indicators widget |
forceOverlay? | boolean | - |
lock? | boolean | - |
inputs? | Record<string, StudyInputValue> | - |
overrides? | TOverrides | - |
options? | CreateStudyOptions | - |
Returns
ID of the created study
Promise<EntityId>
Deprecated
Prefer createStudy
function that relies on named properties for inputs
.
See
Signature
createStudy<TStudyInputValue, TOverrides>(name: string, forceOverlay?: boolean, lock?: boolean, inputs?: TStudyInputValue[], overrides?: TOverrides, options?: CreateStudyOptions) => Promise<EntityId>
Type parameters
Name | Type |
---|---|
TStudyInputValue | extends StudyInputValue |
TOverrides | extends StudyOverrides |
Parameters
Name | Type |
---|---|
name | string |
forceOverlay? | boolean |
lock? | boolean |
inputs? | TStudyInputValue[] |
overrides? | TOverrides |
options? | CreateStudyOptions |
Returns
Promise<EntityId>
createStudyTemplate
Save the current study template to a object.
Signature
createStudyTemplate(options: CreateStudyTemplateOptions) => object
Parameters
Name | Type | Description |
---|---|---|
options | CreateStudyTemplateOptions | An object of study template options. |
Returns
A study template object.
object
crossHairMoved
Get a subscription object for the crosshair moving over the chart.
Signature
crossHairMoved() => ISubscription<(params: CrossHairMovedEventParams) => void>
Returns
A subscription object for the crosshair moving over the chart.
ISubscription<(params: CrossHairMovedEventParams) => void>
dataReady
Provide a callback function that will be called when chart data is loaded. If chart data is already loaded when this method is called then the callback is called immediately.
Signature
dataReady(callback: Function) => boolean
Parameters
Name | Type | Description |
---|---|---|
callback | () => void | A callback function called when chart data is loaded. |
Returns
boolean
defaultScrollPosition
Deprecated
Use defaultRightOffset from TimeScale API instead
Signature
defaultScrollPosition() => number
Returns
number
endOfPeriodToBarTime
Get the end of period to bar time
Signature
endOfPeriodToBarTime(unixTime: number) => number
Parameters
Name | Type | Description |
---|---|---|
unixTime | number | date timestamp |
Returns
number
executeActionById
Execute an action.
Signature
executeActionById(actionId: ChartActionId) => void
Parameters
Name | Type | Description |
---|---|---|
actionId | ChartActionId | An action ID. |
Returns
void
exportData
Export the current data from the chart.
Signature
exportData(options?: Partial<ExportDataOptions>) => Promise<ExportedData>
Parameters
Name | Type | Description |
---|---|---|
options? | Partial<ExportDataOptions> | Optional object of options to control the exported data. |
Returns
A promise that resolves with the exported data.
Promise<ExportedData>
getAllPanesHeight
Get an array of the heigh of all panes.
Signature
getAllPanesHeight() => number[]
Returns
An array of heights.
number[]
getAllShapes
Get an array of IDs and name for all drawings on the chart.
Signature
getAllShapes() => EntityInfo[]
Returns
An array of drawing information.
EntityInfo[]
getAllStudies
Get an array of IDs and names for all studies on the chart.
Signature
getAllStudies() => EntityInfo[]
Returns
An array of study information.
EntityInfo[]
getCheckableActionState
Get the state of a checkable action.
Signature
getCheckableActionState(actionId: ChartActionId) => boolean
Parameters
Name | Type | Description |
---|---|---|
actionId | ChartActionId | An action ID. |
Returns
true
if the action is checked, false
otherwise.
boolean
getPanes
Get an array of API objects for interacting with the chart panes.
Signature
getPanes() => IPaneApi[]
Returns
IPaneApi[]
getPriceToBarRatio
Get the chart's price to bar ratio.
Signature
getPriceToBarRatio() => number
Returns
The ratio or null
if no ratio is defined.
number
getSeries
Get the main series.
Signature
getSeries() => ISeriesApi
Returns
An API object for interacting with the main series.
getShapeById
Get a drawing by ID.
Signature
getShapeById(entityId: EntityId) => ILineDataSourceApi
Parameters
Name | Type | Description |
---|---|---|
entityId | EntityId | A drawing ID. |
Returns
An API object for interacting with the drawing.
getStudyById
Get a study by ID.
Signature
getStudyById(entityId: EntityId) => IStudyApi
Parameters
Name | Type | Description |
---|---|---|
entityId | EntityId | The study ID. |
Returns
An API object for interacting with the study.
getTimeScale
Get an API object for interacting with the timescale.
Signature
getTimeScale() => ITimeScaleApi
Returns
getTimezone
Deprecated
Use Timezone API instead
See
Signature
getTimezone() => "exchange" | Timezone
Returns
"exchange" | Timezone
getTimezoneApi
Get an API object for interacting with the chart timezone.
Signature
getTimezoneApi() => ITimezoneApi
Returns
getVisiblePriceRange
Deprecated
Use Price Scale API instead
Signature
getVisiblePriceRange() => VisiblePriceRange
Returns
getVisibleRange
Get the current visible time range.
Signature
getVisibleRange() => VisibleTimeRange
Returns
isMaximized
Check if the chart is maximized or not.
Signature
isMaximized() => boolean
Returns
true
if maximized, false
otherwise.
boolean
isPriceToBarRatioLocked
Get the locked/unlocked state of the chart's price to bar ratio.
Signature
isPriceToBarRatioLocked() => boolean
Returns
boolean
isSelectBarRequested
Check if bar selection mode is active or not.
Signature
isSelectBarRequested() => boolean
Returns
true
if active, false
otherwise.
boolean
loadChartTemplate
Load and apply a chart template.
Signature
loadChartTemplate(templateName: string) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
templateName | string | The name of the template to load. |
Returns
Promise<void>
marketStatus
Get a readonly watched value that can be used to read/subscribe to the state of the chart's market status.
Signature
marketStatus() => IWatchedValueReadonly<MarketStatus>
Returns
IWatchedValueReadonly<MarketStatus>
maximizeChart
Maximize to its full size currently selected chart.
Example:
widget.activeChart().maximizeChart();
Signature
maximizeChart() => void
Returns
void
onChartTypeChanged
Get a subscription object for the chart type changing.
Signature
onChartTypeChanged() => ISubscription<(chartType: SeriesType) => void>
Returns
A subscription object for the chart type changing.
ISubscription<(chartType: SeriesType) => void>
onDataLoaded
Get a subscription object for new data being loaded for the chart.
Signature
onDataLoaded() => ISubscription<() => void>
Returns
A subscription object for new data loaded for the chart.
ISubscription<() => void>
onIntervalChanged
Get a subscription object for the chart interval (resolution) changing.
Signature
onIntervalChanged() => ISubscription<(interval: ResolutionString, timeFrameParameters: { timeframe?: TimeFrameValue }) => void>
Returns
A subscription object for the chart interval (resolution) changing.
ISubscription<(interval: ResolutionString, timeFrameParameters: { timeframe?: TimeFrameValue }) => void>
onSymbolChanged
Get a subscription object for the chart symbol changing.
Signature
onSymbolChanged() => ISubscription<() => void>
Returns
A subscription object for the chart symbol changing.
ISubscription<() => void>
onVisibleRangeChanged
Get a subscription object for the chart's visible range changing.
Signature
onVisibleRangeChanged() => ISubscription<(range: VisibleTimeRange) => void>
Returns
A subscription object for the chart's visible range changing.
ISubscription<(range: VisibleTimeRange) => void>
priceFormatter
Returns the object with 'format' function that you can use to format the prices.
widget.activeChart().priceFormatter().format(123);
Signature
priceFormatter() => INumberFormatter
Returns
refreshMarks
Force the chart to re-request all bar marks and timescale marks.
Signature
refreshMarks() => void
Returns
void
removeAllShapes
Remove all drawings from the chart.
Signature
removeAllShapes() => void
Returns
void
removeAllStudies
Remove all studies from the chart.
Signature
removeAllStudies() => void
Returns
void
removeEntity
Remove an entity (e.g. drawing or study) from the chart.
Signature
removeEntity(entityId: EntityId, options?: UndoOptions) => void
Parameters
Name | Type | Description |
---|---|---|
entityId | EntityId | The ID of the entity. |
options? | UndoOptions | Optional undo options. |
Returns
void
requestSelectBar
Switch the chart to bar selection mode.
Signature
requestSelectBar() => Promise<number>
Returns
A promise that resolves to the timestamp of a bar selected by the user. Rejects if the bar selection was already requested or is cancelled.
Promise<number>
resetData
Force the chart to re-request data.
Before calling this function the onResetCacheNeededCallback
callback from IDatafeedChartApi.subscribeBars should be called.
Signature
resetData() => void
Returns
void
resolution
Get the current resolution (interval).
Signature
resolution() => ResolutionString
Returns
restoreChart
Restore to its initial size currently selected chart.
Example:
widget.activeChart().restoreChart();
Signature
restoreChart() => void
Returns
void
scrollPosition
Deprecated
Use rightOffset from TimeScale API instead
Signature
scrollPosition() => number
Returns
number
selection
Get an API object for interacting with the selection.
Signature
selection() => ISelectionApi
Returns
sendBackward
Move the sources one level down in the Z-order.
Signature
sendBackward(sources: readonly EntityId[]) => void
Parameters
Name | Type | Description |
---|---|---|
sources | readonly EntityId[] | An array of source IDs. |
Returns
void
sendToBack
Move the group to the bottom of the Z-order.
Signature
sendToBack(entities: readonly EntityId[]) => void
Parameters
Name | Type |
---|---|
entities | readonly EntityId[] |
Returns
void
setAllPanesHeight
Set the height for each pane in the order provided.
Signature
setAllPanesHeight(heights: readonly number[]) => void
Parameters
Name | Type | Description |
---|---|---|
heights | readonly number[] | An array of heights. |
Returns
void
setChartType
Change the chart's type.
Signature
setChartType(type: SeriesType, callback?: Function) => void
Parameters
Name | Type | Description |
---|---|---|
type | SeriesType | A chart type. |
callback? | () => void | An optional callback function. Called when the chart type has changed and data has loaded. |
Returns
void
setEntityVisibility
Deprecated
Use drawing/study API instead.
See
Signature
setEntityVisibility(entityId: EntityId, isVisible: boolean) => void
Parameters
Name | Type |
---|---|
entityId | EntityId |
isVisible | boolean |
Returns
void
setPriceToBarRatio
Set the chart's price to bar ratio.
Signature
setPriceToBarRatio(ratio: number, options?: UndoOptions) => void
Parameters
Name | Type | Description |
---|---|---|
ratio | number | The new price to bar ratio. |
options? | UndoOptions | Optional undo options. |
Returns
void
setPriceToBarRatioLocked
Lock or unlock the chart's price to bar ratio.
Signature
setPriceToBarRatioLocked(value: boolean, options?: UndoOptions) => void
Parameters
Name | Type | Description |
---|---|---|
value | boolean | true to lock, false to unlock. |
options? | UndoOptions | Optional undo options. |
Returns
void
setResolution
Change the chart's interval (resolution).
Note: if you are attempting to change multiple charts (multi-chart layouts) at the same time with
multiple setResolution calls then you should set doNotActivateChart
option to true
.
Signature
setResolution(resolution: ResolutionString, options?: SetResolutionOptions | Function) => void
Parameters
Name | Type | Description |
---|---|---|
resolution | ResolutionString | A resolution. |
options? | SetResolutionOptions | () => void | Optional object of options for the new resolution or optional callback that is called when the data for the new resolution has loaded. |
Returns
void
setScrollEnabled
Enable or disable scrolling of the chart.
Signature
setScrollEnabled(enabled: boolean) => void
Parameters
Name | Type | Description |
---|---|---|
enabled | boolean | true to enable scrolling, false to disable. |
Returns
void
setSymbol
Change the chart's symbol.
Note: if you are attempting to change multiple charts (multi-chart layouts) at the same time with
multiple setSymbol calls then you should set doNotActivateChart
option to true
.
Signature
setSymbol(symbol: string, options?: SetSymbolOptions | Function) => void
Parameters
Name | Type | Description |
---|---|---|
symbol | string | A symbol. |
options? | SetSymbolOptions | () => void | Optional object of options for the new symbol or optional callback that is called when the data for the new symbol has loaded. |
Returns
void
setTimeFrame
Set the time frame for this chart.
Note: This action will set this chart as active in a multi-chart layout.
Example To apply the '1Y' timeframe:
tvWidget.setTimeFrame({
val: { type: 'period-back', value: '12M' },
res: '1W',
});
Signature
setTimeFrame(timeFrame: RangeOptions) => void
Parameters
Name | Type | Description |
---|---|---|
timeFrame | RangeOptions | Object specifying the range and resolution to be applied |
Returns
void
setTimezone
Deprecated
Use Timezone API instead
See
Signature
setTimezone(timezone: "exchange" | Timezone) => void
Parameters
Name | Type |
---|---|
timezone | "exchange" | Timezone |
Returns
void
setVisibleRange
Scroll and/or scale the chart so a time range is visible.
Signature
setVisibleRange(range: SetVisibleTimeRange, options?: SetVisibleRangeOptions) => Promise<void>
Parameters
Name | Type | Description |
---|---|---|
range | SetVisibleTimeRange | A range that will be made visible. |
options? | SetVisibleRangeOptions | Optional object of options for the new visible range. |
Returns
A promise that is resolved when the range has been set.
Promise<void>
setZoomEnabled
Enable or disable zooming of the chart.
Signature
setZoomEnabled(enabled: boolean) => void
Parameters
Name | Type | Description |
---|---|---|
enabled | boolean | true to enable zooming, false to disable. |
Returns
void
shapesGroupController
Get an API object for interacting with groups of drawings.
Signature
shapesGroupController() => IShapesGroupControllerApi
Returns
showPropertiesDialog
Show the properties dialog for a study or drawing.
Signature
showPropertiesDialog(studyId: EntityId) => void
Parameters
Name | Type | Description |
---|---|---|
studyId | EntityId | An ID of the study or drawing. |
Returns
void
symbol
Get the name of the current symbol.
Signature
symbol() => string
Returns
string
symbolExt
Get an extended information object for the current symbol.
Signature
symbolExt() => SymbolExt
Returns
zoomOut
Zoom out. The method has the same effect as clicking on the "Zoom out" button.
Signature
zoomOut() => void
Returns
void