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.

Explaining generators

Explaining generators - D3.js Tutorial

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

Start my 1-month free trial

Explaining generators

- [Presenter] So far we've created the path attribute manually starting with M and using L and x, y coordinates to move from point to point with five data points that's fine but with time serious data in particular we can easily have thousands of points. D3 offers us various generators, which create familiar sounding shapes and charts. For example, there is an area generator which turns data into a wiggly shape running left to right closed off with vertical lines and a horizontal line to the bottom. The area generator draws these extra lines for us automatically using path. We're going to start with the line generator. Create a new file and save it as interpolate.js and now you can close shapes.js. Now we need to update d3.html to reference our new JavaScript file. So to do that we just delete shapes and type in interpolate and save. So now we've got a nice blank file. We need to declare a variable data array to contain some data. So var dataArray = square brackets. Square brackets…

Contents