my php code is this
$newArr = array();
$newArr['Item1']=$array1;
$newArr['Item2']=$array2;
$newArr['Item3']=$array3;
$newArr['Item4']=$array4;
$newArr['Item5']=$array5;
$newArr['Item6']=$array6;
$newArr['Item8']=$array8;
echo json_encode($newArr);
i wanted to build a line chart with chartjs with those data. so the chart would looks like this....
here is my current code js......
$(document).ready(function(){
$.ajax({
url : "http://localhost/clicklog/clicklog.php",
type : "GET",
success : function(newArr){
//console.log(newArr.Item1);
Clicks1 = [];
Clicks2 = [];
Clicks3 = [];
Clicks4 = [];
Clicks5 = [];
Clicks6 = [];
Clicks8 = [];
for(var i in newArr){
//console.log(newArr[i]);
for(var x in newArr[i]){
//console.log(newArr[i][x]);
Clicks1.push(newArr[i][x]);
}
}
console.log(Clicks1);
with this code, my variable "Clicks1" has this value
[18948, 13783, 9484, 5468, 46267, 33511, 22824, 13204, 5378, 3773, 2564, 1586, 18076, 13252, 8979, 5394, 10273, 7139, 4713, 2632, 8812, 6326, 4465, 2751, 18083, 12924, 8886, 5354]
which is comes from "newArray" without sorting.
i wanted to put value in the "var clicks1" only for those data that comes from "item 1"
here is the result of my php code..
{"Item1":{"2009-04-17":18948,"2009-04-18":13783,"2009-04-19":9484,"2009-04-20":5468},
"Item2":{"2009-04-17":46267,"2009-04-18":33511,"2009-04-19":22824,"2009-04-20":13204},
"Item3":{"2009-04-17":5378,"2009-04-18":3773,"2009-04-19":2564,"2009-04-20":1586},
"Item4":{"2009-04-17":18076,"2009-04-18":13252,"2009-04-19":8979,"2009-04-20":5394},
"Item5":{"2009-04-17":10273,"2009-04-18":7139,"2009-04-19":4713,"2009-04-20":2632},
"Item6":{"2009-04-17":8812,"2009-04-18":6326,"2009-04-19":4465,"2009-04-20":2751},
"Item8":{"2009-04-17":18083,"2009-04-18":12924,"2009-04-19":8886,"2009-04-20":5354}}
thank you for the help
