Attempting to write a simple visualization using Cubism and D3. Admittedly, I'm fairly new to using Cubism and D3 and the Cubism documentation is very hard to understand.
Polling a URL for a numerical value to retrieve the 'rate' and then pushing the value onto an array like in the examples. The canvas stuff does not render and initially, neither does the numerical value as in the Cubism.js examples. After a while a number shows up reflecting the latest polled value. Debugging the JavaScript does show the array expanding with values over time.
Any help in understanding the problem better would be appreciated.
render: function() {
var thatElement = this.el;
function update(model) {
var values = [];
return context.metric(function(start, stop, step, callback) {
model.fetch();
var data = model.toJSON();
if (data[0]) values.push(parseInt(data[0]));
callback(null, values = values.slice(-context.size()));
}, "Rate");
}
var context = cubism.context()
.serverDelay(0)
.clientDelay(0)
.step(5000);
var foo = update(this.model);
d3.select(thatElement).append("div").call(function(div) {
div.append("div")
.attr("class", "axis")
.call(content.axis().orient("top"));
div.selectAll(".horizon")
.data([foo])
.enter().append("div")
.attr("class", "horizon")
.call(context.horizon());
div.append("div")
.attr("class", "rule")
.call(context.rule());
});
}
Additionally, noticing that if I call the cubism.context() stuff in other views, it breaks preceding views.