Javascript examples for highcharts:Line Chart
Add range selection to line chart
<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"> $(window).load(function(){// ww w .j av a 2 s . c o m $.getJSON('https://www.highcharts.com/samples/data/jsonp.php?filename=aapl-c.json&callback=?', function(data) { $(function() { $('#container').highcharts('StockChart', { title : { text : 'MACD of AAPL stock price' }, subtitle: { text: 'From may 15, 2006 to May 10, 2013' }, yAxis: [{ title: { text: 'Price' }, height: 200, plotLines: [{ value: 0, width: 1, color: '#808080' }] }], tooltip: { crosshairs: true, shared: true }, rangeSelector : { selected : 1 }, legend: { enabled: true, layout: 'vertical', align: 'right', verticalAlign: 'middle', borderWidth: 0 }, plotOptions: { series: { marker: { enabled: false, } } }, series : [{ name: 'AAPL Stock Price', type : 'line', id: 'primary', data : data }] }); $('#create_macd').click(function(e) { var chartIndicator = $('#container').highcharts(); chartIndicator.addAxis({ // Secondary yAxis title: { text: 'MACD' }, top: 260, height: 87, offset: 0, lineWidth: 1, }); chartIndicator.addSeries( { name : 'MACD', linkedTo: 'primary', yAxis: 2, showInLegend: true, type: 'trendline', algorithm: 'MACD' }); chartIndicator.addSeries( { name : 'Signal line', linkedTo: 'primary', yAxis: 2, showInLegend: true, type: 'trendline', algorithm: 'signalLine' }); }); }); }); }); </script> </head> <body> <script src="https://code.highcharts.com/stock/highstock.js"></script> <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> <script src="https://rawgithub.com/laff/technical-indicators/master/technical-indicators.src.js"></script> <div id="container" style="min-width: 500x; height: 500px; margin: 0 auto"></div> <input type="button" id="create_macd" value="Add MACD"> </body> </html>