[ Index ] |
|
Code source de jpGraph 2.2 |
1 <?php 2 /*======================================================================= 3 // File: JPGRAPH_RADAR.PHP 4 // Description: Radar plot extension for JpGraph 5 // Created: 2001-02-04 6 // Ver: $Id: jpgraph_radar.php 781 2006-10-08 08:07:47Z ljp $ 7 // 8 // Copyright (c) Aditus Consulting. All rights reserved. 9 //======================================================================== 10 */ 11 12 require_once ('jpgraph_plotmark.inc.php'); 13 14 class RadarLogTicks extends Ticks { 15 //--------------- 16 // CONSTRUCTOR 17 function RadarLogTicks() { 18 } 19 //--------------- 20 // PUBLIC METHODS 21 22 // TODO: Add Argument grid 23 function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) { 24 $start = $aScale->GetMinVal(); 25 $limit = $aScale->GetMaxVal(); 26 $nextMajor = 10*$start; 27 $step = $nextMajor / 10.0; 28 $count=1; 29 30 $ticklen_maj=5; 31 $dx_maj=round(sin($aAxisAngle)*$ticklen_maj); 32 $dy_maj=round(cos($aAxisAngle)*$ticklen_maj); 33 $ticklen_min=3; 34 $dx_min=round(sin($aAxisAngle)*$ticklen_min); 35 $dy_min=round(cos($aAxisAngle)*$ticklen_min); 36 37 $aMajPos=array(); 38 $aMajLabel=array(); 39 40 if( $this->supress_first ) 41 $aMajLabel[]=""; 42 else 43 $aMajLabel[]=$start; 44 $yr=$aScale->RelTranslate($start); 45 $xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0]; 46 $yt=$aPos-round($yr*sin($aAxisAngle)); 47 $aMajPos[]=$xt+2*$dx_maj; 48 $aMajPos[]=$yt-$aImg->GetFontheight()/2; 49 $grid[]=$xt; 50 $grid[]=$yt; 51 52 $aImg->SetLineWeight($this->weight); 53 54 for($y=$start; $y<=$limit; $y+=$step,++$count ) { 55 $yr=$aScale->RelTranslate($y); 56 $xt=round($yr*cos($aAxisAngle))+$aScale->scale_abs[0]; 57 $yt=$aPos-round($yr*sin($aAxisAngle)); 58 if( $count % 10 == 0 ) { 59 $grid[]=$xt; 60 $grid[]=$yt; 61 $aMajPos[]=$xt+2*$dx_maj; 62 $aMajPos[]=$yt-$aImg->GetFontheight()/2; 63 if( !$this->supress_tickmarks ) { 64 if( $this->majcolor!="" ) $aImg->PushColor($this->majcolor); 65 $aImg->Line($xt+$dx_maj,$yt+$dy_maj,$xt-$dx_maj,$yt-$dy_maj); 66 if( $this->majcolor!="" ) $aImg->PopColor(); 67 } 68 if( $this->label_formfunc != "" ) { 69 $f=$this->label_formfunc; 70 $l = call_user_func($f,$nextMajor); 71 } 72 else 73 $l = $nextMajor; 74 75 $aMajLabel[]=$l; 76 $nextMajor *= 10; 77 $step *= 10; 78 $count=1; 79 } 80 else 81 if( !$this->supress_minor_tickmarks ) { 82 if( $this->mincolor!="" ) $aImg->PushColor($this->mincolor); 83 $aImg->Line($xt+$dx_min,$yt+$dy_min,$xt-$dx_min,$yt-$dy_min); 84 if( $this->mincolor!="" ) $aImg->PopColor(); 85 } 86 } 87 } 88 } 89 90 class RadarLinearTicks extends Ticks { // extends LinearTicks { 91 92 private $minor_step=1, $major_step=2; 93 private $xlabel_offset=0,$xtick_offset=0; 94 private $maj_ticks_pos=array(); 95 96 97 //--------------- 98 // CONSTRUCTOR 99 function RadarLinearTicks() { 100 // Empty 101 } 102 103 //--------------- 104 // PUBLIC METHODS 105 106 107 // Return major step size in world coordinates 108 function GetMajor() { 109 return $this->major_step; 110 } 111 112 // Return minor step size in world coordinates 113 function GetMinor() { 114 return $this->minor_step; 115 } 116 117 // Set Minor and Major ticks (in world coordinates) 118 function Set($aMajStep,$aMinStep=false) { 119 if( $aMinStep==false ) 120 $aMinStep=$aMajStep; 121 122 if( $aMajStep <= 0 || $aMinStep <= 0 ) { 123 JpGraphError::Raise(" Minor or major step size is 0. Check that you haven't 124 got an accidental SetTextTicks(0) in your code.<p> 125 If this is not the case you might have stumbled upon a bug in JpGraph. 126 Please report this and if possible include the data that caused the 127 problem."); 128 } 129 130 $this->major_step=$aMajStep; 131 $this->minor_step=$aMinStep; 132 $this->is_set = true; 133 } 134 135 function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) { 136 // Prepare to draw linear ticks 137 $maj_step_abs = abs($aScale->scale_factor*$this->major_step); 138 $min_step_abs = abs($aScale->scale_factor*$this->minor_step); 139 $nbrmaj = floor(($aScale->world_abs_size)/$maj_step_abs); 140 $nbrmin = floor(($aScale->world_abs_size)/$min_step_abs); 141 $skip = round($nbrmin/$nbrmaj); // Don't draw minor ontop of major 142 143 // Draw major ticks 144 $ticklen2=$this->major_abs_size; 145 $dx=round(sin($aAxisAngle)*$ticklen2); 146 $dy=round(cos($aAxisAngle)*$ticklen2); 147 $label=$aScale->scale[0]+$this->major_step; 148 149 $aImg->SetLineWeight($this->weight); 150 // NEW 151 $aMajPos = array(); 152 $aMajLabel = array(); 153 for($i=1; $i<=$nbrmaj; ++$i) { 154 $xt=round($i*$maj_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0]; 155 $yt=$aPos-round($i*$maj_step_abs*sin($aAxisAngle)); 156 157 if( $this->label_formfunc != "" ) { 158 $f=$this->label_formfunc; 159 $l = call_user_func($f,$label); 160 } 161 else 162 $l = $label; 163 164 $aMajLabel[]=$l; 165 $label += $this->major_step; 166 $grid[]=$xt; 167 $grid[]=$yt; 168 $aMajPos[($i-1)*2]=$xt+2*$dx; 169 $aMajPos[($i-1)*2+1]=$yt-$aImg->GetFontheight()/2; 170 if( !$this->supress_tickmarks ) { 171 if( $this->majcolor!="" ) $aImg->PushColor($this->majcolor); 172 $aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy); 173 if( $this->majcolor!="" ) $aImg->PopColor(); 174 } 175 } 176 177 // Draw minor ticks 178 $ticklen2=$this->minor_abs_size; 179 $dx=round(sin($aAxisAngle)*$ticklen2); 180 $dy=round(cos($aAxisAngle)*$ticklen2); 181 if( !$this->supress_tickmarks && !$this->supress_minor_tickmarks) { 182 if( $this->mincolor!="" ) $aImg->PushColor($this->mincolor); 183 for($i=1; $i<=$nbrmin; ++$i) { 184 if( ($i % $skip) == 0 ) continue; 185 $xt=round($i*$min_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0]; 186 $yt=$aPos-round($i*$min_step_abs*sin($aAxisAngle)); 187 $aImg->Line($xt+$dx,$yt+$dy,$xt-$dx,$yt-$dy); 188 } 189 if( $this->mincolor!="" ) $aImg->PopColor(); 190 } 191 } 192 } 193 194 195 196 //=================================================== 197 // CLASS RadarAxis 198 // Description: Implements axis for the radar graph 199 //=================================================== 200 class RadarAxis extends AxisPrototype { 201 private $title_color="navy"; 202 public $title=null; 203 //--------------- 204 // CONSTRUCTOR 205 function RadarAxis($img,$aScale,$color=array(0,0,0)) { 206 parent::Axis($img,$aScale,$color); 207 $this->len=$img->plotheight; 208 $this->title = new Text(); 209 $this->title->SetFont(FF_FONT1,FS_BOLD); 210 $this->color = array(0,0,0); 211 } 212 //--------------- 213 // PUBLIC METHODS 214 function SetTickLabels($aLabelArray,$aLabelColorArray=null) { 215 $this->ticks_label = $aLabelArray; 216 $this->ticks_label_colors = $aLabelColorArray; 217 } 218 219 220 // Stroke the axis 221 // $pos = Vertical position of axis 222 // $aAxisAngle = Axis angle 223 // $grid = Returns an array with positions used to draw the grid 224 // $lf = Label flag, TRUE if the axis should have labels 225 function Stroke($pos,$aAxisAngle,&$grid,$title,$lf) { 226 $this->img->SetColor($this->color); 227 228 // Determine end points for the axis 229 $x=round($this->scale->world_abs_size*cos($aAxisAngle)+$this->scale->scale_abs[0]); 230 $y=round($pos-$this->scale->world_abs_size*sin($aAxisAngle)); 231 232 // Draw axis 233 $this->img->SetColor($this->color); 234 $this->img->SetLineWeight($this->weight); 235 if( !$this->hide ) 236 $this->img->Line($this->scale->scale_abs[0],$pos,$x,$y); 237 238 $this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel); 239 $ncolor=0; 240 if( isset($this->ticks_label_colors) ) 241 $ncolor=count($this->ticks_label_colors); 242 243 // Draw labels 244 if( $lf && !$this->hide ) { 245 $this->img->SetFont($this->font_family,$this->font_style,$this->font_size); 246 $this->img->SetTextAlign("left","top"); 247 $this->img->SetColor($this->label_color); 248 249 // majpos contains (x,y) coordinates for labels 250 if( ! $this->hide_labels ) { 251 $n = floor(count($majpos)/2); 252 for($i=0; $i < $n; ++$i) { 253 // Set specific label color if specified 254 if( $ncolor > 0 ) 255 $this->img->SetColor($this->ticks_label_colors[$i % $ncolor]); 256 257 if( $this->ticks_label != null && isset($this->ticks_label[$i]) ) 258 $this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$this->ticks_label[$i]); 259 else 260 $this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$majlabel[$i]); 261 } 262 } 263 } 264 $this->_StrokeAxisTitle($pos,$aAxisAngle,$title); 265 } 266 //--------------- 267 // PRIVATE METHODS 268 269 function _StrokeAxisTitle($pos,$aAxisAngle,$title) { 270 $this->title->Set($title); 271 $marg=6+$this->title->margin; 272 $xt=round(($this->scale->world_abs_size+$marg)*cos($aAxisAngle)+$this->scale->scale_abs[0]); 273 $yt=round($pos-($this->scale->world_abs_size+$marg)*sin($aAxisAngle)); 274 275 // Position the axis title. 276 // dx, dy is the offset from the top left corner of the bounding box that sorrounds the text 277 // that intersects with the extension of the corresponding axis. The code looks a little 278 // bit messy but this is really the only way of having a reasonable position of the 279 // axis titles. 280 if( $this->title->iWordwrap > 0 ) { 281 $title = wordwrap($title,$this->title->iWordwrap,"\n"); 282 } 283 284 $h=$this->img->GetTextHeight($title)*1.2; 285 $w=$this->img->GetTextWidth($title)*1.2; 286 287 while( $aAxisAngle > 2*M_PI ) $aAxisAngle -= 2*M_PI; 288 289 // Around 3 a'clock 290 if( $aAxisAngle>=7*M_PI/4 || $aAxisAngle <= M_PI/4 ) $dx=-0.15; // Small trimming to make the dist to the axis more even 291 // Around 12 a'clock 292 if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dx=($aAxisAngle-M_PI/4)*2/M_PI; 293 // Around 9 a'clock 294 if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dx=1; 295 // Around 6 a'clock 296 if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dx=(1-($aAxisAngle-M_PI*5/4)*2/M_PI); 297 298 if( $aAxisAngle>=7*M_PI/4 ) $dy=(($aAxisAngle-M_PI)-3*M_PI/4)*2/M_PI; 299 if( $aAxisAngle<=M_PI/12 ) $dy=(0.5-$aAxisAngle*2/M_PI); 300 if( $aAxisAngle<=M_PI/4 && $aAxisAngle > M_PI/12) $dy=(1-$aAxisAngle*2/M_PI); 301 if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dy=1; 302 if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dy=(1-($aAxisAngle-3*M_PI/4)*2/M_PI); 303 if( $aAxisAngle>=5*M_PI/4 && $aAxisAngle <= 7*M_PI/4 ) $dy=0; 304 305 if( !$this->hide ) { 306 $this->title->Stroke($this->img,$xt-$dx*$w,$yt-$dy*$h,$title); 307 } 308 } 309 310 311 } // Class 312 313 314 //=================================================== 315 // CLASS RadarGrid 316 // Description: Draws grid for the radar graph 317 //=================================================== 318 class RadarGrid { //extends Grid { 319 private $type='solid'; 320 private $grid_color='#DDDDDD'; 321 private $show=false, $weight=1; 322 323 //------------ 324 // CONSTRUCTOR 325 function RadarGrid() { 326 } 327 328 // PUBLIC METHODS 329 function SetColor($aMajColor) { 330 $this->grid_color = $aMajColor; 331 } 332 333 function SetWeight($aWeight) { 334 $this->weight=$aWeight; 335 } 336 337 // Specify if grid should be dashed, dotted or solid 338 function SetLineStyle($aType) { 339 $this->type = $aType; 340 } 341 342 // Decide if both major and minor grid should be displayed 343 function Show($aShowMajor=true) { 344 $this->show=$aShowMajor; 345 } 346 347 //---------------- 348 // PRIVATE METHODS 349 function Stroke($img,$grid) { 350 if( !$this->show ) return; 351 $nbrticks = count($grid[0])/2; 352 $nbrpnts = count($grid); 353 $img->SetColor($this->grid_color); 354 $img->SetLineWeight($this->weight); 355 for($i=0; $i<$nbrticks; ++$i) { 356 for($j=0; $j<$nbrpnts; ++$j) { 357 $pnts[$j*2]=$grid[$j][$i*2]; 358 $pnts[$j*2+1]=$grid[$j][$i*2+1]; 359 } 360 for($k=0; $k<$nbrpnts; ++$k ){ 361 $l=($k+1)%$nbrpnts; 362 if( $this->type == "solid" ) 363 $img->Line($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1]); 364 elseif( $this->type == "dotted" ) 365 $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],1,6); 366 elseif( $this->type == "dashed" ) 367 $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],2,4); 368 elseif( $this->type == "longdashed" ) 369 $img->DashedLine($pnts[$k*2],$pnts[$k*2+1],$pnts[$l*2],$pnts[$l*2+1],8,6); 370 } 371 $pnts=array(); 372 } 373 } 374 } // Class 375 376 377 //=================================================== 378 // CLASS RadarPlot 379 // Description: Plot a radarplot 380 //=================================================== 381 class RadarPlot { 382 public $mark=null; 383 public $legend=""; 384 private $data=array(); 385 private $fill=false, $fill_color=array(200,170,180); 386 private $color=array(0,0,0); 387 private $weight=1; 388 private $linestyle='solid'; 389 //--------------- 390 // CONSTRUCTOR 391 function RadarPlot($data) { 392 $this->data = $data; 393 $this->mark = new PlotMark(); 394 } 395 396 //--------------- 397 // PUBLIC METHODS 398 function Min() { 399 return Min($this->data); 400 } 401 402 function Max() { 403 return Max($this->data); 404 } 405 406 function SetLegend($legend) { 407 $this->legend=$legend; 408 } 409 410 function SetLineStyle($aStyle) { 411 $this->linestyle=$aStyle; 412 } 413 414 function SetLineWeight($w) { 415 $this->weight=$w; 416 } 417 418 function SetFillColor($aColor) { 419 $this->fill_color = $aColor; 420 $this->fill = true; 421 } 422 423 function SetFill($f=true) { 424 $this->fill = $f; 425 } 426 427 function SetColor($aColor,$aFillColor=false) { 428 $this->color = $aColor; 429 if( $aFillColor ) { 430 $this->SetFillColor($aFillColor); 431 $this->fill = true; 432 } 433 } 434 435 function GetCSIMareas() { 436 JpGraphError::RaiseL(18001); 437 //("Client side image maps not supported for RadarPlots."); 438 } 439 440 function Stroke($img, $pos, $scale, $startangle) { 441 $nbrpnts = count($this->data); 442 $astep=2*M_PI/$nbrpnts; 443 $a=$startangle; 444 445 // Rotate each point to the correct axis-angle 446 // TODO: Update for LogScale 447 for($i=0; $i<$nbrpnts; ++$i) { 448 //$c=$this->data[$i]; 449 $cs=$scale->RelTranslate($this->data[$i]); 450 $x=round($cs*cos($a)+$scale->scale_abs[0]); 451 $y=round($pos-$cs*sin($a)); 452 /* 453 $c=log10($c); 454 $x=round(($c-$scale->scale[0])*$scale->scale_factor*cos($a)+$scale->scale_abs[0]); 455 $y=round($pos-($c-$scale->scale[0])*$scale->scale_factor*sin($a)); 456 */ 457 $pnts[$i*2]=$x; 458 $pnts[$i*2+1]=$y; 459 $a += $astep; 460 } 461 if( $this->fill ) { 462 $img->SetColor($this->fill_color); 463 $img->FilledPolygon($pnts); 464 } 465 $img->SetLineWeight($this->weight); 466 $img->SetColor($this->color); 467 $img->SetLineStyle($this->linestyle); 468 $pnts[]=$pnts[0]; 469 $pnts[]=$pnts[1]; 470 $img->Polygon($pnts); 471 $img->SetLineStyle('solid'); // Reset line style to default 472 // Add plotmarks on top 473 if( $this->mark->show ) { 474 for($i=0; $i < $nbrpnts; ++$i) { 475 $this->mark->Stroke($img,$pnts[$i*2],$pnts[$i*2+1]); 476 } 477 } 478 479 } 480 481 //--------------- 482 // PRIVATE METHODS 483 function GetCount() { 484 return count($this->data); 485 } 486 487 function Legend($graph) { 488 if( $this->legend=="" ) return; 489 if( $this->fill ) 490 $graph->legend->Add($this->legend,$this->fill_color,$this->mark); 491 else 492 $graph->legend->Add($this->legend,$this->color,$this->mark); 493 } 494 495 } // Class 496 497 //=================================================== 498 // CLASS RadarGraph 499 // Description: Main container for a radar graph 500 //=================================================== 501 class RadarGraph extends Graph { 502 public $grid,$axis=null; 503 private $posx,$posy; 504 private $len; 505 private $axis_title=null; 506 //--------------- 507 // CONSTRUCTOR 508 function RadarGraph($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) { 509 $this->Graph($width,$height,$cachedName,$timeout,$inline); 510 $this->posx=$width/2; 511 $this->posy=$height/2; 512 $this->len=min($width,$height)*0.35; 513 $this->SetColor(array(255,255,255)); 514 $this->SetTickDensity(TICKD_NORMAL); 515 $this->SetScale("lin"); 516 $this->SetGridDepth(DEPTH_FRONT); 517 518 } 519 520 //--------------- 521 // PUBLIC METHODS 522 function SupressTickMarks($f=true) { 523 if( ERR_DEPRECATED ) 524 JpGraphError::RaiseL(18002); 525 //('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.'); 526 $this->axis->scale->ticks->SupressTickMarks($f); 527 } 528 529 function HideTickMarks($aFlag=true) { 530 $this->axis->scale->ticks->SupressTickMarks($aFlag); 531 } 532 533 function ShowMinorTickmarks($aFlag=true) { 534 $this->yscale->ticks->SupressMinorTickMarks(!$aFlag); 535 } 536 537 function SetScale($axtype,$ymin=1,$ymax=1,$dummy1=null,$dumy2=null) { 538 if( $axtype != "lin" && $axtype != "log" ) { 539 JpGraphError::RaiseL(18003,$axtype); 540 //("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\""); 541 } 542 if( $axtype=="lin" ) { 543 $this->yscale = new LinearScale($ymin,$ymax); 544 $this->yscale->ticks = new RadarLinearTicks(); 545 $this->yscale->ticks->SupressMinorTickMarks(); 546 } 547 elseif( $axtype=="log" ) { 548 $this->yscale = new LogScale($ymin,$ymax); 549 $this->yscale->ticks = new RadarLogTicks(); 550 } 551 552 $this->axis = new RadarAxis($this->img,$this->yscale); 553 $this->grid = new RadarGrid(); 554 } 555 556 function SetSize($aSize) { 557 if( $aSize < 0.1 || $aSize>1 ) 558 JpGraphError::RaiseL(18004,$aSize); 559 //("Radar Plot size must be between 0.1 and 1. (Your value=$s)"); 560 $this->len=min($this->img->width,$this->img->height)*$aSize/2; 561 } 562 563 function SetPlotSize($aSize) { 564 $this->SetSize($aSize); 565 } 566 567 function SetTickDensity($densy=TICKD_NORMAL,$dummy1=null) { 568 $this->ytick_factor=25; 569 switch( $densy ) { 570 case TICKD_DENSE: 571 $this->ytick_factor=12; 572 break; 573 case TICKD_NORMAL: 574 $this->ytick_factor=25; 575 break; 576 case TICKD_SPARSE: 577 $this->ytick_factor=40; 578 break; 579 case TICKD_VERYSPARSE: 580 $this->ytick_factor=70; 581 break; 582 default: 583 JpGraphError::RaiseL(18005,$densy); 584 //("RadarPlot Unsupported Tick density: $densy"); 585 } 586 } 587 588 function SetPos($px,$py=0.5) { 589 $this->SetCenter($px,$py); 590 } 591 592 function SetCenter($px,$py=0.5) { 593 assert($px > 0 && $py > 0 ); 594 $this->posx=$this->img->width*$px; 595 $this->posy=$this->img->height*$py; 596 } 597 598 function SetColor($c) { 599 $this->SetMarginColor($c); 600 } 601 602 function SetTitles($title) { 603 $this->axis_title = $title; 604 } 605 606 function Add($splot) { 607 $this->plots[]=$splot; 608 } 609 610 function GetPlotsYMinMax($aPlots) { 611 $min=$aPlots[0]->Min(); 612 $max=$aPlots[0]->Max(); 613 foreach( $this->plots as $p ) { 614 $max=max($max,$p->Max()); 615 $min=min($min,$p->Min()); 616 } 617 if( $min < 0 ) 618 JpGraphError::RaiseL(18006,$min); 619 //("Minimum data $min (Radar plots should only be used when all data points > 0)"); 620 return array($min,$max); 621 } 622 623 // Stroke the Radar graph 624 function Stroke($aStrokeFileName="") { 625 $n = count($this->plots); 626 // Set Y-scale 627 if( !$this->yscale->IsSpecified() && count($this->plots)>0 ) { 628 list($min,$max) = $this->GetPlotsYMinMax($this->plots); 629 $this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor); 630 } 631 elseif( $this->yscale->IsSpecified() && 632 ( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) { 633 // The tick calculation will use the user suplied min/max values to determine 634 // the ticks. If auto_ticks is false the exact user specifed min and max 635 // values will be used for the scale. 636 // If auto_ticks is true then the scale might be slightly adjusted 637 // so that the min and max values falls on an even major step. 638 $min = $this->yscale->scale[0]; 639 $max = $this->yscale->scale[1]; 640 $this->yscale->AutoScale($this->img,$min,$max, 641 $this->len/$this->ytick_factor, 642 $this->yscale->auto_ticks); 643 } 644 645 // Set start position end length of scale (in absolute pixels) 646 $this->yscale->SetConstants($this->posx,$this->len); 647 648 // We need as many axis as there are data points 649 $nbrpnts=$this->plots[0]->GetCount(); 650 651 // If we have no titles just number the axis 1,2,3,... 652 if( $this->axis_title==null ) { 653 for($i=0; $i < $nbrpnts; ++$i ) 654 $this->axis_title[$i] = $i+1; 655 } 656 elseif(count($this->axis_title)<$nbrpnts) 657 JpGraphError::RaiseL(18007); 658 //("Number of titles does not match number of points in plot."); 659 for($i=0; $i < $n; ++$i ) 660 if( $nbrpnts != $this->plots[$i]->GetCount() ) 661 JpGraphError::RaiseL(18008); 662 //("Each radar plot must have the same number of data points."); 663 664 if( $this->background_image != "" ) { 665 $this->StrokeFrameBackground(); 666 } 667 else { 668 $this->StrokeFrame(); 669 } 670 $astep=2*M_PI/$nbrpnts; 671 672 // Prepare legends 673 for($i=0; $i < $n; ++$i) 674 $this->plots[$i]->Legend($this); 675 $this->legend->Stroke($this->img); 676 $this->footer->Stroke($this->img); 677 678 if( $this->grid_depth == DEPTH_BACK ) { 679 // Draw axis and grid 680 for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) { 681 $this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0); 682 } 683 } 684 685 // Plot points 686 $a=M_PI/2; 687 for($i=0; $i < $n; ++$i ) 688 $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); 689 690 if( $this->grid_depth != DEPTH_BACK ) { 691 // Draw axis and grid 692 for( $i=0,$a=M_PI/2; $i < $nbrpnts; ++$i, $a += $astep ) { 693 $this->axis->Stroke($this->posy,$a,$grid[$i],$this->axis_title[$i],$i==0); 694 } 695 } 696 $this->grid->Stroke($this->img,$grid); 697 $this->StrokeTitles(); 698 699 // Stroke texts 700 if( $this->texts != null ) { 701 foreach( $this->texts as $t) 702 $t->Stroke($this->img); 703 } 704 705 // Should we do any final image transformation 706 if( $this->iImgTrans ) { 707 if( !class_exists('ImgTrans',false) ) { 708 require_once ('jpgraph_imgtrans.php'); 709 } 710 711 $tform = new ImgTrans($this->img->img); 712 $this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist, 713 $this->iImgTransDirection,$this->iImgTransHighQ, 714 $this->iImgTransMinSize,$this->iImgTransFillColor, 715 $this->iImgTransBorder); 716 } 717 718 // If the filename is given as the special "__handle" 719 // then the image handler is returned and the image is NOT 720 // streamed back 721 if( $aStrokeFileName == _IMG_HANDLER ) { 722 return $this->img->img; 723 } 724 else { 725 // Finally stream the generated picture 726 $this->cache->PutAndStream($this->img,$this->cache_name,$this->inline, 727 $aStrokeFileName); 728 } 729 } 730 } // Class 731 732 /* EOF */ 733 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:27:55 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |