A template to get started working on a D3 powered visualization project. This is based around doing all of the work locally (i.e., no CDN calls).
There are many ways to structure JS projects. Here's what this project tries to stick to:
- The visualization code itself will be stored in
app.js
. - All of the included JS files are local, and linked without version numbers (RequireJS style).
- The structure and JS library includes are as simple as possible (using script tags instead of RequireJS, not relying on any build tools).
To create a new project with this template, navigate to the directory that you want the project in and run:
cookiecutter https://github.com/andyreagan/cookiecutter-d3
Note: if you don't have cookiecutter
installed, get it via pip: pip install cookiecutter
(subnote: you may need sudo to use pip
, depending on your local python setup).
Start by launching the webserver with python -m SimpleHTTPServer
, and point your browser to http://localhost:8000/.
Take note of which port your python server launched on, it might not be 8000 (replace in the URL as needed).
If you're hip and running python3
, that would be python3 -m http.server
.
Or if you have node
installed, their http-server
is more stable under many requests in my experience (but generally, not necessary).
A few steps (using Homebrew) to get a server that way:
brew install npm
npm install -g http-server