Javascript examples for highcharts:Line Chart
Plot multiple lines on x-axis in line chart
<html> <head> <title>Highcharts Demo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <div id="container" style="height: 300px"></div> <div id="report"></div> <script type="text/javascript"> var $report = $('#report'); var data = [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4]; var plotlines = [];//from ww w .j a v a2s . c o m //var startTime = Date.UTC(2010, 0, 1).getTime(); var startTime = new Date(Date.UTC(2010, 0, 1)).getTime(); for(var i = 0; i < data.length; i++) { var timeincr = startTime + 1000*3600*24*i; console.log(new Date(timeincr)); var pline = { // mark the weekend color: 'red', width: 2, value: timeincr, events: { click: function () { $report.html('click'); }, mouseover: function () { $report.html('mouseover'); }, mouseout: function () { $report.html('mouseout'); } } }; plotlines.push(pline); } Highcharts.chart('container', { xAxis: { plotLines: plotlines, tickInterval: 24 * 3600 * 1000, // one day type: 'datetime' }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4], pointStart: Date.UTC(2010, 0, 1), pointInterval: 24 * 3600 * 1000 }] }); </script> </body> </html>