Skip to content
BENIBIX Learn

D3.js

Design📊 Data VisualizationVisualization Software

Also known as D3, Data-Driven Documents, D3 JavaScript Library

A free code tool for the web. You use it to build any chart you want.

Think of it like

It is like a box of LEGO bricks for charts. You can build any chart, but you build it piece by piece.

Example

A news team builds an election map in D3. Readers hover over a county to see its vote count.

Why it matters

It can draw charts no template offers. Many famous interactive news graphics were built with it.

Definition

D3.js is a free, open-source JavaScript library for building charts on the web. The name is short for data-driven documents. Mike Bostock created it in 2011. D3 ties data to the shapes on a web page, like SVG circles and lines. It gives no ready-made charts. It gives the parts, so a coder can build any chart, often with motion and clicks.

Example code

javascript
d3.select("svg")
  .selectAll("rect")
  .data([4, 8, 15])
  .join("rect")
  .attr("y", (d, i) => i * 22)
  .attr("height", 18)
  .attr("width", d => d * 10);
Three numbers become three bars. Each value sets one bar's width.
D3.js: you write code that turns each number into a shape on the page.

Common mistake

Picking it for a simple bar chart. A charting tool or a smaller library does that in minutes, not days.

Key takeaways

  1. 1
    Data drives shapes. Values become SVG elements.
  2. 2
    No templates. You build each chart.
  3. 3
    Web native. SVG, Canvas and JavaScript.