newRadarWidget
newRadarWidget
is a constructor function for creating the Radar widget.
Widget Constructor
Call newRadarWidget
to create a widget instance inside a browser DOM
element.
import { newRadarWidget } from '@dxfeed-widgets/radar'
const domNode = document.getElementById('widget-container')
const dataProviders = {
ipfPath: '/your-path/ipf',
ipfAuthHeader: 'your-header',
scannerPath: '/api/scanner',
scannerAuthHeader: 'your-header',
schedulePath: '/api/schedule'
}
const widget = newRadarWidget({
element: domNode,
providers: dataProviders,
})
Signature
newRadarWidget(props: WidgetConstructorProps): WidgetAPI
Returns
An WidgetAPI object.
WidgetConstructorProps
Name | Type | Description |
---|---|---|
element | HTMLElement | A DOM element where the widget should be attached. |
providers | Providers | An object with configuration for data providers. Refer to the Data Providers section for details |
config optional | Config | Initial configuration of the widget |
state optional | State | Initial state of the widget |
theme optional | ThemeName | Theme | Initial theme of the widget. Refer to the Styling section for details |
Widget API
getConfig
Gets the current widget config.
Signature
getConfig(): Config
Returns
setConfig
Sets widget config.
Signature
setConfig(config: Config): void
Parameters
Name | Type | Description |
---|---|---|
config | Config | Configuration object. Omitted or undefined properties will be set to default |
getState
Gets the current widget state.
Signature
getState(): State
Returns
updateState
Updates widget state.
Signature
updateState(state: Partial<State>): void
Parameters
Name | Type | Description |
---|---|---|
state | Partial<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
Name | Type | Description |
---|---|---|
stateChangeCallback | (state: State) => void | Function that will be called whenever the state is changed. |
Or
Name | Type | Description |
---|---|---|
field | keyof State | The state field to listen for. |
fieldChangeCallback | (value: State[keyof State]) => void | Function 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
Name | Type | Description |
---|---|---|
stateChangeCallback | (state: State) => void | Listener that will be removed. |
Or
Name | Type | Description |
---|---|---|
field | keyof State | The state field for which to remove a listener. |
fieldChangeCallback | (value: State[keyof State]) => void | Listener that will be removed. |
getData
Gets the current widget data.
Signature
getData(): Data
Returns
addDataListener
Sets up a function that will be called whenever the data or specified field is changed.
Signature
addDataListener(dataChangeCallback: (data: Data) => void): void
addDataListener(field: keyof Data, fieldChangeCallback: (field: Data[keyof Data]) => void): void
Parameters
Name | Type | Description |
---|---|---|
dataChangeCallback | (data: Data) => void | Function that will be called whenever the data is changed. |
Or
Name | Type | Description |
---|---|---|
field | keyof Data | The data field to listen for. |
fieldChangeCallback | (value: Data[keyof Data]) => void | Function that will be called whenever the specified field is changed. |
removeDataListener
Removes an data listener previously registered with addDataListener
Signature
removeDataListener(dataChangeCallback: (data: Data) => void): void
removeDataListener(field: keyof Data, fieldChangeCallback: (field: Data[keyof Data]) => void): void
Parameters
Name | Type | Description |
---|---|---|
dataChangeCallback | (data: Data) => void | Listener that will be removed. |
Or
Name | Type | Description |
---|---|---|
field | keyof Data | The data field for which to remove a listener. |
fieldChangeCallback | (value: Data[keyof Data]) => void | Listener 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
Name | Type | Description |
---|---|---|
slot | Slot | The place where a provided element is inserted. |
element | HTMLElement | An 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 an information about the endpoints required by the widget, such as the path to the endpoint and the authorization key.
interface RadarWidgetDataProviders {
ipfPath: string
ipfAuthHeader: string
scannerPath: string
scannerAuthHeader: string
schedulePath: string
}
Properties
Name | Type | Description |
---|---|---|
ipfPath | string | A string containing the path to the endpoint. |
ipfAuthHeader | string | A string containing the authentication header for the endpoint. |
scannerPath | string | A string containing the path to the endpoint. |
scannerAuthHeader | string | A string containing the authentication header for the endpoint. |
schedulePath | string | A string containing the path to the endpoint. |
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 RadarWidgetConfig {
columnSelectMenuEnabled?: boolean,
resizable?: boolean,
reorderable?: boolean,
dataExportEnabled?: boolean,
radarMenuEnabled?: boolean,
refreshButtonEnabled?: boolean,
candlePeriodSelectorViewMode?: ToolbarSelectorViewMode,
delayNotificationEnabled?: boolean,
symbolScheduleStatusEnabled?: boolean,
locale?: LocaleSettings,
}
Properties
Name | Type | Default | Description |
---|---|---|---|
columnSelectMenuEnabled Optional | boolean | true | A flag that controls the column select menu feature visibility. |
resizable Optional | boolean | true | A flag that controls the column resizable feature. |
reorderable Optional | boolean | true | A flag that controls the column reorder feature. |
dataExportEnabled Optional | boolean | true | A flag that controls a visibility of an export button. |
radarMenuEnabled Optional | boolean | true | A flag that controls the radar menu button visibility in the toolbar. |
refreshButtonEnabled Optional | boolean | true | A flag that controls the refresh button visibility in the toolbar. |
candlePeriodSelectorViewMode Optional | ToolbarSelectorViewMode | 'available' | view mode of the order select in the toolbar. |
delayNotificationEnabled Optional | boolean | false | A flag that controls a visibility of an data delay notification. |
symbolScheduleStatusEnabled Optional | boolean | false | A flag that controls a visibility of symbol schedule status in symbol column in table |
locale Optional | LocaleSettings | { language: 'en', dateLocale: '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 RadarWidgetState {
columns: string[],
columnSizes: Record<string, number>,
filters: RadarFilters,
sort: RadarSort,
candlePeriod: CandlePeriod,
selectedSymbol?: string,
}
Properties
Name | Type | Default | Description |
---|---|---|---|
columns | string[] | [ symbol, symbolDescription, marketCap, lastPrice, changePercent, change, volume, priceEarningsRatio, morningstarSectorCode ] | A list of column identifiers that are added to the table. The columns are displayed in the order specified by the array. |
columnSizes | Record<string, number> | {} | An object that specifies column sizes where key is a column identificator and value is a column width in pixels. If the object does not contain a column width, then default width is used. |
filters | RadarFilters | {} | An object that defines enabled filters and their parameters. |
sort | RadarSort | { columnId: 'marketCap', direction: 'desc' } | An object that defines table sort. |
candlePeriod | CandlePeriod | '1d' | A string value defining candle period used in some columns. |
selectedSymbol Optional | string | undefined | A string containing the symbol selected in the table. |
Data
Data is an object that represents the readonly data of the widget.
Type
interface RadarWidgetData {
symbols: string[],
}
Properties
Name | Type | Default | Description |
---|---|---|---|
symbols | string[] | [] | Instruments |
Type Reference
CandlePeriod
Type
'1m' | '2m ' | '3m ' | '4m' | '5m' | '10m' | '15m' | '30m' | '1h' | '2h ' | '4h ' | '1d' | '1w' | '1mo' | '1y'