We have acquired our toolbox and reviewed the basics of SVG. It is now time to explore D3.js. D3 is the evolution of the Protovis (http://mbostock.github.io/protovis/) library. If you have already delved into data visualization have been interested in making charts for your web application, you might have already used this library. Additional libraries also exist that can be differentiated by how quickly they rendered graphics and their compatibility with different browsers. For example, Internet Explorer did not support SVG but used its own implementation, VML. This made the Raphaël.js library an excellent option because it automatically mapped to either VML or SVG. On the other hand, jqPlot was easy to use, and its simplistic jQuery plugin interface allowed developers to adopt it very quickly.
However, Protovis had something different. Given the vector nature of the library, it allowed you to illustrate different kinds of visualizations, as well as generate fluid transitions. Please feel free to look at the links provided and see for yourself. Examine the force-directed layout at: http://mbostock.github.io/protovis/ex/force.html. In 2010, these were interesting and compelling visualizations, especially for the browser.
Inspired by Protovis, a team at Stanford University (consisting of Jeff Heer, Mike Bostock, and Vadim Ogievetsky) began to focus on D3. D3, and its application to SVG, gave developers an easy way to bind their visualizations to data and add interactivity.
There is a wealth of information available for researching D3. A great resource for complete coverage can be found on the D3 website at: https://github.com/mbostock/d3/wiki. In this chapter, we will introduce the following concepts that will be used throughout this book:
- Creating basic SVG elements
- The enter() function
- The update function
- The exit() function
- AJAX