Re: How to define a data range for graphing?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Friday, 17 December 2010, Simon J Welsh <simon@xxxxxxxxxxx> 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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux