Getting started with D3
The D3 API can take some getting used to. The examples in this chapter will strive to illustrate some of the basic concepts as well as dive deeper as we move forward to show some of the best that D3 has to offer.
Before we can do any of that, you need to get D3 into your page. To do so, you can use npm
to install it into your project folder:
npm install d3
Once you've got it installed, you can link to the minified D3 source from your document using a script tag:
<script src="node_modules/d3/dist/d3.min.js"></script>
If you'd prefer not to use npm
, it's also available to be linked to from d3js.org directly:
<scriptsrc="https://d3js.org/d3.v5.js"></script>
Additionally, if you want a local copy, you can clone the project from GitHub ( https://github.com/d3/d3)), or download the project from d3js.org and then organize your files in any way you like.
Once you've got the project installed, you're ready to start to explore the D3 API.
The following example...