read CSV data and create line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

read CSV data and create line chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-git.js"></script> 
      <script type="text/javascript">
$(function () {/*from  www. ja va2 s .  co  m*/
    var chart = new Highcharts.Chart({
        chart: {
            type: 'spline',
            renderTo: 'gfx'
        },
        title: {
            text: 'Daily statistics'
        },
        xAxis: {
            type: 'datetime'
        },
        yAxis: [{
            title: {
                text: 'Watt hours'
            }
        }, {
            title: {
                text: 'Hour.Minutes'
            },
            opposite: true
        }],
        data: {
            csv: document.getElementById('csv').innerHTML,
            firstRowAsNames: true
        },
        series: [{
            yAxis: 0
        }, {
            yAxis: 1
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/data.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="gfx" style="min-width: 310px; height: 400px; margin: 0 auto"></div> 
      <pre id="csv" style="display:none">Date,Production,Duration
2014-10-27,2866,08.50
2014-10-28,6471,09.20
2014-10-29,7609,09.25
2014-10-30,7552,09.11</pre>  
   </body>
</html>

Related Tutorials