So my line extends from one side of my graph to the other, but it doesnt really animate through each data point, I assume I have to add a loop somewhere.
Heres the relevant code. Any assistance would be hugely appreciated!!!
Code:
//assign start coordinates for each piece of data
var startValueline = d3.svg.line()
.x(0)
.y(0);
//assigns coordinates for each piece of data
var valueline = d3.svg.line()
.interpolate("interpolation")
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.close); });
// csv callback function
d3.csv("myData2.csv", function(data) {
data.forEach(function(d) {
d.date = parseDate(d.date);
d.close = +d.close;});
//CLIKC FUNCTION WHICH SHOULD ANIMATE LINE
button.on("click", function() {
svg.append("path") // Add the valueline path.
.attr("class", "line")
.attr("d", startValueline(data)) // set starting position
.transition()
.duration(2000)
.ease("linear")
.attr("d", valueline(data)); // set end position;
});