Skip to main content

newAdvancedChartWidget

newAdvancedChartWidget is a constructor function for creating the Advanced Chart widget.

Widget Constructor​

Call newAdvancedChartWidget to create a widget instance inside a browser DOM element.

import { newAdvancedChartWidget } from '@dx-display/widgets-advanced-chart'

const domNode = document.getElementById('widget-container')
const dataProviders = {
ipfPath: '/your-path/ipf',
ipfAuthHeader: 'your-header',
feedPath: 'wss://your-path/feed',
feedAuthHeader: 'your-header',
schedulePath: '/api/schedule'
}
const widget = newAdvancedChartWidget({
element: domNode,
providers: dataProviders,
})

Signature​

newAdvancedChartWidget(props: WidgetConstructorProps): WidgetAPI

Returns​

An WidgetAPI object.

WidgetConstructorProps​

NameTypeDescription
elementHTMLElementA DOM element where the widget should be attached.
providersProvidersAn object with configuration for data providers. Refer to the Data Providers section for details
config optionalConfigInitial configuration of the widget
state optionalStateInitial state of the widget
theme optionalThemeName | ThemeInitial theme of the widget. Refer to the Styling section for details

Widget API​

getConfig​

Gets the current widget config.

Signature​

getConfig(): Config

Returns​

Config


setConfig​

Sets widget config.

Signature​

setConfig(config: Config): void

Parameters​

NameTypeDescription
configConfigConfiguration object. Omitted or undefined properties will be set to default

getState​

Gets the current widget state.

Signature​

getState(): State

Returns​

State


updateState​

Updates widget state.

Signature​

updateState(state: Partial<State>): void

Parameters​

NameTypeDescription
statePartial<State>State object. Merges with the previous state object.

addStateListener​

Sets up a function that will be called whenever the state or specified field is changed.

Signature​

addStateListener(stateChangeCallback: (state: State) => void): void
addStateListener(field: keyof State, fieldChangeCallback: (field: State[keyof State]) => void): void

Parameters​

NameTypeDescription
stateChangeCallback(state: State) => voidFunction that will be called whenever the state is changed.

Or

NameTypeDescription
fieldkeyof StateThe state field to listen for.
fieldChangeCallback(value: State[keyof State]) => voidFunction that will be called whenever the specified field is changed.

removeStateListener​

Removes an state listener previously registered with addStateListener

Signature​

removeStateListener(stateChangeCallback: (state: State) => void): void
removeStateListener(field: keyof State, fieldChangeCallback: (field: State[keyof State]) => void): void

Parameters​

NameTypeDescription
stateChangeCallback(state: State) => voidListener that will be removed.

Or

NameTypeDescription
fieldkeyof StateThe state field for which to remove a listener.
fieldChangeCallback(value: State[keyof State]) => voidListener that will be removed.

setSlot​

Inserts custom markup into widget UI. Refer to the Extend widget UI section for details.

Signature​

setSlot(slot: Slot, element: HTMLElement): void

Parameters​

NameTypeDescription
slotSlotThe place where a provided element is inserted.
elementHTMLElementAn element that is inserted.

setTheme​

Sets widget theme.

Signature​

setTheme(theme: Theme | ThemeName): void

unmount​

Destroys the widget.

Signature​

unmount(): void

Data Providers​

The Data Providers object supplies the necessary information for connecting to data sources. This can either be:

  • Configuration details such as endpoint paths and authorization keys for seamless integration with dxFeed services.
  • A custom implementation of the required interface to connect the widget to your own data provider.
type AdvancedChartWidgetDataProviders = AdvancedChartProvidersConfig | AdvancedChartServices

AdvancedChartProvidersConfig​

The AdvancedChartProvidersConfig object supplies an information about the endpoints required by the widget, such as the path to the endpoint and the authorization key.

interface AdvancedChartProvidersConfig {
ipfPath: string
ipfAuthHeader: string
feedPath: string
feedAuthHeader: string
schedulePath: string
}

Properties​

NameTypeDescription
ipfPathstringA string containing the path to the endpoint.
ipfAuthHeaderstringA string containing the authentication header for the endpoint.
feedPathstringA string containing the path to the endpoint.
feedAuthHeaderstringA string containing the authentication header for the endpoint.
schedulePathstringA string containing the path to the endpoint.

AdvancedChartServices​

The AdvancedChartServices object defines a set of methods used by the chart at runtime to fetch and manage the required data. It implements the following interface:

interface AdvancedChartServices {
dataService: AdvancedChartDataService
}

The dataService is responsible for handling key data operations. You can read details about implementing AdvancedChartServices in dedicated page.

Configuration​

Configuration is an object that defines the basic behavior of a widget and allows enabling or disabling widget features that cannot be configured within the widget's user interface.

Type​

interface AdvancedChartWidgetConfig {
  toolbarDrawingsEnabled?: boolean,
  sidebarDrawingsEnabled?: boolean,
  timeframeEnabled?: boolean,
  timeframeEditEnabled?: boolean,
  timezoneEnabled?: boolean,
  availableAggregationPeriods?: AggregationPeriod[],
  availableChartTypes?: ChartType[],
  availablePriceLabels?: PriceLabel[],
  comparisonChartsEnabled?: boolean,
  indicatorSettingsEnabled?: boolean,
  indicatorTemplatesEnabled?: boolean,
  layoutEnabled?: boolean,
  layersEnabled?: boolean,
  availableSnapshotOptions?: SnapshotOption[],
  periodsEditEnabled?: boolean,
  availableContextMenus?: ContextMenu[],
  availableSettingsTabs?: TabIdentifier[],
  availablePriceTypes?: PriceType[],
  dataExportEnabled?: boolean,
  toolbarEnabled?: boolean,
  symbolSuggestEnabled?: boolean,
  maxDrawingsAmount?: number,
  maxStudiesAmount?: number,
  delayNotificationEnabled?: boolean,
  locale?: LocaleSettings,
}

Properties​

NameTypeDefaultDescription
toolbarDrawingsEnabled
Optional
boolean
true
A flag that controls a visibility of a drawing menu in the toolbar.
sidebarDrawingsEnabled
Optional
boolean
true
A flag that controls a visibility of a drawing menu in the sidebar.
timeframeEnabled
Optional
boolean
true
A flag that controls a visibility of a timeframe menu
timeframeEditEnabled
Optional
boolean
true
A flag that controls a visibility of a timeframe editor button.
timezoneEnabled
Optional
boolean
true
A flag that controls a visibility of a timezone menu.
availableAggregationPeriods
Optional
AggregationPeriod[]
[
 {duration: 2, durationType: 't'},
 {duration: 144, durationType: 't'},
 {duration: 1, durationType: 'm'},
 {duration: 5, durationType: 'm'},
 {duration: 15, durationType: 'm'},
 {duration: 30, durationType: 'm'},
 {duration: 1, durationType: 'h'},
 {duration: 2, durationType: 'h'},
 {duration: 4, durationType: 'h'},
 {duration: 1, durationType: 'd'},
 {duration: 1, durationType: 'w'},
 {duration: 1, durationType: 'mo'},
 {duration: 1, durationType: 'y'},
 {duration: 1, durationType: 'r'} 
]
A list of available aggregation periods.
availableChartTypes
Optional
ChartType[]
[
 'area',
 'line',
 'candle',
 'bar',
 'equivolume',
 'heikinAshi',
 'scatterPlot',
 'hollow',
 'histogram',
 'baseline',
 'trend'
]
A list of available chart types.
availablePriceLabels
Optional
PriceLabel[]
[
 'bidAsk',
 'prevDayClose',
 'prePostMarket'
]
A list of available price labels in addition to symbol and indicator.
comparisonChartsEnabled
Optional
boolean
true
A flag that controls a visibility of a compare charts button.
indicatorSettingsEnabled
Optional
boolean
true
A flag that controls a visibility of an indicator settings button.
indicatorTemplatesEnabled
Optional
boolean
true
A flag that controls a visibility of a indicator templates button.
layoutEnabled
Optional
boolean
true
A flag that controls a visibility of a layout settings button.
layersEnabled
Optional
boolean
true
A flag that controls a visibility of a layers settings button.
availableSnapshotOptions
Optional
SnapshotOption[]
[
 'downloadImage'
]
A list of available snapshots.
periodsEditEnabled
Optional
boolean
true
A flag that controls a visibility of a custom period input.
availableContextMenus
Optional
ContextMenu[]
[
 'yAxisMenu',
 'backgroundMenu',
 'studiesMenu',
 'drawingsMenu',
 'legendMenu',
 'dataMenu' 
]
A list of available context menus.
availableSettingsTabs
Optional
TabIdentifier[]
[
 'ChartGeneralTab',
 'ChartTradingTab',
 'ChartLegendTab',
 'ChartScalesTab',
 'ChartMarketTab',
 'ChartColorsTab',
 'ChartPaddingsTab' 
]
A list of available settings tabs.
availablePriceTypes
Optional
PriceType[]
[
 'mark',
 'bid',
 'ask',
 'last' 
]
A list of available price types.
dataExportEnabled
Optional
boolean
true
A flag that controls a visibility of an export button.
toolbarEnabled
Optional
boolean
true
A flag that controls a visibility of a toolbar.
symbolSuggestEnabled
Optional
boolean
true
A flag that controls a visibility of selected symbol input.
maxDrawingsAmount
Optional
number
9007199254740991
Maximum amount of drawings.
maxStudiesAmount
Optional
number
5
Maximum amount of studies.
delayNotificationEnabled
Optional
boolean
false
A flag that controls a visibility of an data delay notification.
locale
Optional
LocaleSettings
{
  language: 'en',
  dateLocale: 'en-GB',
  numberLocale: 'en-GB'
}
An object that defines the language and regional settings of the widget.

State​

State is an object that represents the state of the widget.

Type​

interface AdvancedChartWidgetState {
  symbol?: string,
}

Properties​

NameTypeDefaultDescription
symbol
Optional
string
undefined
A string containing the symbol by which the widget will display data.

Type Reference​

Slot​

Type​

'header'

AggregationPeriod​

Type​

{
  duration: string,
  durationType: AggregationPeriodDurationType,
}

AggregationPeriodDurationType​

Type​

't' | 'r' | 's' | 'm' | 'h' | 'd' | 'w' | 'mo' | 'y' | 'v'

ChartType​

Type​

'area' | 'line' | 'candle' | 'bar' | 'equivolume' | 'heikinAshi' | 'scatterPlot' | 'hollow' | 'histogram' | 'baseline' | 'trend'

PriceLabel​

Type​

'bidAsk' | 'prevDayClose' | 'prePostMarket'

SnapshotOption​

Type​

'downloadImage'

ContextMenu​

Type​

'yAxisMenu' | 'backgroundMenu' | 'studiesMenu' | 'drawingsMenu' | 'legendMenu' | 'dataMenu'

TabIdentifier​

Type​

'ChartGeneralTab' | 'ChartTradingTab' | 'ChartLegendTab' | 'ChartScalesTab' | 'ChartMarketTab' | 'ChartColorsTab' | 'ChartPaddingsTab'

PriceType​

Type​

'mark' | 'bid' | 'ask' | 'last'

MaxChartsAmount​

Type​

1 | 2 | 3 | 4 | 8

LocaleSettings​

An object that defines the language and regional settings of the widget.

Type​

{
  language: Language,
  dateLocale: string,
  numberLocale: string,
}

Language​

Type​

'en' | 'de' | 'ar'