have this problem where I need to make an array like this to use jqplot draw a graph:
array = [ ["Nov 24 2014", 3], ["Nov 25 2014", 4], ["Nov 26 2014", 5] ]
I have tried the following:
var json = $.parseJSON(data);
var motivation = [];
$.each(json, function (i, elem) {
var temp = [];
temp.push(elem.value1);
temp.push(elem.value2);
console.log(temp);
motivation.push(temp);
});
The only result I am able to get is an array looking like this.
motivation = [Array[2], Array[2], Array[2]]
But I need something that looks like the array in the top.
Anyone?
EDIT:
When I log Temp array I get:
["Nov 24 2014", 3]
["Nov 25 2014", 3]
["Nov 26 2014", 4]
As I want. But when I put them in Motivation array I get
[Array[2], Array[2], Array[2]]
It is the right values when I open the arrays, for example the first one:
0: Array[2]
0: "Nov 24 2014"
1: 3