Skip to content
Related Articles

Related Articles

D3.js json() Function
  • Last Updated : 31 Aug, 2020

The d3.json() function is used to fetch the JSON file. If this function got an init parameter, then this is called along with the fetch operation.


d3.json(input[, init]);

Parameters: This function accepts two parameters as mentioned above and described below.

  • input: This parameter takes the address of the input file.
  • init: This parameter takes a function that does some operation with the data of the file.

Note: Please create a JSON file named “sample.json” before writing the given example.



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8" />
    <meta name="viewport" path1tent=
        initial-scale=1.0" />
    <script src=
        // Data of sample.json file
        // {
        //     "place": "GeeksforGeeks",
        //     "visitiors": "100M",
        //     "target": "Client",
        //     "source": "Server"
        // }
        d3.json("sample.json", function (d) {


My Personal Notes arrow_drop_up
Recommended Articles
Page :