javascript - Highcharts: Dynamically (programmatically) assign the axis name -


i trying add programmaticallya string x axis, instead declaring in chart creation.

so example, have chart:

$.(document).ready(function{) {     chart=new highcharts.chart({         chart:{             renderto: 'container',             type: 'line'         }     yaxis: {         title: { text: 'theyaxis'}     }     series: [1,2,3,4]     }); }); 

now want change yaxis title, create small function; this:

var titley;

function loadme(){      $.get('names.csv', function(data){         var lines= data.split('\n');         titley=lines[0].split(','[0];     }); }  $.(document).ready(function{) {     chart=new highcharts.chart({         chart:{             renderto: 'container',             type: 'line'         }     yaxis: {         title: { text: titley}     }     series: [1,2,3,4]     });     loadme(); }); 

this result in title being empty.

i checking sure value correctly retrieved, using console.log, , value collected , printed. wrong here? same issue if populate $.get function data want add series in chart: data never add chart, if correctly retrieved.

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

html:

<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  <input type="button" value="change y-axis title 'my text'" id="my_btn"> 

js (part of thec code update y-axis title on 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 "my text" !');     }); 

refer highcharts 'update' function documentation further details.


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -