Click to add series

Description

The following code shows how to add series event.

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  av  a2 s . c om-->
    $('#container').highcharts({
        chart: {
            events: {
                addSeries: function () {
                    var label = this.renderer.label('A series was added, about to redraw chart', 100, 120)
                        .attr({
                            fill: Highcharts.getOptions().colors[0],
                            padding: 10,
                            r: 5,
                            zIndex: 8
                        })
                        .css({
                            color: '#FFFFFF'
                        })
                        .add();

                    setTimeout(function () {
                        label.fadeOut();
                    }, 1000);
                }
            }
        },

        xAxis: {
            categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        },

        series: [{
            data: [129.9, 171.5, 106.4, 19.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 195.6, 4.4]
        }]
    });
    $('#button').click(function () {
        var chart = $('#container').highcharts();
        chart.addSeries({
            data: [16.4, 114.1, 195.6, 154.4, 129.9, 171.5, 16.4, 129.2, 14.0, 16.0, 15.6, 48.5]
        });
    });
});
</script>
</head>
<body>
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
<button id="button" class="autocompare">Add series</button>
</body>
</html>

Click to view the demo





















Home »
  highcharts »
    Series »




Series
Series Color
Series Data
Series Event
Series Marker
Series Style