Answer to Stack Overflow question: http://stackoverflow.com/questions/37851990/populating-highchart-line-with-array-of-objects
Mike Zavarello
by Mike Zavarello
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
JavaScript
$(function () {
// draw chart
$('#container').highcharts({
chart: {
type: 'line'
},
title: {
text: 'Year Wise Sales Data'
},
subtitle: {
text: ''
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr']
},
yAxis: {
title: {
text: 'Sold Value'
},
labels: {
formatter: function () {
return this.value + '';
}
}
},
plotOptions: {
line: {
dataLabels: {
enabled: false
},
enableMouseTracking: true
}
},
//series: response
series: [{"name":"2012","data":[692101643,716334837,776991835,769420169 ]},{"name":"2013","data":[860859252,825852169,895524501,892930333 ]}]
});
});