Adding a link to the D3 library

The first thing we want to do is create a basic index.html file:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
    </body>
</html>

Now add a link to D3 at the bottom of your <body> tag in index.html. We'll put it at the bottom so that the script loads after all your other HTML elements have loaded into the browser:

<body>    
    <script src="https://d3js.org/d3.v5.min.js"></script>
</body>

Now create app.js in the same folder as your index.html. In it, we will store all of our JS code. For now, just put this code in it to see whether it works:

console.log('this works');
console.log(d3);

Link to it in index.html at the bottom of the <body> tag. Make sure it comes after the D3 script ...

Get D3.js Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.