O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

D3 for the Impatient

Book Description

If you’re in a hurry to learn D3.js, the leading JavaScript library for web-based graphics and visualization, this book is for you. Written for technically savvy readers with a background in programming or data science, the book moves quickly, emphasizing unifying concepts and patterns. Anticipating common difficulties, author Philipp K. Janert teaches you how to apply D3 to your own problems.

Assuming only a general programming background, but no previous experience with contemporary web development, this book explains supporting technologies such as SVG, HTML5, CSS, and the DOM as needed, making it a convenient one-stop resource for a technical audience.

  • Understand D3 selections, the library’s fundamental organizing principle
  • Learn how to create data-driven documents with data binding
  • Create animated graphs and interactive user interfaces
  • Draw figures with curves, shapes, and colors
  • Use the built-in facilities for heatmaps, tree graphs, and networks
  • Simplify your work by writing your own reusable components

Table of Contents

  1. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Online Learning
    4. How to Contact Us
    5. Acknowledgments
  2. 1. Introduction
    1. Whom This Book Is For
    2. Why D3?
    3. What Is in This Book
      1. … and What Is Not
    4. How to Read This Book
    5. Conventions
      1. Conventions of the D3 API
      2. Conventions for the API Reference Tables
      3. Conventions for the Code Examples
  3. 2. Let’s Make Some Graphs, Already!
    1. A First Example: A Single Data Set
    2. A Second Example: Two Data Sets
      1. Plotting Symbols and Lines
      2. Adding Graph Elements with Reusable Components
    3. A Third Example: Animating List Items
      1. Creating HTML Elements with D3
      2. Creating a Simple Animation
  4. 3. The Heart of the Matter: Selecting and Binding
    1. Selections
      1. Creating Selections
      2. Understanding Selections
    2. Binding Data
      1. Unmatched Items: The Enter and Exit Selections
      2. Joining on a Key
      3. The General Update Pattern
    3. Manipulating Selections
      1. Operating on Elements of a Selection
      2. Operating on Selections Themselves
    4. Shared Parent Information Among Selections with Groups
  5. 4. Events, Interactivity, and Animation
    1. Events
    2. Exploring Graphs with the Mouse
      1. Case Study: Simultaneous Highlighting
      2. The D3 Drag-and-Drop Behavior Component
      3. Notes on User Interface Programming
    3. Smooth Transitions
      1. Creating and Configuring Transitions
      2. Using Transitions
      3. Hints and Techniques
    4. Animation with Timer Events
      1. Example: Real-Time Animations
      2. Example: Smoothing Periodic Updates with Transitions
  6. 5. Generators, Components, Layouts: Drawing Curves and Shapes
    1. Generators, Components, and Layouts
    2. Symbols
      1. Using D3 Built-Ins
      2. Custom Symbols
      3. SVG Fragments as Symbols
    3. Lines and Curves
      1. Built-In Curves
      2. Custom Curves
    4. Circles, Arcs, and Pie Charts: Working with Layouts
    5. Other Shapes
    6. Writing Your Own Components
      1. A Simple Component
      2. Working with Components
      3. A Component to Save Keystrokes
      4. SVG Transformations as Components
  7. 6. Files, Fetches, Formats: Getting Data In and Out
    1. Fetching a File
      1. Examples
      2. Controlling Fetches with the RequestInit Object
    2. Parsing and Writing Tabular Data
      1. Field Value Conversions
      2. Parsing Input Containing Arbitrary Delimiters
      3. Generating Tabular Output
      4. Using Regular Expressions to Parse Whitespace-Separated Data
    3. Formatting Numbers
      1. Locales
      2. Formatters
      3. Format or Conversion Specifiers
  8. 7. Values to Visuals: Interpolations, Scales, and Axes
    1. Interpolation
      1. How Universal Interpolation Works
      2. Implementation Notes and Custom Interpolators
    2. Scales
      1. Continuous Scales: Numbers to Numbers
      2. Binning Scales: Numbers to Bins
      3. Discrete or Ordinal Scales: Keys to Sequence
    3. Axes
      1. The Constituents of an Axis
      2. Creating an Axis and Moving It into Position
      3. Customizing Tick Marks and Their Labels
    4. Examples
      1. Falling Long-Distance Costs: Linear and Logarithmic Scales
      2. Server Load: Time Series and Discrete Colors
  9. 8. Colors, Color Scales, and Heatmaps
    1. Colors and Color Space Conversions
    2. Color Schemes
      1. Cartographic Schemes
      2. False-Color Schemes
      3. Other Color Schemes
    3. Color Scales
      1. Discrete Colors
      2. Color Gradients
      3. Making a Color Box
    4. False-Color Graphs and Related Techniques
      1. Heatmaps
      2. Contour Lines
  10. 9. Trees and Networks
    1. Trees and Hierarchical Data Structures
      1. Preparing the Data
      2. Link and Node Diagrams for Trees
      3. Area Graphs for Containment Hierarchies
    2. Force-Based Particle Arrangements
      1. Simulation How-To
      2. Built-In Interactions
      3. Examples
  11. 10. Utilities: Arrays, Statistics, and Timestamps
    1. Structural Array Manipulations
    2. Descriptive Statistics for Numerical Arrays
      1. Histograms
    3. Working with Dates and Timestamps
      1. Parsing and Formatting Timestamps
  12. A. Setup, Tools, Resources
    1. Setup
    2. Tools
    3. Resources
      1. Books
      2. Websites, Example Collections, and Galleries
  13. B. An SVG Survival Kit
    1. Introduction
    2. General Overview
    3. Shapes
    4. Path
    5. Text
    6. Presentational Attributes
    7. Color
    8. Transformations
    9. Structural Elements and Document Organization
    10. Coordinates, Scaling, and Rendering
    11. SVG and CSS
    12. Resources
  14. C. Hitchhiker’s Guide to JavaScript and the DOM
    1. JavaScript
    2. The DOM
      1. Classes
      2. DOM Events
      3. Event Propagation
    3. The Browser as Development Environment
    4. Resources
      1. JavaScript
  15. Index