Here for this animated line chart, we set first the SVG element in the DOM and we establish the width and the height of the graph (the value for the height is assigned in the following line).
Then we establish the "skeleton" of the visualisation by grouping the axes for the graph with a G element inside the SVG element. We start passing the values for styles and the functions that are going to draw the visualisation. The values will be defined below.
Here we also pass the data of the csv file that we are going to store in the variable data to draw the line and establish the axes.
With yAxis we do the same as with xAxis, but for the y-axis this time. For the y-axis we're also going to extend the domain scale of the values to 6000. We also set some elements for the style and the attributes for the g element.
The transition function will define the animation and will call the tweenDash function we define next to set the stroke-dasharray attribute to draw the line.
The tweenDash function will get the length of the path element in the SVG element in order to interpolate the values and draw the whole continuous line.
Here we call for all the D3 functions that we have been using such as the scaleTime, the scaleLinear, the tweenDash and the transition function to name a few.