Skip to main content
Version: v25

Widget Constructor

The Widget Constructor is the entry point to the library. It allows you to embed the library within your web page. You can use the Widget Constructor parameters to customize the widget's appearance and behavior. All parameters are listed in the ChartingLibraryWidgetOptions interface. If you use Trading Terminal, you can specify some additional parameters.

The following video tutorial describes Widget Constructor parameters and demonstrates how to use them.


The code sample below shows how to adjust some basic parameters using Widget Constructor.

Parameters

The following parameters relate to Advanced Charts and Trading Terminal.

Widget Configuration

Use the parameters below to configure basic widget settings:

ParameterDescription
containerRepresents either a reference to an attribute of a DOM element inside which the iframe with the chart will be placed or the HTMLElement itself.
library_pathA path to a static folder.
debugMakes the chart write detailed API logs into the browser console.

Chart Configuration

Use the parameters below to configure basic chart settings:

ParameterDescription
symbolThe default chart symbol.
intervalThe default chart interval.
timeframeThe default chart time frame.
time_framesThe list of visible time frames that can be selected at the bottom of the chart.
timezoneThe default chart time zone.
localeThe default chart locale.
favoritesItems that should be marked as favorite by default.

Data Configuration

Use the parameters below to connect data to the chart:

ParameterDescription
datafeedA JavaScript object that implements the IBasicDataFeed interface to supply the chart with data.
additional_symbol_info_fieldsAn optional field containing an array of custom symbol info fields to be shown in the Symbol Info dialog.
snapshot_urlA URL that is used to send a POST request with binary chart snapshots when a user presses the snapshot button.

Chart Size

Use the parameters below to customize the chart size:

ParameterDescription
widthThe desired width of the widget.
heightThe desired height of the widget.
fullscreenA Boolean value showing whether the chart should use all the available space in the window.
autosizeA Boolean value showing whether the chart should use all the available space in the container and resize when the container itself is resized.

UI Customization

Use the parameters below to customize colors, fonts, price and date formats, and more:

ParameterDescription
toolbar_bgA background color of the toolbars.
themeThe predefined custom theme color for the chart.
custom_css_urlAdds your custom CSS to the chart.
custom_font_familyChanges the font family used on the chart.
custom_formattersCustom formatters for adjusting the display format of price, date, and time values.
custom_translate_functionUse this property to set your own translation function.
numeric_formattingAn object that contains formatting options for numbers.
overridesOverrides values for the default widget properties.
settings_overridesAn object that contains new values for values saved to the settings.
loading_screenAn object that allows you to customize the loading spinner.
context_menuAn object that allows you to customize the context menu.
time_scaleAn additional optional field to add more bars on screen.
header_widget_buttons_modeAn additional optional field to change the look and feel of buttons on the top toolbar.

Chart Features

If you want to change the chart's behavior or show/hide UI elements, you should use featuresets. The following parameters allow you to enable/disable a certain featureset:

ParameterDescription
enabled_featuresThe array containing names of features that should be enabled by default.
disabled_featuresThe array containing names of features that should be disabled by default.

Studies and Drawings

Use the parameters below to customize studies (indicators) and drawing tools:

ParameterDescription
study_count_limitMaximum amount of studies on the chart of a multichart layout.
studies_accessAn object that allows you to specify indicators available for users.
studies_overridesUse this option to customize the style or inputs of the indicators.
custom_indicators_getterA function that returns the Promise object with the array of your custom indicators.
drawings_accessAn object that allows you to specify drawing tools available for users.

Symbol Search and Comparison

ParameterDescription
symbol_search_request_delayA threshold delay in milliseconds that is used to reduce the number of symbol search requests when the user is typing a name of a symbol in the search box.
symbol_search_completeTakes an additional search result object parameter, and returns an additional human-friendly symbol name.
compare_symbolsAn array of custom compare symbols for the Compare window.

Saving and Loading Chart

Specify the following parameters to save/load a chart using the predefined REST API:

ParameterDescription
charts_storage_urlSets the storage URL endpoint for use with the high-level saving / loading charts API.
charts_storage_api_versionA version of your backend. Supported values are: "1.0" | "1.1".
client_idSets the client ID for the high-level saving/loading charts API.
user_idSets the user ID for the high-level saving/loading charts API.

Specify the following parameters to save/load a chart using the low-level API:

ParameterDescription
auto_save_delayA threshold delay in seconds that is used to reduce the number of onAutoSaveNeeded calls.
saved_dataAn object containing saved chart content.
saved_data_meta_infoAn object containing saved chart content meta info.
load_last_chartA Boolean value showing whether the library should load the last saved chart for a user.

Specify the save_load_adapter parameter to save/load a chart using the API handlers.

Specify the settings_adapter parameter to save chart settings and set a watermark.

Trading Terminal Parameters

All Trading Terminal parameters are listed in the TradingTerminalWidgetOptions interface. Most of them duplicate the [Advanced Charts(#charting-library-parameters) parameters. Additional parameters are listed below:

ParameterDescription
broker_configConfiguration flags for Trading Terminal.
restConfigConnection configuration settings for the Broker API.
widgetbarSettings for the widget panel on the right side of the chart. You can enable Watchlist, News, Details and Data Window widgets on the right side of the chart using this property.
rss_news_feedUse this property to change the RSS feed for news.
news_providerUse this property to set your own news getter function.
trading_customizationOverrides orders and positions.