3.9.9Removing a drawing

To remove a drawing, you first need to capture its drawingId in the optional callback from ChartChange() when using create-drawing. You can then use remove-drawing, passing in the drawingId.

For example, creating a drawing and recording the drawingId:

// Create a drawing, storing the ID for future use (for example, in Framework.$myDrawingId)

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "create-drawing",

drawing: { … }

}, function (MsgResponse) {

if (MsgResponse.result.success) {

// Drawing added. Store the ID for later use:

Framework.$myDrawingId = MsgResponse.result.drawingId;

} else {

// Failed.

// Textual error message in MsgResponse.result.error

}

});

You can then later remove the drawing as follows:

Framework.ChartChange({

mode: "active", // or "all", or "single" plus a .chartId value

command: "remove-drawing",

drawingId: Framework.$myDrawingId

});

Note: it is almost always inefficient and undesirable to change a drawing by removing it and then re-creating it, rather than modifying the drawing.