Accepted answer

being a JS library D3 works with the JS objects(along with other JS data types) only, d3.json is just a method to load the object from an external file. So if you dont need to load data from external file then dont use d3.json

//d3.json("FILENAME", function(error, data) {
    //data = JSON.parse(data);
    var data = {
        "file_id": 333, 
        "t": "2016-03-08 12:00:56"
    }; //your own object
    x.domain( { return d.file_id}));
    y.domain([0, d3.max(data, function(d) { return d.t})]);

hope it helps


If I change the filename to an object its not working.

Then you should call it in a function and pass the object in the params:

var obj = {}; // the object to be be passed for chart

function updateGraph(o){ // get in the params here
    var x = d3.scale.ordinal().rangeRoundBands([0, width]),
        y = d3.scale.linear().range([height, 0]);

    y.domain([0, o.frequency]);

updateGraph(obj); // <----pass it here

Related Query

More Query from same tag