Friday, December 16, 2016

Format Axis labels in High Charts

There are a number of formatting options in HighCharts.

To format a data label, formatter can be used as demonstrated at http://stackoverflow.com/questions/24708198/how-to-format-highcharts-datalabels-decimal-points.

A tooltip formatter formats tooltip e.g. http://stackoverflow.com/questions/16991335/highcharts-tooltip-formatter

To format axis labels a formatter can be configured as

formatter: function () {
    var ret = '',multi,axis = this.axis,numericSymbols = ['k', 'M', 'G', 'T', 'P', 'E'],
        i = numericSymbols.length;
    while (i-- && ret === '') {
        multi = Math.pow(1000, i + 1);
        if (axis.tickInterval >= multi && numericSymbols[i] !== null) {
            ret = Highcharts.numberFormat(this.value / multi, -1) + numericSymbols[i];
        }
    }
    if (ret === '') ret = this.value;
    return ret;
}

I have created a fiddle to demonstrate this at http://jsfiddle.net/Lng7w9v0/

No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...