Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learn D3.js
  • Table Of Contents Toc
Learn D3.js

Learn D3.js - Second Edition

By : Helder da Rocha
close
close
Learn D3.js

Learn D3.js

By: Helder da Rocha

Overview of this book

Learn D3.js, Second Edition, is a fully updated guide to building interactive, standards-compliant data visualizations for the web using D3.js v7 and modern JavaScript. Whether you're a developer, designer, data journalist, or analyst, this book will help you master the core techniques for transforming data into compelling, meaningful visuals. Starting with fundamentals like selections, data binding, and SVG, the book progressively covers scales, axes, animations, hierarchical data, and geographical maps. Each chapter includes short examples and a hands-on project with downloadable code you can run, modify, and use in your own work. This new edition introduces improved chapter structure, updated code samples using ES2019 standards, and better formatting for readability. Chapters were completely rewritten to focus on the most important topics first, with suggested exercises after each section, complete with commented solutions and online step-by-step tutorials. All code snippets are drawn from real-world D3 data visualization projects available in a GitHub repository, which also includes bonus content on integrating D3 into applications and migrating legacy code. With its practical approach, this book remains one of the most respected resources for learning D3.js and creating interactive data visualizations with JavaScript.
Table of Contents (27 chapters)
close
close
1
Part 1: Getting Started with D3
3
Chapter 2: Essential JavaScript for D3 (Online)
4
Chapter 3: Essential SVG for D3 (Online)
6
Part 2: Core D3
17
Part 3: Advanced D3

Exploring D3’s modules

Functions, methods, and properties of the D3 library are organized into modules. There are over 40 modules (Figure 1.10). When you import the d3.js library, you automatically load the 29 modules that make up the default bundle.

Figure 1.10 – Modules in D3.js v7 showing dependencies and inclusion in the default bundle

Figure 1.10 – Modules in D3.js v7 showing dependencies and inclusion in the default bundle

Modules that are not part of the default bundle need to be imported separately.

You don’t always need the full d3.js bundle. Any SVG can be created by importing just the d3-selection module separately. In the following code, for example, version 3 of this module is used to provide methods such as d3.append() and d3.select():

<script type="module">
    import * as d3 from "https://cdn.skypack.dev/d3-selection@3";
    d3.select("body").append("svg").append("circle")
      .attr("r",20).attr("x",50).attr("y",50);
</script>

Using separate modules, however, is not trivial. Omitting a required module, loading them in the wrong order, assigning prefixes incorrectly, or using incompatible versions can cause hard-to-find errors.

Most examples in this book import the entire d3.js bundle. This avoids configuration errors that may distract us from our primary goal, which is to learn how to use the D3 library efficiently. When modules that are not part of the default bundle are required, we will show you exactly how to import them correctly. See the Imports/ folder (in this chapter’s repository) for different ways to include the D3 library in a web application.

It’s still important to have a general overview of the modules provided by the D3 library, since the official documentation is organized per module. Most chapters in this book are also dedicated to specific modules. In the repository’s Appendix/ folder you will find a quick reference of D3’s modules in the Modules/ subfolder.

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learn D3.js
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon