Dynamically change / add axis attributes - Javascript highcharts

Javascript examples for highcharts:Chart Axis

Description

Dynamically change / add axis attributes

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts : Initialize y-axis title using a function</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
var yAxis = {/*from   ww  w  . ja  va  2  s  . c  om*/
   'dollars': function () {
      var yAxis = {
         title: {
            text: "Burdened Dollars"
         }
      };
      return yAxis;
   }
};
$(function () {
    var chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            type: 'column'
        },
        xAxis: {
            categories: ['FY Total']
        },
        yAxis: yAxis.dollars(),
        series: [{
            name: 'YTD Plan2',
            data: [1000]
        }, {
            type: 'column',
            name: 'YTD Actual',
            data: [900]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials