Add chart series and redraw chart - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

Add chart series and redraw 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 {//w  w  w. j av  a  2  s . c o m
   min-width: 310px;
   max-width: 800px;
   height: 400px;
   margin: 0 auto
}


      </style> 
   </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="chart1"></div> 
      <input type="button" value="add" onclick="onBtnclick();"> 
      <script type="text/javascript">
Highcharts.chart('chart1', {
    series: [{
        name: 'Installation',
        data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175]
    }]
});
function logFunc(){
    return {
        name: 'NewSeries',
        data: [12908, 5948, 8105, 11248, 8989, 11816, 18274, 48111]
    };
}
function onBtnclick(){
   var chart = $("#chart1").highcharts();
   chart.addSeries(logFunc());
    chart.redraw();
}

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

Related Tutorials