# Graph scale formula

This topic is 5460 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi ppl. This may seem trivial to some but bear with me. I need to come up with a formula that will generate the scale values for a graph. for example's sake, lets say i can have 5 number on the graph scale. Now at runtime, the actual graph may have a highest value of, say, 9900... so ideally my scale ranges from 0 to 10000, with a step of 2000. still with me? i currently use this formula (pseudocode): Round( Log( Abs(value) ) / LN10 ) Log being log10 and LN10 being the natural-log constant. Wat this returns me is the power of the (highest) value. However, this number is useful only if all the other data are relatively near to the highest. However that value on its own cannot be used universally as the data set has higher variance and the power difference between data start to generate scales which are too huge for me. is there a general formula that can work universally to limit the scale as near as possible to the highest value without sacrificing detail. also, how is it possible to round the scale of to the nearest multiple of a power-of-10? Not sure if i phrased this well, but here's to hoping :) thanx in advance.

##### Share on other sites
when imean nearest, i dun mean literally the nearest.. btu a sensible one. like if the highest is 9000, then the scale shud be in steps of 2000 reaching the highest of 10000.
but if the value is 10000, then the scale shud be 11000 or 12000. I think it makes more sense for it to be perfectly divisible by 4.

i'm limiting the scale to a minimum of 3 digits and up to 8 digits. just cant figure out a formula that works across this entire range.

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 16
• 13
• 14