Javascript examples for highcharts:Chart Range
Range Selector for Date fields
<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. j a v a2 s . co m var seriesOptions = [], seriesCounter = 0, names = ['MSFT', 'AAPL', 'GOOG']; /** * Create the chart when all data is loaded * @returns {undefined} */ function createChart() { $('#container').highcharts('StockChart', { rangeSelector: { enabled: true, selected: 4, inputEnabled: true }, 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 }, function () { console.log(this.rangeSelector) }); } $.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 }; 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>