I'm trying to log the latest data from a metric (actually in reality to update a div) but the dummy code below only ever logs out "undefined".
var context, cube, metric;
context = cubism.context().step("1e4").size(1080);
cube = context.cube(CUBE_SERVER);
metric = cube.metric("median(sar(value).eq(key,'ldavg_15').eq(host,'myserver'))");
metric.on("change", function(start, stop) {
console.log("changing");
if (typeof this.valueAt !== "undefined") {
console.log(this, this.valueAt(-1));
}
});
Can anyone show me some working code for the valueAt function? The same metric does work by the way as it is used elsewhere to plot a horizon graph.