Highcharts test tool

HTML

<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>

<div id="container" style="height: 300px"></div>

<button id="addaxis">1. Add Y axis</button>
<button id="addseries">2. Add series</button>
<button id="removeseries">3. Remove primary series</button>
<button id="removeaxis">4. Remove primary axis</button>

JavaScript

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

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

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

$('#addaxis').click(function () {
    chart.addAxis({
        opposite: true,
        title: {
            text: 'Secondary'
        }
    });    
});

$('#addseries').click(function () {
    chart.addSeries({
        name: 'Second series',
        color: 'red',
        data: $.map(new Array(12), Math.random),
        yAxis: chart.yAxis.length - 1
    });
});



$('#removeseries').click(function () {
    chart.series[0].remove();
});

$('#removeaxis').click(function () {
    chart.yAxis[0].remove();
});

/*
 * Highcharts plugin for adding an axis after render time. Works with Highcharts >= 2.2.4.
 * Last revision: 2012-11-26
 */
(function (Highcharts) {
    /**
     * Utility function to remove last occurence of an item from an array
     * @param {Array} arr
     * @param {Mixed} item
     */
    function erase(arr, item) {
        var i = arr.length;
        while (i--) {
            if (arr[i] === item) {
                arr.splice(i, 1);
                break;
            }
        }
        return i;
    }
    /**
     * Add an axis to the chart
     * @param {Object} options The axis option
     * @param {Boolean} isX Whether it is an X axis or a value axis
     */
    Highcharts.Chart.prototype.addAxis = function (options, isX) {
        var key = isX ? 'xAxis' : 'yAxis',
            axis = new Highcharts.Axis(this, Highcharts.merge(options, {
                index: chart[key].length
            }));
        
        // Push the new axis options to the chart options
        chart.options[key] = Highcharts.splat(chart.options[key] || {});
        chart.options[key].push(options);
    };
    
    /**
     * Remove an axis from...