Chapter 5. Layouts – D3's Black Magic

Most of us look at the Internet for inspiration and code samples. You find something that looks great, you look at the code, and your eyes glaze over. It doesn't make any sense.

The usual culprit is D3's reliance on layouts for anything remotely complicated. The black magic of taking some data, calling a function, and—voilà—visualization! This elegance makes layouts look deceptively difficult, but they make things a lot easier when you get the hang of them.

In this chapter, we'll go in, guns blazing, with everything you've learned so far to create 11—count 'em! 11!—visualizations of the same dataset.

What are layouts and why should you care?

D3 layouts are modules that transform data into drawing rules. The simplest ...

Get D3.js: Cutting-edge Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.