3.9.11Adding an event marker to a chart

You can use ChartChange() to add an event marker to a chart. Event markers are created against specific date/times, and drawn at the bottom of the chart. They are automatically stacked if there is more than one marker for each bar.

(Event markers are intended for things such as calendar events, which apply to a bar as a whole. To draw a marker against both a date/time and also a specific price, use a barMarker drawing.)

The create-event-marker command must contain a marker:{} definition which describes the object to add. For example:

// Draw a marker against a date

Framework.ChartChange({

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

command: "create-event-marker",

marker: {

date: 1778072400000,

icon: "f00d", // Font Awesome cross glyph (0xF00D)

color: "red"

}

});

The optional callback from create-event-marker contains a markerId which can then be used to remove the marker. For example:

Framework.ChartChange({

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

command: "create-event-marker",

marker: { … }

}, function (MsgResponse) {

if (MsgResponse.result.success) {

// Event marker added.

// ID of new marker is in MsgResponse.result.markerId

} else {

// Failed.

// Textual error message in MsgResponse.result.error

}

});