3.9.7Adding a drawing to a chart

You can use ChartChange() to add a drawing to a chart. The create-drawing command must contain a drawing:{} definition which describes the object to add. For example:

Framework.ChartChange({

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

command: "create-drawing",

drawing: {

type: "lineSegment",

points: [

{date: 1778025600000, value: 1.170},

{date: 1778054400000, value: 1.175}

],

style: {line: {color: "red"}}

}

});

The optional callback from create-drawing contains a drawingId which can then be used to modify/move the drawing, or remove it. For example:

Framework.ChartChange({

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

command: "create-drawing",

drawing: { … }

}, function (MsgResponse) {

if (MsgResponse.result.success) {

// Drawing added.

// ID of new drawing is in MsgResponse.result.drawingId

} else {

// Failed.

// Textual error message in MsgResponse.result.error

}

});