Bind chart to another series - Javascript highcharts

Javascript examples for highcharts:Chart Series

Description

Bind chart to another 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"> 
      <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  .  j  a  v  a2 s .  co  m
    $('#container').highcharts({
        series: [{
            data: [Math.random(), Math.random(), Math.random(), Math.random()]
        }]
    });
    // the button action
    $('#button').click(function() {
        var chart = $('#container').highcharts();
        chart.series[0].setData([Math.random(), Math.random(), Math.random(), Math.random()] );
    });
    $('#button2').click(function() {
       $('#container').highcharts({
            series: [{
                data: [Math.random(), Math.random(), Math.random(), Math.random()]
            }]
        });
    });
});

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

Related Tutorials