Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Data Visualization with D3 and AngularJS

You're reading from  Data Visualization with D3 and AngularJS

Product type Book
Published in Apr 2015
Publisher
ISBN-13 9781784398484
Pages 278 pages
Edition 1st Edition
Languages
Authors (2):
Erik Hanchett Erik Hanchett
Profile icon Erik Hanchett
Christoph Körner Christoph Körner
Profile icon Christoph Körner
View More author details

Table of Contents (16) Chapters

Data Visualization with D3 and AngularJS
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. The Magic of SVG, D3.js, and AngularJS 2. Getting Started with D3.js 3. Manipulating Data 4. Building a Chart Directive 5. Loading and Parsing Data 6. Drawing Curves and Shapes 7. Controlling Transitions and Animations 8. Bringing the Chart to Life with Interactions 9. Building a Real-time Visualization to Monitor Server Logs Index

Binding data to DOM elements


Data binding techniques are very powerful in D3.js because they enable us to generate graphical content based on data. In general, with the data-driven approach, we can declare the graphical elements to match the data instead of looping through the data and drawing the elements one by one.

selection.data(values[, key])

D3-Selections provide the .data([values[, key]]) method to bind an array of arbitrary data to a Selection. It will return a new Selection that stores the bound data internally and binds every element of the data array to an element of the Selection.

The first values argument is an array of values or a function that returns an array of values. With the second optional key argument, we can specify a function that identifies each element of the array. The key argument is important for D3.js to identify and keep track of the elements for the data joins. Let's first take a look at a simple example:

<svg width="400" height="200">
  <circle cx="50...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}