I need help for generate the series data part into json
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container'
},
xAxis: {
type: 'datetime'
},
series: [{
data: [
[Date.UTC(2010, 0, 1), 29.9],
[Date.UTC(2010, 0, 2), 71.5],
[Date.UTC(2010, 0, 3), 106.4],
[Date.UTC(2010, 0, 6), 129.2],
[Date.UTC(2010, 0, 7), 144.0],
[Date.UTC(2010, 0, 8), 176.0]
]
}]
});
My php part
foreach ($behaviour as $value) {
$chart['xAxis']['categories'][]= time($value['date']);
}
Json output
[1318354710,1318354710,1318354710,1318354710]
I don’t know what I need to do with my php code to do this part with a valid json.
part where I need help
series: [{
data: [
[Date.UTC(2010, 0, 1), 29.9],
[Date.UTC(2010, 0, 2), 71.5],
[Date.UTC(2010, 0, 3), 106.4],
[Date.UTC(2010, 0, 6), 129.2],
[Date.UTC(2010, 0, 7), 144.0],
[Date.UTC(2010, 0, 8), 176.0]
]
}]
How can I solve this?
Date.UTCreturns the number of milliseconds in a date string since midnight of January 1, 1970. This is the same as a UNIX timestamp. So[Date.UTC(2010, 0, 1), 29.9]translates to[1262304000, 29.9].There are a number of ways to get this timestamp in PHP. One simple (and object oriented) way is to use the DateTime class:
Update
Without knowing the ins and outs of your code, the best I can do is offer some sample code:
Feel free to adapt it to your actual code.