Skip to Content
D3 for the Impatient
book

D3 for the Impatient

by Philipp K. Janert
May 2019
Intermediate to advanced
256 pages
6h 5m
English
O'Reilly Media, Inc.
Book available
Content preview from D3 for the Impatient

Chapter 3. The Heart of the Matter: Selecting and Binding

D3 is a JavaScript library for manipulating the DOM tree in order to represent information visually. This makes it different from other graphics or plotting libraries: a conventional graphics library operates on a “canvas” and places lines, circles, and other graphical objects directly onto this canvas. But because D3 uses the DOM tree to display information, it must provide capabilities to operate on the DOM tree—in addition to the customary management of shapes, coordinates, colors, and so on. Specifically, it must allow the user to:

  1. Specify where in the DOM tree a change should take place and which elements will be affected; the user must be able to select a node (or set of nodes).

  2. Associate individual records from the data set with specific elements or nodes in the DOM tree; enable the user to bind or join a data set to a selection of nodes.

  3. Change the size, position, and appearance of DOM elements according to the values of the data associated with them.

The first and last item in this list are common activities in contemporary web development, and users familiar with the jQuery library, for instance, should feel quite at home. (But if you are not familiar with jQuery and the particular style of programming popularized by it, D3 can seem very peculiar indeed!)

The second item, however, is different. The idea to establish a tight association between individual data records and individual DOM elements, so that ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

D3.js in Action, Second Edition

D3.js in Action, Second Edition

Elijah Meeks
D3.js in Action

D3.js in Action

Elijah Meeks

Publisher Resources

ISBN: 9781492046783Errata Page