Get data from series in button action

Description

The following code shows how to get data from series in button action.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript'>
$(function () {<!-- ww  w  .j a  v a  2 s  .  c  o  m-->
    $('#container').highcharts({
        series: [{
            data: [29, 7, 1, 12]
        }]
    });
    // the button action
    $('#button').click(function () {
        var chart = $('#container').highcharts();
        data = chart.series[0].data;
        for (i in data) console.log(i);
    });
});
</script>
</head>
<body>
  <script src="http://code.highcharts.com/highcharts.js"></script>
  <div id="container" style="height: 400px"></div>
  <button id="button">Set new data</button>
</body>
</html>

Click to view the demo





















Home »
  highcharts »
    Series »




Series
Series Color
Series Data
Series Event
Series Marker
Series Style