Reputation: 1563
I am trying to get this graph working according to my dataset. See this jsfiddle. For me the dataset is not an array of objects, it is an array of integers which will denote my y axis, and index of those values will denole my x axis(basically a sequential set of values).
I think I am not getting the exact purpose of nest and stack functions. Or I think I am not getting the data1 populated in the correct manner like this :
var data1=[]
data.forEach(function(v, i) {
var d = {}
d.x = i;
d.y = v;
data1.push(d);
});
Can anyone please help me understand where I am going wrong . Thanks in advance
Upvotes: 0
Views: 45
Reputation: 10612
Here is what I have done : https://jsfiddle.net/thatOneGuy/0xhmphgw/5/
Basically the example you have shown I converted it to JSON and this is what one of the data elements look like :
{
"key": "Group2",
"value": 12,
"date": "04/23/12"
}
So I changed your data to be similar like so :
var data = [];
oldData.forEach(function(d, i) {
//console.log(d)
d.forEach(function(e, j) {
var thisData = {}
thisData.key = i; //i is which group it is in (0,1,2 of the array)
thisData.value = e; //value is the integer
thisData.date = j; //date (used to keep similar to example) is what index it is in current array
data.push(thisData)
})
})
Now your new data looks similar to this :
{
date:0,
key:0,
value:48746453,
}
Hopefully you understand. Basically, you need to manipulate your data so that it fits with the example provided.
Upvotes: 1