Source for file svgGrapher.internal.findRange.php

Documentation is available at svgGrapher.internal.findRange.php

  1. <?php
  2. /**
  3.  * Plugin internal findRange.
  4.  *
  5.  * @version $Id: svgGrapher.internal.findRange.php,v 1.3 2007/10/17 23:04:23 geelweb Exp $
  6.  * @author Guillaume L. <guillaume@geelweb.org>
  7.  * @copyright Copyright © 2006, Guillaume Luchet.
  8.  * @license http://opensource.org/licenses/bsd-license.php BSD License
  9.  * @package SvgGrapher
  10.  * @subpackage Internal
  11.  */
  12.  
  13.  
  14. /**
  15.  * svgGrapher_internal_findRange()
  16.  *
  17.  * Get the range for data.
  18.  *
  19.  * @param array $data  Array of data.
  20.  * @param integer $min Minimum accetable value.
  21.  * @param integer $max Maximum acceptable value.
  22.  * @param integer $resolution Approximation level of the max value.
  23.  * @return array 
  24.  */
  25. function svgGrapher_internal_findRange($data$min$max$resolution{
  26.     if (sizeof($data== {
  27.         return array('min' => 0'max' => 0'delta' => 0);
  28.     }
  29.  
  30.     foreach ($data as $key => $value{
  31.         if ($value=='none'{
  32.             continue;
  33.         }
  34.         if ($value $max{
  35.             $max $value;
  36.         }
  37.         if ($value $min{
  38.             $min $value;
  39.         }
  40.     }
  41.  
  42.     if ($max == 0{
  43.         $factorMax 1;
  44.     else {
  45.         /*if ($max < 0) {
  46.             $factorMax = - pow(10, (floor(log10(abs($max)))));
  47.         } else {*/
  48.             $factorMax pow(10(floor(log10(abs($max)))));
  49.         //}
  50.     }
  51.     if($min == 0{
  52.         $factorMin 1;
  53.     /*} elseif($min < 0) {
  54.         $factorMin = - pow(10, (floor(log10(abs($min)))));*/
  55.     else {
  56.         $factorMin pow(10(floor(log10(abs($min)))));
  57.     }
  58.  
  59.     $max $factorMax ceil($max $factorMax);
  60.     $min $factorMin floor($min $factorMin);
  61.     $delta $max $min;
  62.     return array('min' => $min'max' => $max'delta' => $delta);
  63. }
  64.  
  65. ?>

Documentation generated on Tue, 23 Oct 2007 11:32:09 +0200 by phpDocumentor 1.4.0