Use addSeries and addAxis to update line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Use addSeries and addAxis to update 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"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function() {//from   ww w. java  2s.c  o  m
  $('#container').highcharts({
    series: [{
      data: [1, 2, 3, 4, 5, 6, 7]
    }]
  }, function(chart) {
    chart.addAxis({
      id: 'serie.options.id',
      title: {
        text: 'serie.name'
      },
      lineWidth: 2,
      opposite: false,
    });
    chart.addSeries({
       data: [42,2,4,0],
      yAxis: 1
    });
  });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials