Loading D3.js data from a simple JSON string

for remote data.json
replace :

d3.tsv("data.tsv", function(error, data) {...}

with :

d3.json("data.json", function(error, data) {
    console.log(data); // this is your data
});

for local data:

var myData = { {date:'2013-05-01', frequency:99},
               {date:'2013-05-02', frequency:24} };

function draw(data) {
    console.log(data); // this is your data
}

draw(myData);

Leave a Comment