From the course: D3.js Essential Training for Data Scientists

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Drawing a line chart from CSV data

Drawing a line chart from CSV data - D3.js Tutorial

From the course: D3.js Essential Training for Data Scientists

Start my 1-month free trial

Drawing a line chart from CSV data

- [Instructor] Now, that our data are shipshape, let's set about using them to draw a line chart. Now, one thing we need to do quickly, so that we can see the resulting chart, is just add some style declarations here for path. So, we've got stroke of green and we'll give it a stroke-width there of two. We can arrange our get data on multiple lines here, as long as it's within these curly brackets. In this section, we're going to put together all the things that we saw in the last chapter. So, we're going to start by defining height of 300 and a width of 500. The next thing we need is some max and min of the data that we have. And we need this for the scales. And the scales are going to be used to draw the chart and to draw the axes. So, we'll declare var max, which we're going to use to return the maximum price data. So, it's d3.max(). The data is held in an array called data. And then again, we're using this optional function parameter to tell d3 precisely which data point we want…

Contents