The following lab exercise is designed to introduce you to making interactive data visualizations in D3.
For both of these exercises you will need to run a python local server. You will then be able to view the progress you make in the exercise, in your browser.
- Download the code from this repository.
- In the command line, navigate to the folder that contains this repository.
- Depending on which exercise you are working on, navigate to either the Basic or the Advanced Exercise folder.
cd D3BasicExercise
- Type the command below for whichever version of Python you are running to start a local server:
python -m SimpleHTTPServer (for Python 2) python -m http.server (for Python 3)
- Once you have the server up and running, in your browser, go to the link
0.0.0.0:8000/
to view your code in action. - By default the server serves the
index.html
in your folder to the browser. You can open other files from the same folder in the browser by appending the file name to the default address. For e.g.0.0.0.0:8000/solutions.html
to open thesolutions.html
file from the same folder.
Once your server is up, start with the exercises in app.js
. Don't forget to use your browser developer tools for debugging!
Note : After making changes to your file, if they do not reflect on your browser: do a hard refresh with Shift+click on the refresh button.
- Open the
index.html
andapp.js
files and follow along with the comments inapp.js
to add the missing code and get the visualization working. - As you go through, try to figure out what is going on with the code. Ask the TAs if you need help.
- When you are done (or if you are really stuck!) look at the
app_solution.js
file. - If you get the basic visualization working, you can make your own modifications (add animations and interactivity, change colors, etc.) or move on to the advanced exercise below.
If you already have some experience in D3 or have completed the beginner exercise. Try your hand at this more advanced exercise. The original idea is from a Spring 2015 assignment by David Eicke. However, it has not been updated to use D3 v4, so... anyone who contributes that update will be appreciated.
- Read through David's code (original.html) and look at the visualization in your browser to get a sense of what is going on in the code.
- Implement this code using the billboardtop5.csv data.
- Make any necessary changes to the size of the rectangles.
- Make any other modifications you like to the animation, colors, etc.