D3 in Depth covers versions 6 and 7 of D3

Home About

Getting Started

Getting started with D3.js. This article assumes familiarity with HTML, SVG, CSS and JavaScript.

D3 in Depth assumes you're familiar with HTML, SVG, CSS and JavaScript. If not, I recommend reading Fundamentals of HTML, SVG, CSS and JavaScript for Data Visualisation.

If you're familiar with libraries such as React and Vue.js (or even jQuery) you should be fine.

CodePen examples

D3 in Depth uses CodePen to demonstrate code. Here's an example:

Click the 'Edit in CodePen' button to open the example in CodePen.

Each example consists of three or more files:

  • index.html
  • index.js
  • style.css

index.html usually looks similar to:

<svg width="760" height="140">
<g transform="translate(70, 70)">
</g>
</svg>

index.js contains the JavaScript code and style.css contains CSS code.

Developing with bundlers

If you're using a bundler such as Vite or Webpack import D3 modules using code similar to:

import { select } from 'd3-selection';

Note the Codepen examples use Skypack so the equivalent import is:

import { select } from 'https://esm.sh/d3-selection';
BOOKS & COURSES
D3 Start to Finish book cover

Visualising Data with JavaScript teaches you how to build charts, dashboards and data stories using Chart.js, Leaflet, D3 and React.

Find out more

"One of the best D3 books I've read. The contents are very clear, it is easy to follow and the concepts are very solid."

Javier García Fernández

Learn how to make a custom data visualisation using D3.js.

Find out more

Learn the fundamentals of HTML, SVG, CSS and JavaScript for building data visualisations on the web.

Find out more