A widget can embed a trading chart inside its page. For example, the widget's HTML contains an iframe:
<body>
<iframe id="ChartContainer"></iframe>
</body>
The widget can then load a chart into the iframe as follows, using
Framework.CreateSubWidget({
domTarget: "ChartContainer", // Either the HTML element, or its id attribute
type: "chart",
context: {instrumentId: "GBP/USD", timeframe: 3600},
settings: { … }
});
Framework.CreateSubWidget({
domTarget: "ChartContainer", // Either the HTML element, or its id attribute
type: "chart",
context: {instrumentId: "GBP/USD", timeframe: 3600},
settings: { … }
}, function (MsgResponse) {
// 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}
});
});