0

Currently when using numeral(1000000).format('0a') will return 1m, however is it possible to set a scale, for example thousands, so any number will get converted to a number in thousands? For instance 1000000 will become 1000k, and 100 would become 0,1k and so on.

console.log(
  numeral(1000000).format('0a')
);  
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Alex T
  • 3,529
  • 12
  • 56
  • 105

1 Answers1

2

Try 0ak format

https://github.com/adamwdraper/Numeral-js/blob/master/src/numeral.js#L143

console.log("1000000:",numeral(1000000).format('0ak'),"\n100:",numeral(100).format('0ak'))
<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js"></script>
User863
  • 19,346
  • 2
  • 17
  • 41