Javascript examples for highcharts:Line Chart
Display Date month on X-Axis for line chart
<html> <head> <title>ElementStacks</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.7.1.js"></script> <script type="text/javascript"> $(window).load(function(){//from w ww . ja v a 2 s .co m $(document).ready(function() { window.chart = new Highcharts.Chart({ chart: { renderTo: 'container', borderWidth: 1, width: 400, height: 600, zoomType: 'x' }, title: { text: '' }, xAxis: { type: 'datetime', tickInterval: 24 * 3600000, labels: { formatter: function() { return Highcharts.dateFormat('%b %d', this.value); } }, min: Date.parse('06/21/2012') - (6 * 24 * 3600000) - 50000000 // Should set this via some check. Something like get max time and subtract 7. You can do this when you read in the data from your SQL. The '(6 * 24 * 3600000)' is 6 days back (or a total of 7 points and then we take a little more off so the first point is on the yAxis. }, yAxis: { min: 0, title: { text: 'Unemployment Rate', align: 'high' } }, series: [{ data: [[Date.parse('06/01/2012'), 6], [Date.parse('06/02/2012'), 6], [Date.parse('06/03/2012'), 7], [Date.parse('06/04/2012'), 7], [Date.parse('06/05/2012'), 8], [Date.parse('06/06/2012'), 7], [Date.parse('06/07/2012'), 9], [Date.parse('06/08/2012'), 6], [Date.parse('06/09/2012'), 10], [Date.parse('06/10/2012'), 9], [Date.parse('06/11/2012'), 9], [Date.parse('06/12/2012'), 10], [Date.parse('06/13/2012'), 4], [Date.parse('06/14/2012'), 6], [Date.parse('06/15/2012'), 11], [Date.parse('06/16/2012'), 7], [Date.parse('06/17/2012'), 19], [Date.parse('06/18/2012'), 12], [Date.parse('06/19/2012'), 10], [Date.parse('06/20/2012'), 11], [Date.parse('06/21/2012'), 13]], type: 'line', lineWidth: 1}] }); }); }); </script> </head> <body> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 600px;margin-top:20px;width: 400px"></div> </body> </html>