score:0

You can call a funtion like that:

  graph({height: 200, width:400, id: "ccag", xE:d3.scale.ordinal().domain(["I", " II", "III", "IV", "V"]),
    data: [[{ x: 0, y: 109117 },{ x: 1, y: 22546 },{ x: 2, y: 29449 },{ x: 3, y: 43711 },{ x: 4, y: 26604 }],[{ x: 0, y: 7481 },{ x: 1, y: 5328 },{ x: 2, y: 10315 },{ x: 3, y: 6218 },{ x: 4, y: 4330 }]],
    color:[["#1c3848"],["#36a8e1"]]
    })();

then your function to draw the graph:

function graph(a) {
  return function () {
    var margin = {top: 20, right: 20, bottom: 20, left: 35},
    w = a.width - margin.left - margin.right,
    h = a.height - margin.top - margin.bottom,
    fnum = d3.format(",");

    //Original data
    var ccad = a.data;
    var stack = d3.layout.stack();

    //Data, stacked
    stack(ccad);
.....
.....

Or you can pass file name to function:

graph({file:"newTSV.tsv"})

then on your function:

function graph(a) {
  return function () {
    d3.tsv(a.file, function(data) { ....

Related Query

More Query from same tag