Highcharts : Dynamically update y-axis title

by Rahul Gupta

HTML

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

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>

<input type="button" value="Change Y-axis Title to 'My text'" id="my_btn">
<br>
    <a href="http://api.highcharts.com/highcharts#Axis.update">Refer Highcharts Update function documentation</a>

JavaScript

$(function () {
    /*Highcharts.setOptions({
        lang: {
            //drillUpText: '<< Terug naar {series.name}'
        }
    });*/
    // Create the chart
    $('#container').highcharts({
        chart: {
            type: 'column',
            events: {
                drillup: function (e) {
                    alert('drill Up');
                    console.log(this);
                    console.log(this.options.series[0].name);
                    console.log(this.options.series[0].data[0].name);
                }
            }        
        },
        title: {
            text: 'Y-axis title update demo'
        },
        xAxis: {
            type: 'category'
        },

        legend: {
            enabled: false
        },

        plotOptions: {
            series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                }
            }
        },

        series: [{
            name: 'Things',
            colorByPoint: true,
            data: [{
                name: 'Dieren',
                y: 5,
                drilldown: 'animals'
            }, {
                name: 'Fruit',
                y: 2,
                drilldown: 'fruits'
            }, {
                name: "Auto's",
                y: 4
            }]
        }],
        drilldown: {
            drillUpButton: {
                relativeTo: 'spacingBox',
                position: {
                    y: 0,
                    x: 0
                },
                theme: {
                    fill: 'white',
                    'stroke-width': 1,
                    stroke: 'silver',
                    r: 0,
                    states: {
                        hover: {
                            fill: '#bada55'
                        },
                        select: {
                            stroke: '#039',
                            fill: '#bada55'
                        }
                    }
        ...