D3

v7.9.2

Data driven documents. Low level toolkit for bespoke, interactive data visualisation.

Quick start

Add this tag to your page. Place it just before the closing </body> tag, or in the <head> with the defer attribute.

HTML
<script src="https://jscdns.net/libs/d3/7.9.2/d3.min.js"
        integrity="sha384-LxfWGZyh6PaLjBRPf7NWiEYs9Mn0UQ6ZmqbLLZhxlOBBNWF2a2K0Pfc5efkrNnhQ" crossorigin="anonymous"></script>

Files

FileSizeCopy
d3.min.jsScript 274.0 KB

Usage

Complete example

A minimal page that loads D3 and uses it. Copy it into a file and open it in your browser.

example.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
</head>
<body>
  <svg id="chart" width="300" height="120"></svg>

  <script src="https://jscdns.net/libs/d3/7.9.2/d3.min.js"
          integrity="sha384-LxfWGZyh6PaLjBRPf7NWiEYs9Mn0UQ6ZmqbLLZhxlOBBNWF2a2K0Pfc5efkrNnhQ" crossorigin="anonymous"></script>
  <script>
    const data = [30, 80, 45, 60, 20];
    const x = d3.scaleBand().domain(d3.range(data.length)).range([0, 300]).padding(0.2);
    const y = d3.scaleLinear().domain([0, 100]).range([120, 0]);

    d3.select('#chart').selectAll('rect')
      .data(data)
      .join('rect')
      .attr('x', (d, i) => x(i))
      .attr('y', d => y(d))
      .attr('width', x.bandwidth())
      .attr('height', d => 120 - y(d))
      .attr('fill', '#1f6feb');
  </script>
</body>
</html>
Good to know. The full bundle includes every D3 module (scales, shapes, selections, transitions and so on) under the d3 global.