Javascript examples for highcharts:Chart Json Data
Different type of series in highstock with json data
<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 () {/*from w w w. j a v a 2 s .c o m*/ var seriesOptions = [], seriesCounter = 0, names = ['MSFT', 'AAPL', 'GOOG'], types = ['line', 'column', 'spline']; /** */ function createChart() { $('#container').highcharts('StockChart', { rangeSelector: { selected: 4 }, yAxis: { labels: { formatter: function () { return (this.value > 0 ? ' + ' : '') + this.value + '%'; } }, plotLines: [{ value: 0, width: 2, color: 'silver' }] }, plotOptions: { series: { compare: 'percent' } }, tooltip: { pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>', valueDecimals: 2 }, series: seriesOptions }); } $.each(names, function (i, name) { $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=' + name.toLowerCase() + '-c.json&callback=?', function (data) { seriesOptions[i] = { name: name, data: data, type: types[i] }; seriesCounter += 1; if (seriesCounter === names.length) { createChart(); } }); }); }); </script> </head> <body> <script src="https://code.highcharts.com/stock/highstock.js"></script> <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> <div id="container" style="height: 400px; min-width: 310px"></div> </body> </html>