[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * This work is hereby released into the Public Domain. 4 * To view a copy of the public domain dedication, 5 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to 6 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 7 * 8 */ 9 10 require_once dirname(__FILE__)."/Plot.class.php"; 11 12 /** 13 * ScatterPlot 14 * 15 * @package Artichow 16 */ 17 class awScatterPlot extends awPlot { 18 19 /** 20 * Add marks to the scatter plot 21 * 22 * @var Mark 23 */ 24 var $mark; 25 26 /** 27 * Labels on the plot 28 * 29 * @var Label 30 */ 31 var $label; 32 33 /** 34 * Link points ? 35 * 36 * @var bool 37 */ 38 var $link = FALSE; 39 40 /** 41 * Display impulses 42 * 43 * @var bool 44 */ 45 var $impulse = NULL; 46 47 /** 48 * Link NULL points ? 49 * 50 * @var bool 51 */ 52 var $linkNull = FALSE; 53 54 /** 55 * Line color 56 * 57 * @var Color 58 */ 59 var $lineColor; 60 61 /** 62 * Line type 63 * 64 * @var int 65 */ 66 var $lineStyle = LINE_SOLID; 67 68 /** 69 * Line thickness 70 * 71 * @var int 72 */ 73 var $lineThickness = 1; 74 75 /** 76 * Construct a new awScatterPlot 77 * 78 * @param array $datay Numeric values for Y axis 79 * @param array $datax Numeric values for X axis 80 * @param int $mode 81 */ 82 function awScatterPlot($datay, $datax = NULL) { 83 84 parent::awPlot(); 85 86 // Defaults marks 87 $this->mark = new awMark; 88 $this->mark->setType(MARK_CIRCLE); 89 $this->mark->setSize(7); 90 $this->mark->border->show(); 91 92 $this->label = new awLabel; 93 94 $this->setValues($datay, $datax); 95 $this->setColor(new awBlack); 96 97 } 98 99 /** 100 * Display plot as impulses 101 * 102 * @param $impulse Impulses color (or NULL to disable impulses) 103 */ 104 function setImpulse($color) { 105 $this->impulse = $color; 106 } 107 108 /** 109 * Link scatter plot points 110 * 111 * @param bool $link 112 * @param $color Line color (default to black) 113 */ 114 function link($link, $color = NULL) { 115 $this->link = (bool)$link; 116 if(is_a($color, 'awColor')) { 117 $this->setColor($color); 118 } 119 } 120 121 /** 122 * Ignore null values for Y data and continue linking 123 * 124 * @param bool $link 125 */ 126 function linkNull($link) { 127 $this->linkNull = (bool)$link; 128 } 129 130 /** 131 * Change line color 132 * 133 * @param $color 134 */ 135 function setColor($color) { 136 $this->lineColor = $color; 137 } 138 139 /** 140 * Change line style 141 * 142 * @param int $style 143 */ 144 function setStyle($style) { 145 $this->lineStyle = (int)$style; 146 } 147 148 /** 149 * Change line tickness 150 * 151 * @param int $tickness 152 */ 153 function setThickness($tickness) { 154 $this->lineThickness = (int)$tickness; 155 } 156 157 /** 158 * Get the line thickness 159 * 160 * @return int 161 */ 162 function getLegendLineThickness() { 163 return $this->lineThickness; 164 } 165 166 /** 167 * Get the line type 168 * 169 * @return int 170 */ 171 function getLegendLineStyle() { 172 return $this->lineStyle; 173 } 174 175 /** 176 * Get the color of line 177 * 178 * @return Color 179 */ 180 function getLegendLineColor() { 181 return $this->lineColor; 182 } 183 184 /** 185 * Get the background color or gradient of an element of the component 186 * 187 * @return Color, Gradient 188 */ 189 function getLegendBackground() { 190 return NULL; 191 } 192 193 /** 194 * Get a mark object 195 * 196 * @return Mark 197 */ 198 function getLegendMark() { 199 return $this->mark; 200 } 201 202 function drawComponent($drawer, $x1, $y1, $x2, $y2, $aliasing) { 203 204 $count = count($this->datay); 205 206 // Get start and stop values 207 list($start, $stop) = $this->getLimit(); 208 209 // Build the polygon 210 $polygon = new awPolygon; 211 212 for($key = 0; $key < $count; $key++) { 213 214 $x = $this->datax[$key]; 215 $y = $this->datay[$key]; 216 217 if($y !== NULL) { 218 $p = awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($x, $y)); 219 $polygon->set($key, $p); 220 } else if($this->linkNull === FALSE) { 221 $polygon->set($key, NULL); 222 } 223 224 } 225 226 // Link points if needed 227 if($this->link) { 228 229 $prev = NULL; 230 231 foreach($polygon->all() as $point) { 232 233 if($prev !== NULL and $point !== NULL) { 234 $drawer->line( 235 $this->lineColor, 236 new awLine( 237 $prev, 238 $point, 239 $this->lineStyle, 240 $this->lineThickness 241 ) 242 ); 243 } 244 $prev = $point; 245 246 } 247 248 $this->lineColor->free(); 249 250 } 251 252 // Draw impulses 253 if(is_a($this->impulse, 'awColor')) { 254 255 foreach($polygon->all() as $key => $point) { 256 257 if($point !== NULL) { 258 259 $zero = awAxis::toPosition( 260 $this->xAxis, 261 $this->yAxis, 262 new awPoint($key, 0) 263 ); 264 265 $drawer->line( 266 $this->impulse, 267 new awLine( 268 $zero, 269 $point, 270 LINE_SOLID, 271 1 272 ) 273 ); 274 275 } 276 277 } 278 279 } 280 281 // Draw marks and labels 282 foreach($polygon->all() as $key => $point) { 283 284 $this->mark->draw($drawer, $point); 285 $this->label->draw($drawer, $point, $key); 286 287 } 288 289 } 290 291 function xAxisPoint($position) { 292 $y = $this->xAxisZero ? 0 : $this->getRealYMin(); 293 return awAxis::toPosition($this->xAxis, $this->yAxis, new awPoint($position, $y)); 294 } 295 296 function getXCenter() { 297 return FALSE; 298 } 299 300 } 301 302 registerClass('ScatterPlot'); 303 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |