Re: How to define a data range for graphing?
| From: | Simon J Welsh | Date: | Fri, 17 Dec 2010 19:53:19 +0000 |
| Subject: | Re: How to define a data range for graphing? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-310120@lists.php.net to get a copy of this message | ||
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 :)
---
Simon Welsh
Admin of http://simon.geek.nz/
Who said Microsoft never created a bug-free program? The blue screen never, ever crashes!
http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e