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.

Creating a linear scale

Creating a linear scale - D3.js Tutorial

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

Start my 1-month free trial

Creating a linear scale

- [Instructor] We're going to create some axes on our area chart. This is going to take the following two sections. So this section is how to make the scale for the axis that we will add in the next section. So, we can close the Interpolate file and redirect our HTML file to area.js which we can now re-open. And we're all set to start. D3 scales can be continuous, ordinal, quantized or sequential. We want the most common type of continuous scale which is a numeric linear scale. So let's just check that we've got an area chart showing. And there, we have. Let's do the y-axis first. After the data and after the height and width, but before the area generator, we're going to enter var y = d3.scaleLinear().domain().range():. And that is the structure that scales always take. You declare the type of scale you want and then take a domain as an input and a range as an output. And you can write it all in one line like this, but I think it's gonna be easier when we start filling those out if…

Contents