I am trying to create an animated line graph where the line draws out its path from left to right, as in the first scene of this example. I have been closely following the code for mbostock's example, but still am having a couple issues.
When I try to run my code, I get an error saying "'d' is undefined", in the attr method inside the draw function shown below:
var line = d3.svg.line()
.interpolate('linear')
.x(function(d,i) {return x(i);})
.y(function(d,i) {return y(d['measures'][i]);});
chart.append('path')
.attr('class','line')
.data(array);
function draw(k) {
chart.select('.line')
.attr('d',function(d) { return line(d.measures.slice(0,k+1));});
}
var k=1, n = array.measures.length;
d3.timer( function() {
draw(k);
if((k+=2) >= n-1) {
draw(n-1);
//next transitions
return true;
}
This leads me to believe that my data has not been correctly bound to the path. However, I can't seem to understand why it would not be binding correctly
Any help would be much appreciated!