Getting started with D3.js
First, download the latest version of D3 from the official website http://d3js.org/.
Or, to link directly to the latest release, copy this snippet:
<script src="http://d3js.org/d3.v3.min.js"></script>
In the basic examples, we can just open our HTML document in a web browser to view it. But when we need to load external data sources, we need to publish the folder on a web server such as Apache, nginx, or IIS. Python provides us with an easy way to run a web server with http.server
; we just need to open the folder where our D3 files are present and execute the following command in the terminal.
$ python3 –m http.server 8000
In Windows, you can use the same command by removing the number 3 from python.
> python –m http.server 8000
The following examples are based on Mike Bostock's reference gallery, which can be found at https://github.com/mbostock/d3/wiki/Gallery.
All the codes and datasets of this chapter can be found in the author's GitHub repository...