Use Javascript function to set labels - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

Use Javascript function to set labels

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Support: StackOverflow</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">
$(function() {/*from  ww w .  j a va 2  s  .  co  m*/
  $('#container').highcharts({
    xAxis: {
      categories: [1, 4, 0, 0, 2, 0, 5, 0],
      labels: {
        formatter: function() {
          // custom formatter
          debugger;
          if (this.value == 0) {
            return '(Not Designated)';
          } else if (this.value != 0) {
            return this.value;
          }
        },
      },
    },
    series: [{
      data: [29.9, 71.5, 106.4, 102, 80, 76, 45]
    }]
  });
});

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

Related Tutorials