Creating a Simple Line Chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Creating a Simple Line Chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#container {//from   ww  w. j ava2  s.c om
   min-width: 310px;
   max-width: 800px;
   height: 400px;
   margin: 0 auto
}


      </style> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/series-label.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <script src="https://code.highcharts.com/modules/export-data.js"></script> 
      <div id="container"></div> 
      <script type="text/javascript">
var one_yr = [{
  'close': 30.1361,
  'date': '2017-07-05'
}, {
  'close': 29.7583,
  'date': '2017-07-06'
}, {
  'close': 29.9326,
  'date': '2017-07-07'
}]
one_yr = one_yr.map(function(e) {
  return {
    'y': e.close,
    'x': new Date(e.date).getTime()
  }
})
Highcharts.chart('container', {
  title: {
    text: 'One Year Stock Price'
  },
  xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
      day: '%e of %b'
    }
  },
  series: [{
    data: one_yr
  }]
});

      </script>  
   </body>
</html>

Related Tutorials