Reputation: 61
I use this eample link to customize.There are json array and create bar charts according to array.
Please guide me, this is my json format:
{ "server1": [
{
"mount": "test1",
"value": 207
},
{
"mount": "test2",
"value": 20.07
}
],
"server2": [
{
"mount": "test1",
"value": 45
},
{
"mount": "test2",
"value": 0.04
}
]
}
I want to create 2 separate bar chart.
Upvotes: 1
Views: 580
Reputation: 76
pass value like data array and loop it!
d3.json("./data/new.json", function(error,data1){
for(r in data1){
like this you can implement this
Upvotes: 1
Reputation: 29
you can use loop for this
$.getJSON("./data/new.json", function(data){
for(i in data){
alert(i);
data1 = data[i];
after looping using your example this way link
Upvotes: 2
Reputation: 153
Convert this json to two list using javascript or jquery whichever you like
t1 = [207, 45]
t2 = [20.07, 0.04]
now replace data (d) in the http://bl.ocks.org/mbostock/3885304 with t1 for graph 1 and with t2 for graph 2 it will work for sure
Upvotes: 0