javascript - How do I get latest value for Cubism Metrics -


i'm trying log latest data metric (actually in reality update div) dummy code below 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 show me working code valueat function? same metric work way used elsewhere plot horizon graph.

i'm afraid this in on handler refers else.

use metric.valueat(<your index>) instead, 1079 (the last index of metric data array, 1080 size of it).


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -