0

I am drawing graph real-time and i have big numbers on axis like "200000000". It is hard to read it. I need it to be like "200kk" or anything else. Help?

kalombo
  • 861
  • 1
  • 9
  • 31
  • 1
    This should help. http://stackoverflow.com/questions/9461621/how-to-format-a-number-as-2-5k-if-a-thousand-or-more-otherwise-900-in-javascrip – Sterling Archer Oct 28 '13 at 04:42

1 Answers1

2
 function FormatterNum(num) {
    if (num >= 1000000000) {
        return (num / 1000000000).toFixed(1) + 'G';
    }
    if (num >= 1000000) {
        return (num / 1000000).toFixed(1) + 'M';
    }
    if (num >= 1000) {
        return (num / 1000).toFixed(1) + 'K';
    }
    return num;
}
console.log(FormatterNum(6000));

reference How to format a number as 2.5K if a thousand or more, otherwise 900 in javascript?

Community
  • 1
  • 1
Rituraj ratan
  • 10,260
  • 8
  • 34
  • 55