Link to home
Start Free TrialLog in
Avatar of JSW21
JSW21Flag for United States of America

asked on

algorithm ideas for number shorten with 1 Million = 1M, 1 Thousand = 1K etc.

I have a set of numbers to be plot as histogram chart. The Y scale need a short legend for divisor such as M = million, K = thousand .

I need a logic so that the y scale show a meaningful numbers - and also all data will be divided by that divisor.

The set of number changed randomly for each new plot - so algorithm need to work when there are large and small numbers plot together. - no log scale is necessary.

Numbers will not goes below 0 but can be as high as billions.

How should i calculate for divisor, e.g. using average number or max/min etc.
BR,
ASKER CERTIFIED SOLUTION
Avatar of Amick
Amick
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Numbers will not goes below 0 but can be as high as billions.

If that really means that ALL plots will be from zero upwards then use the suggestion by Amick.

However if you mean you could have a range of eg. 1,000,000 to 1,000,200 - all values within a range of 200 but with a start of 1 million then you will need to find the minimum and maximum values and use the difference to calculate the actual intervals that make sense.



ps. re Amicks suggestion you could also convert to a string and use the length.  eg.  "123456789" is 9 chars long = billions
Avatar of JSW21

ASKER

They are stock volume so they can get varies.

So basically fine the largest magnitude then convert all other numbers.

But One thing - I then need to make sure - Y scale support decimal point - or - it will show 0 on the scale. thanks.

PS. Thanks for other comments but points were given earlier.