Tuesday, 6 August 2013

json values in variable for D3 chart throwing error.While the static json files works fine

json values in variable for D3 chart throwing error.While the static json
files works fine

We are trying to fetch the json values from a variable(data) and giving
this to D3 as input in the form of json.But it is throwing error in
firebug saying "data.links is not defined". This chart is coming fine if
we take the json values from sample.json file with d3.json() funtion,but
not with the variable.
below is the sample json,
{
"nodes": [
{
"group": "Rockstar",
"name": "SLUSSOMATIC",
"size": 20
},
{
"group": "Redbull",
"name": "ROBDELANEY",
"size": 7
},
{
"group": "Rockstar",
"name": "MIKERIZZO1225",
"size": 5
},
{
"group": "Redbull",
"name": "OFFASRETURNII",
"size": 1
},
{
"group": "Rockstar",
"name": "DEUCES_SK",
"size": 1
},
{
"group": "Redbull",
"name": "EITAKMARSHALL",
"size": 1
},
{
"group": "Redbull",
"name": "COOKIEPIKACHU14",
"size": 1
},
{
"group": "Redbull",
"name": "CRISPAULCANDO",
"size": 1
}
],
"links": [
{
"source": 3,
"target": 3,
"value": 1
},
{
"source": 4,
"target": 4,
"value": 1
},
{
"source": 7,
"target": 57,
"value": 1
},
{
"source": 10,
"target": 10,
"value": 1
},
{
"source": 12,
"target": 332,
"value": 1
},
{
"source": 14,
"target": 325,
"value": 1
},
{
"source": 17,
"target": 548,
"value": 1
},
{
"source": 19,
"target": 157,
"value": 1
}
]
}
and D3 code is here D3 chart with JSON
we are trying to retriev the data from rest api call with mongoDB with
jquery.This we are using becasue the JSON format returned from mongoDB is
not refined.

No comments:

Post a Comment