Get series by id

Description

The following code shows how to get series by id.

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 () {<!-- w w  w  .  j ava2s .co  m-->
    $('#container').highcharts({
        series: [{
            id: 'series-1',
            name: 'First series',
            data: [9.9, 7.5, 10.4]
        }, {
            id: 'series-1',
            name: 'Second series',
            data: [16.4, 14.1, 9.6]
        }]
    });
    // The button action
    $('#button').click(function () {
        var chart = $('#container').highcharts(),
            series = chart.get('series-1');
        alert('The first series\' name is ' + series.name);
    });    
});
</script>
</head>
<body>
  <script src="http://code.highcharts.com/highcharts.js"></script>
  <script src="http://code.highcharts.com/highcharts-more.js"></script>
  <script src="http://code.highcharts.com/modules/exporting.js"></script>
  <div id="container" style="height: 400px"></div>
  <button id="button">Get first series</button>
</body>
</html>

Click to view the demo





















Home »
  highcharts »
    Series »




Series
Series Color
Series Data
Series Event
Series Marker
Series Style