On Friday, 17 December 2010, Simon J Welsh <si...@welsh.co.nz> wrote: > On 18/12/2010, at 8:45 AM, Brian Dunning wrote: > >> Hey all - >> >> I'm trying to provide reporting to users of our widget. Some may get 0 to 5 >> hits a day; others may get up to 10,000 hits a day. I need to define the >> range of the graph (using one of Google's). If their max day is 7, I'd like >> the graph to go from 0 to 10. If their max day is 5678, I'd probably like it >> to go from 0 to 6000. I'm guessing the way to do this is with a ceiling >> function? >> >> - Brian >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > > Personally, I'd use something like: > > if($hits < 10) { > $top = 10; > } else { > $top = ($hits[0] + 1) * pow(10, strlen($hits) - 1); > } > > Basically, add one to the first digit and make the rest of the digits 0. > Depending on how you want to handle the cases ending in 0s, you may want an > extra check in there. > > General disclaimer about code typed directly into mail client. > > Happy Saturday :)
Personally I'd add a percentage on top, say 5 or 10 percent. Regards Peter -- <hype> WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 </hype> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php