Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display highchart y axis with constistant data

I have a highchart column graph, in that at some time the y axis data are displaying as [1000,2000,3000,4000] and some times as [1k, 2k, 3k, 4k].

How can I fix it to single type of data.

Regards, Navin Leon

like image 885
Navin Leon Avatar asked Feb 29 '12 19:02

Navin Leon


3 Answers

Compare http://jsfiddle.net/BNFe5/

The difference is here:

yAxis: {
    labels: {
        formatter: function() {
            return this.value;
        }
    }
},
like image 111
Cheery Avatar answered Nov 01 '22 10:11

Cheery


For Converting your yaxis values into 1k,2k,3k,4k,etc:

yAxis: 
{
    labels: 
    { 
      formatter: function() 
      {
         return Math.round(this.value/1000) + 'k';
      }
    }
},
like image 24
Venkateswara Raju V Avatar answered Nov 01 '22 08:11

Venkateswara Raju V


If you are using thousands and millions in one chart, check this out.

yAxis: {
    labels: {
        formatter: function () {
            if (this.value.toFixed(0) >= 1000000) {
                return '$' + this.value.toFixed(0) / 1000000 + 'M';
            } else {
                return '$' + this.value.toFixed(0) / 1000 + 'K';
            }
        }
    },
    title: {
        text: ''
    }
},
like image 2
M H Avatar answered Nov 01 '22 10:11

M H