[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 4 5 /** 6 * Class for axis handling. 7 * 8 * PHP versions 4 and 5 9 * 10 * LICENSE: This library is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU Lesser General Public License as published by 12 * the Free Software Foundation; either version 2.1 of the License, or (at your 13 * option) any later version. This library is distributed in the hope that it 14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 16 * General Public License for more details. You should have received a copy of 17 * the GNU Lesser General Public License along with this library; if not, write 18 * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 19 * 02111-1307 USA 20 * 21 * @category Images 22 * @package Image_Graph 23 * @subpackage Axis 24 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 25 * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen 26 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 27 * @version CVS: $Id: Logarithmic.php,v 1.15 2006/03/02 12:35:57 nosey Exp $ 28 * @link http://pear.php.net/package/Image_Graph 29 */ 30 31 /** 32 * Include file Image/Graph/Axis.php 33 */ 34 require_once 'Image/Graph/Axis.php'; 35 36 /** 37 * Diplays a logarithmic axis (either X- or Y-axis). 38 * 39 * @category Images 40 * @package Image_Graph 41 * @subpackage Axis 42 * @author Jesper Veggerby <pear.nosey@veggerby.dk> 43 * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen 44 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 45 * @version Release: 0.7.2 46 * @link http://pear.php.net/package/Image_Graph 47 */ 48 class Image_Graph_Axis_Logarithmic extends Image_Graph_Axis 49 { 50 51 /** 52 * Image_Graph_AxisLogarithmic [Constructor]. 53 * 54 * Normally a manual creation should not be necessary, axis are 55 * created automatically by the {@link Image_Graph_Plotarea} constructor 56 * unless explicitly defined otherwise 57 * 58 * @param int $type The type (direction) of the Axis, use IMAGE_GRAPH_AXIS_X 59 * for an X-axis (default, may be omitted) and IMAGE_GRAPH_AXIS_Y for Y- 60 * axis) 61 */ 62 function Image_Graph_Axis_Logarithmic($type = IMAGE_GRAPH_AXIS_X) 63 { 64 parent::Image_Graph_Axis($type); 65 $this->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_MAXIMUM); 66 $this->_minimum = 1; 67 $this->_minimumSet = true; 68 } 69 70 /** 71 * Calculate the label interval 72 * 73 * If explicitly defined this will be calucated to an approximate best. 74 * 75 * @return double The label interval 76 * @access private 77 */ 78 function _calcLabelInterval() 79 { 80 $result = parent::_calcLabelInterval(); 81 $this->_axisValueSpan = $this->_value($this->_axisSpan); 82 return $result; 83 } 84 85 /** 86 * Preprocessor for values, ie for using logarithmic axis 87 * 88 * @param double $value The value to preprocess 89 * @return double The preprocessed value 90 * @access private 91 */ 92 function _value($value) 93 { 94 return log10($value) - log10($this->_minimum); 95 } 96 97 /** 98 * Get next label point 99 * 100 * @param doubt $point The current point, if omitted or false, the first is 101 * returned 102 * @return double The next label point 103 * @access private 104 */ 105 function _getNextLabel($currentLabel = false, $level = 1) 106 { 107 if (is_array($this->_labelOptions[$level]['interval'])) { 108 return parent::_getNextLabel($currentLabel, $level); 109 } 110 111 if ($currentLabel !== false) { 112 $value = log10($currentLabel); 113 $base = floor($value); 114 $frac = $value - $base; 115 for ($i = 2; $i < 10; $i++) { 116 if ($frac <= (log10($i)-0.01)) { 117 $label = pow(10, $base)*$i; 118 if ($label > $this->_getMaximum()) { 119 return false; 120 } else { 121 return $label; 122 } 123 } 124 } 125 return pow(10, $base+1); 126 } 127 128 return max(1, $this->_minimum); 129 } 130 131 /** 132 * Get the axis intersection pixel position 133 * 134 * This is only to be called prior to output! I.e. between the user 135 * invokation of Image_Graph::done() and any actual output is performed. 136 * This is because it can change the axis range. 137 * 138 * @param double $value the intersection value to get the pixel-point for 139 * @return double The pixel position along the axis 140 * @access private 141 */ 142 function _intersectPoint($value) 143 { 144 if (($value <= 0) && ($value !== 'max') && ($value !== 'min')) { 145 $value = 1; 146 } 147 return parent::_intersectPoint($value); 148 } 149 150 } 151 152 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |