I have a highcharts chart in one of my views and I want the source data to be ajax loaded from a route that returns a json response.
So I made an api route:
Route::get('api/v1/data/{id}', function($id) {
//Do some stuff and make a key value array with unix timestamp as key and float as value
$data = Model::getData($id);
return $data;
});
I have set up the highchart in my view as in the demo but with my api route as the json source. My chart renders OK but the data is not drawn. There are no errors in the console.
When I view the output of my api route the json output is as follows:
{
"1317423600": 0,
"1325289600": -0.17099521359192,
"1333148400": 0.85133638321359,
"1341010800": -0.94235521748172,
"1348959600": 0.37334056741349,
"1356912000": -0.15089107586321,
"1364688000": 10.261663055542,
"1372546800": 9.4860565407533,
"1380495600": 6.2120398914028,
"1388448000": 8.7469537358921,
"1396220400": 8.7985530414845,
"1398812400": 7.633928980909
}
While the demo json output is like this:
[
[1147651200000,67.79],
[1147737600000,64.98],
[1147824000000,65.26],
[1147910400000,63.18],
[1147996800000,64.51],
[1148256000000,63.38],
[1148342400000,63.15]
]
I suspect this is why the data is not rendering. Why the difference in output and how can I return a response that highcharts will understand.