This page shows the source for this entry, with WebCore formatting language tags and attributes highlighted.


Getting started with D3.js


<img attachment="d3example.png" align="right">The programmable notebook <a href="" source="MIT Visualization Group" author="Arvind Satyanarayan">Introduction to D3</a> is part of a <a href="">full course</a> at MIT about <i>Interactive Data Visualization</i>. The linked notebook uses <a href="">D3.js</a>, but previous classes in the course have dealt with <a href="'">Vega</a>, which is, <bq>[...] a visualization grammar, a declarative language for creating, saving, and sharing interactive visualization designs. With Vega, you can describe the visual appearance and interactive behavior of a visualization in a JSON format, and generate web-based views using Canvas or SVG.</bq> Vega is a higher-level abstraction than D3 and is, therefore, both more powerful and more limited than it. If what you want to build fits the higher-level building blocks of Vega (see <a href="">examples</a>), then you'll be done more quickly with that; if it doesn't, then D3.js offers more flexibility as it functions at finer granularity. <bq>[...] grammars [like Vega] break visualization design down into a process of specifying mappings (or visual encodings) between data fields and the properties of graphical objects called marks. They're useful for concisely and rapidly creating recognizable visualizations, while giving us more design flexibility (or expressivity) than chart typologies like Microsoft Excel. However, describing visualization design in these high-level terms limits the types of visualizations we can create. For example, we can only use the available marks, and can only bind data to supported encoding channels.</bq> With D3.js, you have to do a bit more legwork yourself, but it offers more graphical flexibility and possibilities. Instead of customizing the settings for predefined renderers (or "marks"), you define the renderers yourself: the notebook includes examples in HTML and SVG. To keep things simple, the SVG examples replicate the HTML examples, but they <i>could</i> render much more that is not so easy to realize in HTML. Although D3.js has a reputation as a "charting library", that moniker is actually more appropriate for Vega. D3.js is a generalized data-to-graphics mapping library. As you can see from the <a href="">examples</a>, it <i>is</i> very useful for charts, but allows a lot more customizability than <i>Vega</i>. Anyone building charts for their site should consider very carefully whether the additional power and complexity are warranted vs. a solution with something like Vega. That said, it was a lot of fun getting to know D3 with this notebook. The notebook is extremely well-written and organized and it's absolutely fantastic that it's available online, for free. I was able to understand and execute all of the exercises and feel like I have a good enough grasp of D3 now to be able to build something with it. Perhaps more importantly, I feel that I can now: <ol> Determine whether D3 or Vega are appropriate for a given project Estimate the amount of time required to build something with either of them </ol>