D3.js (original) (raw)

Last Updated : 23 Jul, 2025

**D3.js, short for **Data-Driven Documents, is a powerful JavaScript library used to create dynamic and interactive data visualizations in web browsers. Developed by Mike Bostock in 2011, it leverages HTML, CSS, and SVG for visualization.

In this D3.js tutorial, you'll delve into creating dynamic and interactive data visualizations using D3.js. Starting with the fundamentals, you'll learn about SVG, data binding, and selections. Progressing to advanced topics like transitions, scales, and axes, you'll master the art of crafting captivating visualizations.

D3.js Tutorial

D3.js tutorial empowers users to create dynamic, interactive data visualizations. It covers SVG, data binding, transitions, and more, essential for crafting captivating visualizations and enhancing data-driven storytelling on the web.

Table of Content

What is D3.js

D3.js, or Data-Driven Documents, is a JavaScript library for manipulating documents based on data. It enables the creation of dynamic and interactive data visualizations in web browsers using HTML, SVG, and CSS, making it a powerful tool for data-driven storytelling and analysis.

Reason to learn D3.js

Download D3.js Library

To download D3.js, visit the official website at d3js.org. You can either download the latest version directly from the website or use package managers like npm or yarn. Alternatively, you can include it directly in your HTML file using a CDN link.

D3.js Editor

Installation of D3.js

**Step 1: Download the latest version of the D3.js library from the official website (D3.js website). Currently, the latest version of D3.js is v7.8.1.

**Step 2: Extract the zipped file obtained after the download

**Step 3: Search for the **d3.min.js file which is present inside the dist folder.

**Step 4: Copy this file to the root folder or the main library directory of the web page.

**Project Structure

D3.js project structure

D3.js project structure

Another short and easier way to use **D3.js directly is by including the following script tag in your index.html file:

**Example: In this example, we will render the properties of DOM using D3.js and print the greatest of an array using D3.js

HTML `

    <!-- Linking D3.js -->
    <script src="https://d3js.org/d3.v7.min.js"></script>
</head>

<body>
 
    <h3>Example of D3.js</h3>
    <div id="result"></div>
    <script
        type="text/javascript"
        charset="utf-8"
    >
        d3.select("body").style(
            "text-align",
            "center"
        );
    
        d3.select("h3").style(
            "color",
            "blue"
        );

        let gfg = d3.greatest([
            5, 4, 3, 2, 1,
        ]);
        let resultDiv =
            document.getElementById("result");
        resultDiv.innerText =
            "The greatest number is: " + gfg;
    </script>
</body>

`

**Output:

D3js

D3.js Example Output

Features of D3.js

There are many other platforms or frameworks available for managing data visualization, but D3 has left all the other frameworks behind because of being extremely flexible.

Application of D3.js

Learn more about D3.js

D3.js Complete References

Drawbacks of D3.js

**Recent articles for D3.js