Show live data on chart without default series - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

Show live data on chart without default series

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  ww  .j a va2 s  .c  o m*/
   min-width: 310px;
   max-width: 800px;
   height: 400px;
   margin: 0 auto
}


      </style> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container"></div> 
      <script type="text/javascript">
const chart = new Highcharts.chart('container', {
   series: [{}]
});
const values = [[100, 20], [200, 20], [300, 20], [400, 20], [500, 20]];
document.addEventListener('DOMContentLoaded', function() {
  var i = 0;
  chart.series[0].addPoint(values[i], true, false);
  i++;
  setInterval(function() {
    chart.series[0].addPoint(values[i], true, true);
    i++;
  }, 1000);
});

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

Related Tutorials