3.8.1Displaying a chart as a dialog

A widget, script, or UDIX can display a chart as a dialog. For example:

Framework.CreateDialog({

type: "chart",

context: {instrumentId: "GBP/USD", timeframe: 3600},

settings: { … }

});

The chart can also be displayed as a floating window; a "modeless" dialog which stays open while the user continues to carry out actions in other parts of the platform:

Framework.CreateDialog({

type: "chart",

disposition: "floating", // Optional. Changes from a modal dialog to a floating window.

context: {instrumentId: "GBP/USD", timeframe: 3600},

settings: { … }

});

CreateDialog() fires callbacks on dialog creation and dialog closure. The initial callback, on creation, provides a widgetId which can subsequently be used to interact with the chart, using ChartChange(). For example:

Framework.CreateDialog({

type: "chart",

}, function (MsgResponse) {

if (MsgResponse.widgetId) {

// Initial response, on dialog creation.

// MsgResponse.widgetId contains the ID which can be used in

// calls to ChartChange(). For example, use ChartChange() to add

// 20-bar EMA to the chart:

Framework.ChartChange({

mode: "single",

chartId: MsgResponse.widgetId,

command: "load-indicator",

indicator: "EMA",

indicatorSettings: {period: 20}

});

} else {

// Subsequent dialog update, such as closure

}

});