get default y-Axis label formatter in a custom formatter - Javascript highcharts

Javascript examples for highcharts:Chart Label

Description

get default y-Axis label formatter in a custom formatter

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {//from  ww w .  j a v a  2 s .co m
    var UNDEFINED;
    $('#container').highcharts({
        yAxis: {
            labels: {
                formatter: function () {
                    var numericSymbolDetector = this.axis.isLog ? this.value : this.axis.tickInterval,
                        numericSymbols = this.chart.options.lang.numericSymbols,
                        i = numericSymbols && numericSymbols.length,
                        value = this.value,
                        ret = value,
                        multi;
                    if (i && numericSymbolDetector >= 1000) {
                        ret = UNDEFINED;
                        while (i-- && ret === UNDEFINED) {
                            multi = Math.pow(1000, i + 1);
                            if (numericSymbolDetector >= multi && numericSymbols[i] !== null) {
                                ret = Highcharts.numberFormat(value / multi, -1) + numericSymbols[i];
                            }
                        }
                    }
                    return ret;
                }
            }
        },
        series: [{
            name: 'Tokyo',
            data: [100000, 300000, 300000, 50000, 200000]
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials