Javascript examples for highcharts:Line Chart
Counting json data to create dynamic series in line charts
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(function () {/* w w w . ja va 2s . c o m*/ var json = [{ "data": ["2012-12-16; 0", "2012-12-16; 23"] }, { "name": "MSMDN1", "data": [98.9914, 99.5429] }, { "name": "MSMDN2", "data": [99.4577, 99.5078] }, { "name": "MSMDN3", "data": [99.1454, 99.4605] }, { "name": "MSMDN4", "data": [98.9663, 99.3663] }, { "name": "MSMDN5", "data": [104.97, 91.4251] }]; var len = json.length i = 0; var options = { xAxis: { categories: [] }, series: [] } for (i; i < len; i++) { if (i === 0) { var dat = json[i].data, lenJ = dat.length, j = 0, tmp; for (j; j < lenJ; j++) { tmp = dat[j].split(';'); options.xAxis.categories.push(tmp[0]); } } else { options.series.push(json[i]); } } $('#container').highcharts(options); }); </script> </head> <body> <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> </body> </html>