I am new to using HighCharts and JSON. I am pulling data from my database and it is producing the following JSON:
{"GS10":[{"data_date":-528656400,"value":2.83},{"data_date":-526064400,"value":3.05},{"data_date":-523386000,"value":3.11},{"data_date":-520794000,"value":2.93},{"data_date":-518115600,"value":2.95},{"data_date":-515437200,"value":2.87},{"data_date":-512845200,"value":2.66},{"data_date":-510166800,"value":2.68},{"data_date":-507574800,"value":2.59},{"data_date":-504896400,"value":2.48},{"data_date":-502218000,"value":2.47},{"data_date":-499798800,"value":2.37},{"data_date":-497120400,"value":2.29},{"data_date":-494528400,"value":2.37},{"data_date":-491850000,"value":2.38},{"data_date":-489258000,"value":2.3},{"data_date":-486579600,"value":2.36},{"data_date":-483901200,"value":2.38}]}
This JSON is then to be rendered into a line chart using HighCharts. The script is below. It renders a graph, but the graph is blank. I am currently only testing with one series, but the intent is to be able to use multiple series once I can successfully graph one. Any help would be appreciated, thanks.
<script>
$(function () {
var test_point = 'GS10';
$(document).ready(function() {
$.getJSON("get_data.php", function(json) {
var seriesArr = [];
var series = {
name: test_point,
data: []
};
$.each(json[test_point], function(key, data){
series.data.push({
date: data.data_date,
value: data.value
});
});
seriesArr.push(series);
var options = {
chart: {
renderTo: 'container',
defaultSeriesType: 'line'
},
xAxis: {
type: 'datetime'
},
series: seriesArr
};
var chart = new Highcharts.Chart(options);
});
});
});
</script>