I have to show some results of an experiment in a line chart. I got it working for static data, but I want to make it dynamic.
So what I got:
I have a line charts:
var options = {
chart: {
renderTo: 'container',
type: 'line',
},
series: [{}]
}
I want something like this: http://jsfiddle.net/gh/get/jquery/1.7.1/highslide-software/highcharts.com/tree/master/samples/highcharts/series/data-array-of-arrays/
I am struggling to make those data:
data: [
[0, 29.9],
[1, 71.5],
[3, 106.4]
]
in php side and send it jquery, and feed to my line chart. I am aware of JSON encoding, but how should I create and array in php in first place? And how should I encode it and give it to jquery and feed my line chart?
This is working so far with static data:
var arr = [[0, 15], [10, 50], [20, 56.5], [30, 46.5], [40, 22.1],
[50, 2.5], [60, 27.7], [70, 55.7], [80, 76.5]];
options.series[0].name = 'Occlusion';
options.series[0].data = arr;
var l = new Highcharts.Chart(options);
});
But I want arr to come from php.
Thanks in advance.
If you want to create such format, you need to restructure them first. Consider this example:
Sample Output