3.9.8Modifying or moving a drawing

To modify a drawing, including moving it, you first need to capture its drawingId in the optional callback from ChartChange() when using create-drawing. You can then use change-drawing, passing in the drawingId and a revised drawing:{}definition.

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 modify the drawing by passing in the drawingId and a new drawing:{} definition. You can include all the same properties which you can use with create-drawing (apart, of course, from the type). You only need to include the values which you want to change. For example, you can change the drawing's points - move the drawing - without re-specifying the colours and other visual styles, or vice versa:

Framework.ChartChange({

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

command: "change-drawing",

drawingId: Framework.$myDrawingId,

drawing: {

// Properties to change.

// Can include any or all of the properties which are

// accepted by create-drawing (apart from the .type).

// For example, moving the drawing (while leaving properties such as

// the colour unchanged):

points: [

{date: 1777939200000, value: 1.171},

{date: 1777968000000, value: 1.173}

]

}

});