[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 <?php 2 /*======================================================================= 3 // File: JPGRAPH_ERROR.PHP 4 // Description: Error plot extension for JpGraph 5 // Created: 2001-01-08 6 // Author: Johan Persson (johanp@aditus.nu) 7 // Ver: $Id: jpgraph_error.php 18250 2005-05-07 14:13:43Z ralfbecker $ 8 // 9 // License: This code is released under GPL 2.0 10 // Copyright (C) 2001 Johan Persson 11 //======================================================================== 12 */ 13 14 //=================================================== 15 // CLASS ErrorPlot 16 // Description: Error plot with min/max value for 17 // each datapoint 18 //=================================================== 19 class ErrorPlot extends Plot { 20 var $errwidth=2; 21 var $center=false; 22 //--------------- 23 // CONSTRUCTOR 24 function ErrorPlot(&$datay,$datax=false) { 25 $this->Plot($datay,$datax); 26 $this->numpoints /= 2; 27 } 28 //--------------- 29 // PUBLIC METHODS 30 function SetCenter($c=true) { 31 $this->center=$c; 32 } 33 34 // Gets called before any axis are stroked 35 function PreStrokeAdjust(&$graph) { 36 if( $this->center ) { 37 $a=0.5; $b=0.5; 38 ++$this->numpoints; 39 } else { 40 $a=0; $b=0; 41 } 42 $graph->xaxis->scale->ticks->SetXLabelOffset($a); 43 $graph->SetTextScaleOff($b); 44 $graph->xaxis->scale->ticks->SupressMinorTickMarks(); 45 } 46 47 // Method description 48 function Stroke(&$img,&$xscale,&$yscale) { 49 $numpoints=count($this->coords[0])/2; 50 $img->SetColor($this->color); 51 $img->SetLineWeight($this->weight); 52 53 for( $i=0; $i<$numpoints; ++$i) { 54 $xt = $xscale->Translate($i); 55 $yt1 = $yscale->Translate($this->coords[0][$i*2]); 56 $yt2 = $yscale->Translate($this->coords[0][$i*2+1]); 57 $img->Line($xt,$yt1,$xt,$yt2); 58 $img->Line($xt-$this->errwidth,$yt1,$xt+$this->errwidth,$yt1); 59 $img->Line($xt-$this->errwidth,$yt2,$xt+$this->errwidth,$yt2); 60 } 61 return true; 62 } 63 } // Class 64 65 66 //=================================================== 67 // CLASS ErrorLinePlot 68 // Description: Combine a line and error plot 69 //=================================================== 70 class ErrorLinePlot extends ErrorPlot { 71 var $line=null; 72 //--------------- 73 // CONSTRUCTOR 74 function ErrorLinePlot(&$datay,$datax=false) { 75 $this->ErrorPlot($datay); 76 // Calculate line coordinates as the average of the error limits 77 for($i=0; $i<count($datay); $i+=2 ) { 78 $ly[]=($datay[$i]+$datay[$i+1])/2; 79 } 80 $this->line=new LinePlot($ly); 81 } 82 83 //--------------- 84 // PUBLIC METHODS 85 function Legend(&$graph) { 86 if( $this->legend != "" ) 87 $graph->legend->Add($this->legend,$this->color); 88 $this->line->Legend($graph); 89 } 90 91 function Stroke(&$img,&$xscale,&$yscale) { 92 parent::Stroke($img,$xscale,$yscale); 93 $this->line->Stroke($img,$xscale,$yscale); 94 } 95 } // Class 96 97 /* EOF */ 98 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |