Skip to main content

IChartWidgetApi

Interface

The main chart API.

This interface can be retrieved by using the following widget (IChartingLibraryWidget) methods:

Methods

applyLineToolsState

Apply line tools state to the chart which will restore the drawings from the saved content.

This method requires that the saveload_separate_drawings_storage featureset is enabled.

Signature

applyLineToolsState(state: LineToolsAndGroupsState) => Promise<void>

Parameters

NameType
stateLineToolsAndGroupsState

Returns

Promise<void>


applyStudyTemplate

Apply a study template to the chart.

Example

widget.activeChart().applyStudyTemplate(template);

Signature

applyStudyTemplate(template: object) => void

Parameters

NameTypeDescription
templateobjectA study template object.

Returns

void


availableZOrderOperations

Get an object with operations available for the specified set of entities.

Example

widget.activeChart().availableZOrderOperations([id]);

Signature

availableZOrderOperations(sources: readonly EntityId[]) => AvailableZOrderOperations

Parameters

NameTypeDescription
sourcesreadonly EntityId[]An array of entity IDs.

Returns

AvailableZOrderOperations


barTimeToEndOfPeriod

Get the bar time to the end of the period

Signature

barTimeToEndOfPeriod(unixTime: number) => number

Parameters

NameTypeDescription
unixTimenumberdate timestamp

Returns

number


bringForward

Move the sources one level up in the Z-order.

Example

widget.activeChart().bringForward([id]);

Signature

bringForward(sources: readonly EntityId[]) => void

Parameters

NameTypeDescription
sourcesreadonly EntityId[]An array of source IDs.

Returns

void


bringToFront

Move the sources to the top of the Z-order.

Example

widget.activeChart().bringToFront([id]);

Signature

bringToFront(sources: readonly EntityId[]) => void

Parameters

NameTypeDescription
sourcesreadonly EntityId[]An array of source IDs.

Returns

void


canZoomOut

Check if the chart can be zoomed out using the zoomOut method.

Example

if(widget.activeChart().canZoomOut()) {
widget.activeChart().zoomOut();
};

Signature

canZoomOut() => boolean

Returns

true if the chart can be zoomed out.

boolean


cancelSelectBar

Cancel any active bar selection requests.

Example

widget.activeChart().cancelSelectBar();

Signature

cancelSelectBar() => void

Returns

void


chartType

Returns the main series style type.

console.log(widget.activeChart().chartType());

Signature

chartType() => SeriesType

Returns

SeriesType


clearMarks

Remove marks from the chart.

Example

widget.activeChart().clearMarks();

Signature

clearMarks(marksToClear?: ClearMarksMode) => void

Parameters

NameTypeDescription
marksToClear?ClearMarksModetype 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.

Example

widget.createAnchoredShape({ x: 0.1, y: 0.9 }, { shape: 'anchored_text', text: 'Hello, charts!', overrides: { color: 'green' }});

For more information, refer to Drawings API.

Signature

createAnchoredShape<TOverrides>(position: PositionPercents, options: CreateAnchoredShapeOptions<TOverrides>) => EntityId

Type parameters

NameType
TOverridesextends object

Parameters

NameTypeDescription
positionPositionPercentsPercent-based x and y position of the new drawing, relative to the top left of the chart.
optionsCreateAnchoredShapeOptions<TOverrides>An options object for the new drawing.

Returns

EntityId


createExecutionShape

Deprecated

Starting from version 29, this method will only be available in Trading Platform.

Creates a new trade execution on the chart.

Example

widget.activeChart().createExecutionShape()
.setText("@1,320.75 Limit Buy 1")
.setTooltip("@1,320.75 Limit Buy 1")
.setTextColor("rgba(0,255,0,0.5)")
.setArrowColor("#0F0")
.setDirection("buy")
.setTime(widget.activeChart().getVisibleRange().from)
.setPrice(160);

Signature

createExecutionShape(options?: UndoOptions) => IExecutionLineAdapter

Parameters

NameTypeDescription
options?UndoOptionsOptional undo options.

Returns

An API object for interacting with the execution.

IExecutionLineAdapter


createMultipointShape

Create a new multi point drawing.

Example

const from = Date.now() / 1000 - 500 * 24 * 3600; // 500 days ago
const to = Date.now() / 1000;
widget.activeChart().createMultipointShape(
[{ time: from, price: 150 }, { time: to, price: 150 }],
{
shape: "trend_line",
lock: true,
disableSelection: true,
disableSave: true,
disableUndo: true,
text: "text",
}
);

For more information, refer to Drawings API.

Signature

createMultipointShape<TOverrides>(points: ShapePoint[], options: CreateMultipointShapeOptions<TOverrides>) => EntityId

Type parameters

NameType
TOverridesextends object

Parameters

NameTypeDescription
pointsShapePoint[]An array of points that define the drawing.
optionsCreateMultipointShapeOptions<TOverrides>An options object for the new drawing.

Returns

The ID of the new drawing if it was created successfully, or null otherwise.

EntityId


createOrderLine

Deprecated

Starting from version 29, this method will only be available in Trading Platform.

Create a new trading order on the chart.

Example

widget.activeChart().createOrderLine()
.setTooltip("Additional order information")
.setModifyTooltip("Modify order")
.setCancelTooltip("Cancel order")
.onMove(function() {
this.setText("onMove called");
})
.onModify("onModify called", function(text) {
this.setText(text);
})
.onCancel("onCancel called", function(text) {
this.setText(text);
})
.setText("STOP: 73.5 (5,64%)")
.setQuantity("2");

Signature

createOrderLine(options?: UndoOptions) => IOrderLineAdapter

Parameters

NameTypeDescription
options?UndoOptionsOptional undo options.

Returns

An API object for interacting with the order.

IOrderLineAdapter


createPositionLine

Deprecated

Starting from version 29, this method will only be available in Trading Platform.

Creates a new trading position on the chart.

Example

widget.chart().createPositionLine()
.onModify(function() {
this.setText("onModify called");
})
.onReverse("onReverse called", function(text) {
this.setText(text);
})
.onClose("onClose called", function(text) {
this.setText(text);
})
.setText("PROFIT: 71.1 (3.31%)")
.setTooltip("Additional position information")
.setProtectTooltip("Protect position")
.setCloseTooltip("Close position")
.setReverseTooltip("Reverse position")
.setQuantity("8.235")
.setPrice(160)
.setExtendLeft(false)
.setLineStyle(0)
.setLineLength(25);

Signature

createPositionLine(options?: UndoOptions) => IPositionLineAdapter

Parameters

NameTypeDescription
options?UndoOptionsOptional undo options.

Returns

An API object for interacting with the position.

IPositionLineAdapter


createShape

Create a new single point drawing.

Example

widget.activeChart().createShape({ time: 1514764800 }, { shape: 'vertical_line' });

For more information, refer to Drawings API.

Signature

createShape<TOverrides>(point: ShapePoint, options: CreateShapeOptions<TOverrides>) => EntityId

Type parameters

NameType
TOverridesextends object

Parameters

NameTypeDescription
pointShapePointA point. The location of the new drawing.
optionsCreateShapeOptions<TOverrides>An options object for the new drawing.

Returns

The ID of the new drawing if it was created successfully, or null otherwise.

EntityId


createStudy

Adds an indicator or a symbol for comparison to the chart. For more information, refer to the Indicators article.

Signature

createStudy<TOverrides>(name: string, forceOverlay?: boolean, lock?: boolean, inputs?: Record<string, StudyInputValue>, overrides?: TOverrides, options?: CreateStudyOptions) => Promise<EntityId>

Type parameters

NameType
TOverridesextends Partial<SingleIndicatorOverrides>

Parameters

NameTypeDescription
namestringname of an indicator as shown in the Indicators widget
forceOverlay?booleanforces the Charting Library to place the created indicator on the main pane
lock?booleanwhether a user will be able to remove/change/hide the indicator or not
inputs?Record<string, StudyInputValue>From version v22, it's an object containing named properties from the indicator properties dialog.
overrides?TOverridesAn object that contains overrides for a new indicator. Note that you should not specify the indicator name. Overrides for built-in indicators are listed in SingleIndicatorOverrides.
options?CreateStudyOptionsstudy creation options

Returns

ID of the created study

Promise<EntityId>


createStudyTemplate

Save the current study template to a object.

Example

const options = { saveSymbol: true, saveInterval: true };
const template = widget.activeChart().createStudyTemplate(options);

Signature

createStudyTemplate(options: CreateStudyTemplateOptions) => object

Parameters

NameTypeDescription
optionsCreateStudyTemplateOptionsAn object of study template options.

Returns

A study template object.

object


crossHairMoved

Get a subscription object for the crosshair moving over the chart.

Example

widget.activeChart().crossHairMoved().subscribe(
null,
({ time, price }) => console.log(time, price)
);

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, the callback is called immediately.

Example

widget.activeChart().dataReady(() => {
// ...
}

Signature

dataReady(callback?: Function) => boolean

Parameters

NameTypeDescription
callback?() => voidA callback function called when chart data is loaded.

Returns

boolean


endOfPeriodToBarTime

Get the end of period to bar time

Signature

endOfPeriodToBarTime(unixTime: number) => number

Parameters

NameTypeDescription
unixTimenumberdate timestamp

Returns

number


executeActionById

Execute an action.

Example

// ...
widget.activeChart().executeActionById("undo");
// ...
widget.activeChart().executeActionById("drawingToolbarAction"); // Hides or shows the drawing toolbar
// ...

Signature

executeActionById(actionId: ChartActionId) => void

Parameters

NameTypeDescription
actionIdChartActionIdAn action ID.

Returns

void


exportData

Export the current data from the chart.

Example

// Exports series' data only
widget.activeChart().exportData({ includeTime: false, includedStudies: [] });
// Exports series' data with times
widget.activeChart().exportData({ includedStudies: [] });
// Exports series' data with with user time
widget.activeChart().exportData({ includeTime: false, includeUserTime: true, includedStudies: [] });
// Exports data for the indicator which ID is STUDY_ID
widget.activeChart().exportData({ includeTime: false, includeSeries: false, includedStudies: ['STUDY_ID'] });
// Exports all available data from the chart
widget.activeChart().exportData({ includeUserTime: true });
// Exports series' data before 2018-01-01
widget.activeChart().exportData({ includeTime: false, to: Date.UTC(2018, 0, 1) / 1000 });
// Exports series' data after 2018-01-01
widget.activeChart().exportData({ includeTime: false, from: Date.UTC(2018, 0, 1) / 1000 });
// Exports series' data in the range between 2018-01-01 and 2018-02-01
widget.activeChart().exportData({ includeTime: false, from: Date.UTC(2018, 0, 1) / 1000, to: Date.UTC(2018, 1, 1) / 1000 });
// Exports all displayed data on the chart
widget.activeChart().exportData({ includeDisplayedValues: true });

Signature

exportData(options?: Partial<ExportDataOptions>) => Promise<ExportedData>

Parameters

NameTypeDescription
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.

Example

console.log(widget.activeChart().getAllPanesHeight());

Signature

getAllPanesHeight() => number[]

Returns

An array of heights.

number[]


getAllShapes

Get an array of IDs and name for all drawings on the chart.

Example

widget.activeChart().getAllShapes().forEach(({ name }) => console.log(name));

Signature

getAllShapes() => EntityInfo[]

Returns

An array of drawing information.

EntityInfo[]


getAllStudies

Get an array of IDs and names for all studies on the chart.

Example

widget.activeChart().getAllStudies().forEach(({ name }) => console.log(name));

Signature

getAllStudies() => EntityInfo[]

Returns

An array of study information.

EntityInfo[]


getCheckableActionState

Get the state of a checkable action.

Example

if (widget.activeChart().getCheckableActionState("drawingToolbarAction")) {
// ...
};

Signature

getCheckableActionState(actionId: ChartActionId) => boolean

Parameters

NameTypeDescription
actionIdChartActionIdAn action ID.

Returns

null if the action with specified id doesn't exist or is not checkable, true if the action is checked, false otherwise.

boolean


getLineToolsState

Get the line tools state containing the drawings on the active chart.

This method requires that the saveload_separate_drawings_storage featureset is enabled.

Signature

getLineToolsState() => LineToolsAndGroupsState

Returns

LineToolsAndGroupsState


getPanes

Get an array of API objects for interacting with the chart panes.

Example

widget.activeChart().getPanes()[1].moveTo(0);

Signature

getPanes() => IPaneApi[]

Returns

IPaneApi[]


getPriceToBarRatio

Get the chart's price to bar ratio.

Example

console.log(widget.activeChart().getPriceToBarRatio());

Signature

getPriceToBarRatio() => number

Returns

The ratio or null if no ratio is defined.

number


getSeries

Get the main series.

Example

widget.activeChart().getSeries().setVisible(false);

Signature

getSeries() => ISeriesApi

Returns

An API object for interacting with the main series.

ISeriesApi


getShapeById

Get a drawing by ID.

Example

widget.activeChart().getShapeById(id).bringToFront();

For more information, refer to Drawings API.

Signature

getShapeById(entityId: EntityId) => ILineDataSourceApi

Parameters

NameTypeDescription
entityIdEntityIdA drawing ID.

Returns

An API object for interacting with the drawing.

ILineDataSourceApi


getStudyById

Get a study by ID.

Example

widget.activeChart().getStudyById(id).setVisible(false);

Signature

getStudyById(entityId: EntityId) => IStudyApi

Parameters

NameTypeDescription
entityIdEntityIdThe study ID.

Returns

An API object for interacting with the study.

IStudyApi


getTimeScale

Get an API object for interacting with the timescale.

Example

var time = widget.activeChart().getTimeScale().coordinateToTime(100);

Signature

getTimeScale() => ITimeScaleApi

Returns

ITimeScaleApi


getTimezoneApi

Get an API object for interacting with the chart timezone.

Signature

getTimezoneApi() => ITimezoneApi

Returns

ITimezoneApi


getVisibleRange

Get the current visible time range.

Example

console.log(widget.activeChart().getVisibleRange());

Signature

getVisibleRange() => VisibleTimeRange

Returns

VisibleTimeRange


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.

Example

console.log(widget.activeChart().isPriceToBarRatioLocked());

Signature

isPriceToBarRatioLocked() => boolean

Returns

boolean


isSelectBarRequested

Check if bar selection mode is active or not.

Example

var isRequested = widget.activeChart().isSelectBarRequested();

Signature

isSelectBarRequested() => boolean

Returns

true if active, false otherwise.

boolean


loadChartTemplate

Load and apply a chart template.

Signature

loadChartTemplate(templateName: string) => Promise<void>

Parameters

NameTypeDescription
templateNamestringThe 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.

Example

widget.activeChart().onChartTypeChanged().subscribe(
null,
(chartType) => console.log('The type of chart is changed')
);

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.

Example

widget.activeChart().onDataLoaded().subscribe(
null,
() => console.log('New history bars are loaded'),
true
);

Signature

onDataLoaded() => ISubscription<() => void>

Returns

A subscription object for new data loaded for the chart.

ISubscription<() => void>


onHoveredSourceChanged

Get a subscription object for the ID of the study or series hovered by the crosshair.

Signature

onHoveredSourceChanged() => ISubscription<(sourceId: EntityId) => void>

Returns

A subscription object for the ID of the study or series hovered by the crosshair. Subscribers will be called with null if there is no study or series hovered.

ISubscription<(sourceId: EntityId) => void>


onIntervalChanged

Get a subscription object for the chart resolution (interval) changing. This method also allows you to track whether the chart's date range is changed. The timeframe argument represents if a user clicks on the time frame toolbar or changes the date range manually. If timeframe is undefined, you can change a date range before data loading starts. To do this, you can specify a time frame value or a certain date range.

Examples

The following code sample specifies a time frame value:

widget.activeChart().onIntervalChanged().subscribe(null, (interval, timeframeObj) =>
timeframeObj.timeframe = {
value: "12M",
type: "period-back"
});

The following code sample specifies a certain date range:

widget.activeChart().onIntervalChanged().subscribe(null, (interval, timeframeObj) =>
timeframeObj.timeframe = {
from: new Date('2015-01-01').getTime() / 1000,
to: new Date('2017-01-01').getTime() / 1000,
type: "time-range"
});

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.

Example

widget.activeChart().onSymbolChanged().subscribe(null, () => console.log('The symbol is changed'));

Signature

onSymbolChanged() => ISubscription<() => void>

Returns

A subscription object for when a symbol is resolved (ie changing resolution, timeframe, currency, etc.)

ISubscription<() => void>


onVisibleRangeChanged

Get a subscription object for the chart's visible range changing.

Example

widget.activeChart().onVisibleRangeChanged().subscribe(
null,
({ from, to }) => console.log(from, to)
);

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

INumberFormatter


refreshMarks

Force the chart to re-request all bar marks and timescale marks.

Example

widget.activeChart().refreshMarks();

Signature

refreshMarks() => void

Returns

void


reloadLineToolsFromServer

Manually trigger the chart to request the linetools again from the IExternalSaveLoadAdapter.loadLineToolsAndGroups method or the 'load_line_tools' endpoint of the Save and load REST API.

This method requires that the saveload_separate_drawings_storage featureset is enabled.

Signature

reloadLineToolsFromServer() => void

Returns

void


removeAllShapes

Remove all drawings from the chart.

Example

widget.activeChart().removeAllShapes();

Signature

removeAllShapes() => void

Returns

void


removeAllStudies

Remove all studies from the chart.

Example

widget.activeChart().removeAllStudies();

Signature

removeAllStudies() => void

Returns

void


removeEntity

Remove an entity (e.g. drawing or study) from the chart.

Example

widget.activeChart().removeEntity(id);

Signature

removeEntity(entityId: EntityId, options?: UndoOptions) => void

Parameters

NameTypeDescription
entityIdEntityIdThe ID of the entity.
options?UndoOptionsOptional undo options.

Returns

void


requestSelectBar

Switch the chart to bar selection mode.

Example

widget.activeChart().requestSelectBar()
.then(function(time) {
console.log('user selects bar with time', time);
})
.catch(function() {
console.log('bar selection was rejected');
});

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, for example if there are internet connection issues. Before calling this function the onResetCacheNeededCallback callback from IDatafeedChartApi.subscribeBars should be called.

Example

widget.activeChart().resetData();

Signature

resetData() => void

Returns

void


resolution

Get the current resolution (interval).

Example

console.log(widget.activeChart().resolution());

Signature

resolution() => ResolutionString

Returns

ResolutionString


restoreChart

Restore to its initial size currently selected chart.

Example

widget.activeChart().restoreChart();

Signature

restoreChart() => void

Returns

void


selection

Get an API object for interacting with the selection.

Example

widget.activeChart().selection().clear();

Signature

selection() => ISelectionApi

Returns

ISelectionApi


sendBackward

Move the sources one level down in the Z-order.

Example

widget.activeChart().sendBackward([id]);

Signature

sendBackward(sources: readonly EntityId[]) => void

Parameters

NameTypeDescription
sourcesreadonly EntityId[]An array of source IDs.

Returns

void


sendToBack

Move the group to the bottom of the Z-order.

Example

widget.activeChart().sendToBack([id]);

Signature

sendToBack(entities: readonly EntityId[]) => void

Parameters

NameTypeDescription
entitiesreadonly EntityId[]An array of entity IDs.

Returns

void


setAllPanesHeight

Set the height for each pane in the order provided.

Example

console.log(widget.activeChart().setAllPanesHeight([250, 400, 200]));

Signature

setAllPanesHeight(heights: readonly number[]) => void

Parameters

NameTypeDescription
heightsreadonly number[]An array of heights.

Returns

void


setChartType

Change the chart's type.

Example

widget.activeChart().setChartType(12); // Specifies the High-low type

Signature

setChartType(type: SeriesType, callback?: Function) => void

Parameters

NameTypeDescription
typeSeriesTypeA chart type.
callback?() => voidAn optional callback function. Called when the chart type has changed and data has loaded.

Returns

A promise that resolves with a boolean value. It's true when the chart type has been set and false when setting the chart type is not possible.

void


setPriceToBarRatio

Set the chart's price to bar ratio.

Example

widget.activeChart().setPriceToBarRatio(0.4567, { disableUndo: true });

Signature

setPriceToBarRatio(ratio: number, options?: UndoOptions) => void

Parameters

NameTypeDescription
rationumberThe new price to bar ratio.
options?UndoOptionsOptional undo options.

Returns

void


setPriceToBarRatioLocked

Lock or unlock the chart's price to bar ratio.

Example

widget.activeChart().setPriceToBarRatioLocked(true, { disableUndo: false });

Signature

setPriceToBarRatioLocked(value: boolean, options?: UndoOptions) => void

Parameters

NameTypeDescription
valuebooleantrue to lock, false to unlock.
options?UndoOptionsOptional undo options.

Returns

void


setResolution

Change the chart's interval (resolution).

Example

widget.activeChart().setResolution('2M');

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) => Promise<boolean>

Parameters

NameTypeDescription
resolutionResolutionStringA resolution.
options?SetResolutionOptions | () => voidOptional object of options for the new resolution or optional callback that is called when the data for the new resolution has loaded.

Returns

A promise that resolves with a boolean value. It's true when the resolution has been set and false when setting the resolution is not possible.

Promise<boolean>


setScrollEnabled

Enable or disable scrolling of the chart.

Example

widget.activeChart().setScrollEnabled(false);

Signature

setScrollEnabled(enabled: boolean) => void

Parameters

NameTypeDescription
enabledbooleantrue to enable scrolling, false to disable.

Returns

void


setSymbol

Change the chart's symbol.

Example

widget.activeChart().setSymbol('IBM');

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

NameTypeDescription
symbolstringA symbol.
options?SetSymbolOptions | () => voidOptional 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

NameTypeDescription
timeFrameRangeOptionsObject specifying the range and resolution to be applied

Returns

void


setVisibleRange

Scroll and/or scale the chart so a time range is visible.

Example

widget.activeChart().setVisibleRange(
{ from: 1420156800, to: 1451433600 },
{ percentRightMargin: 20 }
).then(() => console.log('New visible range is applied'));

Signature

setVisibleRange(range: SetVisibleTimeRange, options?: SetVisibleRangeOptions) => Promise<void>

Parameters

NameTypeDescription
rangeSetVisibleTimeRangeA range that will be made visible.
options?SetVisibleRangeOptionsOptional 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.

Example

widget.activeChart().setZoomEnabled(false);

Signature

setZoomEnabled(enabled: boolean) => void

Parameters

NameTypeDescription
enabledbooleantrue to enable zooming, false to disable.

Returns

void


shapesGroupController

Get an API object for interacting with groups of drawings. Refer to the Drawings API article for more information.

Example

widget.activeChart().shapesGroupController().createGroupFromSelection();

Signature

shapesGroupController() => IShapesGroupControllerApi

Returns

IShapesGroupControllerApi


showPropertiesDialog

Show the properties dialog for a study or drawing.

Example

const chart = widget.activeChart();
chart.showPropertiesDialog(chart.getAllShapes()[0].id);`

Signature

showPropertiesDialog(studyId: EntityId) => void

Parameters

NameTypeDescription
studyIdEntityIdAn ID of the study or drawing.

Returns

void


symbol

Get the name of the current symbol.

Example

console.log(widget.activeChart().symbol());

Signature

symbol() => string

Returns

string


symbolExt

Get an extended information object for the current symbol.

Example

console.log(widget.activeChart().symbolExt().name);

Signature

symbolExt() => SymbolExt

Returns

SymbolExt


zoomOut

Zoom out. The method has the same effect as clicking on the "Zoom out" button.

Signature

zoomOut() => void

Returns

void