3.8.5.1Getting the ID of a chart dialog or embedded chart

Before modifying a chart, the creator must first obtain the ID of the chart, via the callback issued by CreateDialog() or CreateSubWidget(). This value later gets passed to ChartChange() as chartId: X.

CreateDialog() fires callbacks on both dialog creation and dialog closure. The first callback, on creation, provides a widgetId which identifies the chart. For example:

Framework.CreateDialog({

type: "chart",

}, function (MsgResponse) {

if (MsgResponse.widgetId) {

// Initial callback on creation

// MsgResponse.widgetId can be used to modify the chart,

// using ChartChange() with mode: "single" and chartId: <widgetId>

} else {

// Subsequent callback from dialog after creation

}

});

CreateSubWidget() fires a single callback when the embedded chart is created in the iframe:

Framework.CreateSubWidget({

type: "chart",

domTarget: document.getElementById("MyChartContainer"),

}, function (MsgResponse) {

// Initial callback on creation

// MsgResponse.widgetId can be used to modify the chart,

// using ChartChange() with mode: "single" and chartId: <widgetId>

});