I am constructing a line graph in PHP. I was setting the max value of the line graph to the max value of my collection of items, but this ended up making the graph less readable you are unable to view the highest line on the graph as it intersects with the top of it. So what I need is basically a formula to take a set of numbers and calculate what the logical max value of on the line graph should be.. so some examples
3500
250
10049
45394
434
312
Max value on line graph should probably be 50000
493
412
194
783
457
344
max value on line graph would ideally be 1000
545
649
6854
5485
11545
In this case, 12000 makes sense as max value
So something as simple as rounding upward to the nearest thousandth might work but I'd need it to progressively increase as the numbers got bigger. (50000 instead of 46,000 in first example) The maximum these numbers will ever be is about a million.
Any recommendations would be greatly appreciated, thank you.
Here is what I settled on, thank you all for your comments:
private function FigureMaxValue($array)
{
$highestNumber = max($array);
if ($highestNumber == 0) return 0;
$highestNumber = $highestNumber * 1.1;
(float)$highestNumber = round((float)$highestNumber, 0);
$maxValue = ceil( (integer)$highestNumber / 100 ) * 100;
return $maxValue;
}