So in d3 I want an array for functions such that
var data = [44,23];
var line = [];
for (var i = 0; i < data.length; i++) {
line[i] = d3.svg.line()
.interpolate("monotone")
.y(function(d) {
return data[i];
});
}
However, because of the way the closure works, the i is always evaluated to 2. Is there a way to make it evaluate as 0, then 1, instead of 2 always?