score:2

Accepted answer

i have created a demo fiddle to dynamically change y-axis title. refer this jsfiddle

html:

<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">

js (part of thec code to update the y-axis title on a button click):

var chart = $('#container').highcharts();
    $('#my_btn').click(function(){
        //alert('hey');
        chart.yaxis[0].update({
            title:{
                text:"my text"
            }
        });
        alert('y-axis title changed to "my text" !');
    });

refer highcharts 'update' function documentation for further details.

score:0

you have two options:

  • use axis.settitle() - good performance, i advice use that solution for setting title
  • use axis.update() - lower performance, because it recreates whole axis, while first method only changes title

Related Query

More Query from same tag