Changeset 265 for trunk/client/modules/Elezioni/grafici/jpgraph_error.php
- Timestamp:
- Apr 13, 2019, 8:05:15 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/client/modules/Elezioni/grafici/jpgraph_error.php
r2 r265 1 1 <?php 2 2 /*======================================================================= 3 // File:JPGRAPH_ERROR.PHP4 // Description:Error plot extension for JpGraph5 // Created:2001-01-086 // Ver: $Id: jpgraph_error.php 781 2006-10-08 08:07:47Z ljp $7 //8 // Copyright (c) Aditus Consulting. All rights reserved.9 //========================================================================10 */11 3 // File: JPGRAPH_ERROR.PHP 4 // Description: Error plot extension for JpGraph 5 // Created: 2001-01-08 6 // Ver: $Id: jpgraph_error.php 1106 2009-02-22 20:16:35Z ljp $ 7 // 8 // Copyright (c) Asial Corporation. All rights reserved. 9 //======================================================================== 10 */ 11 12 12 //=================================================== 13 13 // CLASS ErrorPlot … … 17 17 class ErrorPlot extends Plot { 18 18 private $errwidth=2; 19 //--------------- 20 // CONSTRUCTOR 21 function ErrorPlot($datay,$datax=false) { 22 $this->Plot($datay,$datax); 23 $this->numpoints /= 2; 19 20 //--------------- 21 // CONSTRUCTOR 22 function __construct($datay,$datax=false) { 23 parent::__construct($datay,$datax); 24 $this->numpoints /= 2; 24 25 } 25 //---------------26 // PUBLIC METHODS27 26 //--------------- 27 // PUBLIC METHODS 28 28 29 // Gets called before any axis are stroked 29 30 function PreStrokeAdjust($graph) { 30 31 32 ++$this->numpoints; 33 34 35 36 37 $graph->SetTextScaleOff($b); 38 31 if( $this->center ) { 32 $a=0.5; $b=0.5; 33 ++$this->numpoints; 34 } else { 35 $a=0; $b=0; 36 } 37 $graph->xaxis->scale->ticks->SetXLabelOffset($a); 38 $graph->SetTextScaleOff($b); 39 //$graph->xaxis->scale->ticks->SupressMinorTickMarks(); 39 40 } 40 41 41 42 // Method description 42 43 function Stroke($img,$xscale,$yscale) { 43 44 45 $img->SetLineWeight($this->weight); 44 $numpoints=count($this->coords[0])/2; 45 $img->SetColor($this->color); 46 $img->SetLineWeight($this->weight); 46 47 47 48 49 50 //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");51 52 53 54 else 55 48 if( isset($this->coords[1]) ) { 49 if( count($this->coords[1])!=$numpoints ) 50 JpGraphError::RaiseL(2003,count($this->coords[1]),$numpoints); 51 //("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints"); 52 else 53 $exist_x = true; 54 } 55 else 56 $exist_x = false; 56 57 57 58 if( $exist_x ) 59 60 else 61 58 for( $i=0; $i<$numpoints; ++$i) { 59 if( $exist_x ) 60 $x=$this->coords[1][$i]; 61 else 62 $x=$i; 62 63 63 if( !is_numeric($x) || 64 65 66 64 if( !is_numeric($x) || 65 !is_numeric($this->coords[0][$i*2]) || !is_numeric($this->coords[0][$i*2+1]) ) { 66 continue; 67 } 67 68 68 69 70 71 72 73 74 } 75 69 $xt = $xscale->Translate($x); 70 $yt1 = $yscale->Translate($this->coords[0][$i*2]); 71 $yt2 = $yscale->Translate($this->coords[0][$i*2+1]); 72 $img->Line($xt,$yt1,$xt,$yt2); 73 $img->Line($xt-$this->errwidth,$yt1,$xt+$this->errwidth,$yt1); 74 $img->Line($xt-$this->errwidth,$yt2,$xt+$this->errwidth,$yt2); 75 } 76 return true; 76 77 } 77 78 } // Class … … 86 87 class ErrorLinePlot extends ErrorPlot { 87 88 public $line=null; 88 //---------------89 // CONSTRUCTOR90 function ErrorLinePlot($datay,$datax=false) {91 $this->ErrorPlot($datay,$datax);92 93 94 95 96 } 97 89 //--------------- 90 // CONSTRUCTOR 91 function __construct($datay,$datax=false) { 92 parent::__construct($datay,$datax); 93 // Calculate line coordinates as the average of the error limits 94 $n = count($datay); 95 for($i=0; $i < $n; $i+=2 ) { 96 $ly[]=($datay[$i]+$datay[$i+1])/2; 97 } 98 $this->line=new LinePlot($ly,$datax); 98 99 } 99 100 100 //---------------101 // PUBLIC METHODS101 //--------------- 102 // PUBLIC METHODS 102 103 function Legend($graph) { 103 104 105 104 if( $this->legend != "" ) 105 $graph->legend->Add($this->legend,$this->color); 106 $this->line->Legend($graph); 106 107 } 107 108 108 109 function Stroke($img,$xscale,$yscale) { 109 110 110 parent::Stroke($img,$xscale,$yscale); 111 $this->line->Stroke($img,$xscale,$yscale); 111 112 } 112 113 } // Class … … 119 120 class LineErrorPlot extends ErrorPlot { 120 121 public $line=null; 121 //---------------122 // CONSTRUCTOR122 //--------------- 123 // CONSTRUCTOR 123 124 // Data is (val, errdeltamin, errdeltamax) 124 function LineErrorPlot($datay,$datax=false) {125 126 127 128 129 //('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3');130 131 132 133 134 135 } 136 $this->ErrorPlot($ey,$datax);137 125 function __construct($datay,$datax=false) { 126 $ly=array(); $ey=array(); 127 $n = count($datay); 128 if( $n % 3 != 0 ) { 129 JpGraphError::RaiseL(4002); 130 //('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3'); 131 } 132 for($i=0; $i < $n; $i+=3 ) { 133 $ly[]=$datay[$i]; 134 $ey[]=$datay[$i]+$datay[$i+1]; 135 $ey[]=$datay[$i]+$datay[$i+2]; 136 } 137 parent::__construct($ey,$datax); 138 $this->line=new LinePlot($ly,$datax); 138 139 } 139 140 140 //---------------141 // PUBLIC METHODS141 //--------------- 142 // PUBLIC METHODS 142 143 function Legend($graph) { 143 144 145 144 if( $this->legend != "" ) 145 $graph->legend->Add($this->legend,$this->color); 146 $this->line->Legend($graph); 146 147 } 147 148 148 149 function Stroke($img,$xscale,$yscale) { 149 150 150 parent::Stroke($img,$xscale,$yscale); 151 $this->line->Stroke($img,$xscale,$yscale); 151 152 } 152 153 } // Class
Note:
See TracChangeset
for help on using the changeset viewer.