Not long ago D3js came on my radar as a library I needed to look into. At first I dismissed it as ‘just another jQuery wannabe’. There is some overlap, but having played with it a little, I’m coming to think of D3 more as jQuery’s nerdy cousin.
I still have some learning to do, but my first foray into it is a quick census data visualization. Truth be told, I janked one of the examples and tweaked it to allow choosing any census measure, adjust the colors, automatically determine the scale, and fade between color changes.
The result is pretty astounding. With just a few lines of code, we grab some CSV census data and county map vectors, do the math to map the census value to a color, and draw it on the page.
The ajax and selection are nice, but technically are things jQuery already does pretty well. Similarly, D3’s databinding model is powerful, but not enough to convince me to pick it over Knockout. What D3 brings that is fairly unique are a slew of useful math, array, and scaling functions. For example, this would be much more complex without D3:
As would this:
Perusing the examples, there’s still a fair amount to learn about this library, but I think it’s safe to say I’ll be putting it in the toolbox alongside jQuery and Knockout.