⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jpgraph.php

📁 一个基于web的开源项目管理工具
💻 PHP
📖 第 1 页 / 共 5 页
字号:
	$this->footer->iBottomMargin += $aShadowWidth;	$this->footer->iRightMargin += $aShadowWidth;    }    // Specify x,y scale. Note that if you manually specify the scale    // you must also specify the tick distance with a call to Ticks::Set()    function SetScale($aAxisType,$aYMin=1,$aYMax=1,$aXMin=1,$aXMax=1) {	$this->axtype = $aAxisType;	if( $aYMax < $aYMin || $aXMax < $aXMin )	    JpGraphError::RaiseL(25020);//('Graph::SetScale(): Specified Max value must be larger than the specified Min value.');	$yt=substr($aAxisType,-3,3);	if( $yt=="lin" )	    $this->yscale = new LinearScale($aYMin,$aYMax);	elseif( $yt == "int" ) {	    $this->yscale = new LinearScale($aYMin,$aYMax);	    $this->yscale->SetIntScale();	}	elseif( $yt=="log" )	    $this->yscale = new LogScale($aYMin,$aYMax);	else	    JpGraphError::RaiseL(25021,$aAxisType);//("Unknown scale specification for Y-scale. ($aAxisType)");				$xt=substr($aAxisType,0,3);	if( $xt == "lin" || $xt == "tex" ) {	    $this->xscale = new LinearScale($aXMin,$aXMax,"x");	    $this->xscale->textscale = ($xt == "tex");	}	elseif( $xt == "int" ) {	    $this->xscale = new LinearScale($aXMin,$aXMax,"x");	    $this->xscale->SetIntScale();	}	elseif( $xt == "dat" ) {	    $this->xscale = new DateScale($aXMin,$aXMax,"x");	}	elseif( $xt == "log" )	    $this->xscale = new LogScale($aXMin,$aXMax,"x");	else	    JpGraphError::RaiseL(25022,$aAxisType);//(" Unknown scale specification for X-scale. ($aAxisType)");	$this->xaxis = new Axis($this->img,$this->xscale);	$this->yaxis = new Axis($this->img,$this->yscale);	$this->xgrid = new Grid($this->xaxis);	$this->ygrid = new Grid($this->yaxis);		$this->ygrid->Show();			    }	    // Specify secondary Y scale    function SetY2Scale($aAxisType="lin",$aY2Min=1,$aY2Max=1) {	if( $aAxisType=="lin" ) 	    $this->y2scale = new LinearScale($aY2Min,$aY2Max);	elseif( $aAxisType == "int" ) {	    $this->y2scale = new LinearScale($aY2Min,$aY2Max);	    $this->y2scale->SetIntScale();	}	elseif( $aAxisType=="log" ) {	    $this->y2scale = new LogScale($aY2Min,$aY2Max);	}	else JpGraphError::RaiseL(25023,$aAxisType);//("JpGraph: Unsupported Y2 axis type: $aAxisType\nMust be one of (lin,log,int)");				$this->y2axis = new Axis($this->img,$this->y2scale);	$this->y2axis->scale->ticks->SetDirection(SIDE_LEFT); 	$this->y2axis->SetLabelSide(SIDE_RIGHT); 	$this->y2axis->SetPos('max');	$this->y2axis->SetTitleSide(SIDE_RIGHT);			// Deafult position is the max x-value	$this->y2grid = new Grid($this->y2axis);							    }    // Set the delta position (in pixels) between the multiple Y-axis    function SetYDeltaDist($aDist) {	$this->iYAxisDeltaPos = $aDist;    }	    // Specify secondary Y scale    function SetYScale($aN,$aAxisType="lin",$aYMin=1,$aYMax=1) {	if( $aAxisType=="lin" ) 	    $this->ynscale[$aN] = new LinearScale($aYMin,$aYMax);	elseif( $aAxisType == "int" ) {	    $this->ynscale[$aN] = new LinearScale($aYMin,$aYMax);	    $this->ynscale[$aN]->SetIntScale();	}	elseif( $aAxisType=="log" ) {	    $this->ynscale[$aN] = new LogScale($aYMin,$aYMax);	}	else JpGraphError::RaiseL(25024,$aAxisType);//("JpGraph: Unsupported Y axis type: $aAxisType\nMust be one of (lin,log,int)");				$this->ynaxis[$aN] = new Axis($this->img,$this->ynscale[$aN]);	$this->ynaxis[$aN]->scale->ticks->SetDirection(SIDE_LEFT); 	$this->ynaxis[$aN]->SetLabelSide(SIDE_RIGHT);     }	    // Specify density of ticks when autoscaling 'normal', 'dense', 'sparse', 'verysparse'    // The dividing factor have been determined heuristically according to my aesthetic     // sense (or lack off) y.m.m.v !    function SetTickDensity($aYDensity=TICKD_NORMAL,$aXDensity=TICKD_NORMAL) {	$this->xtick_factor=30;	$this->ytick_factor=25;			switch( $aYDensity ) {	    case TICKD_DENSE:		$this->ytick_factor=12;					break;	    case TICKD_NORMAL:		$this->ytick_factor=25;					break;	    case TICKD_SPARSE:		$this->ytick_factor=40;					break;	    case TICKD_VERYSPARSE:		$this->ytick_factor=100;					break;			    default:		JpGraphError::RaiseL(25025,$densy);//("JpGraph: Unsupported Tick density: $densy");	}	switch( $aXDensity ) {	    case TICKD_DENSE:		$this->xtick_factor=15;									break;	    case TICKD_NORMAL:		$this->xtick_factor=30;					break;	    case TICKD_SPARSE:		$this->xtick_factor=45;							break;	    case TICKD_VERYSPARSE:		$this->xtick_factor=60;										break;			    default:		JpGraphError::RaiseL(25025,$densx);//("JpGraph: Unsupported Tick density: $densx");	}		    }	    // Get a string of all image map areas	    function GetCSIMareas() {	if( !$this->iHasStroked )	    $this->Stroke(_CSIM_SPECIALFILE);	$csim = $this->title->GetCSIMAreas();	$csim .= $this->subtitle->GetCSIMAreas();	$csim .= $this->subsubtitle->GetCSIMAreas();	$csim .= $this->legend->GetCSIMAreas();	if( $this->y2axis != NULL ) {	    $csim .= $this->y2axis->title->GetCSIMAreas();	}	if( $this->texts != null ) {	    $n = count($this->texts);	    for($i=0; $i < $n; ++$i ) {		$csim .= $this->texts[$i]->GetCSIMAreas();	    }	}	if( $this->y2texts != null && $this->y2scale != null ) {	    $n = count($this->y2texts);	    for($i=0; $i < $n; ++$i ) {		$csim .= $this->y2texts[$i]->GetCSIMAreas();	    }	}	if( $this->yaxis != null && $this->xaxis != null ) {	    $csim .= $this->yaxis->title->GetCSIMAreas();		    $csim .= $this->xaxis->title->GetCSIMAreas();	}	$n = count($this->plots);	for( $i=0; $i < $n; ++$i ) 	    $csim .= $this->plots[$i]->GetCSIMareas();	$n = count($this->y2plots);	for( $i=0; $i < $n; ++$i ) 	    $csim .= $this->y2plots[$i]->GetCSIMareas();	$n = count($this->ynaxis);	for( $i=0; $i < $n; ++$i ) {	    $m = count($this->ynplots[$i]); 	    for($j=0; $j < $m; ++$j ) {		$csim .= $this->ynplots[$i][$j]->GetCSIMareas();	    }	}	$n = count($this->iTables);	for( $i=0; $i < $n; ++$i ) {	    $csim .= $this->iTables[$i]->GetCSIMareas();	}	return $csim;    }	    // Get a complete <MAP>..</MAP> tag for the final image map    function GetHTMLImageMap($aMapName) {	//$im = "<map name=\"$aMapName\" id=\"$aMapName\">\n";	$im = "<map name=\"$aMapName\" />\n";	$im .= $this->GetCSIMareas();	$im .= "</map>"; 	return $im;    }    function CheckCSIMCache($aCacheName,$aTimeOut=60) {	global $_SERVER;	if( $aCacheName=='auto' )	    $aCacheName=basename($_SERVER['PHP_SELF']);	$this->csimcachename = CSIMCACHE_DIR.$aCacheName;	$this->csimcachetimeout = $aTimeOut;	// First determine if we need to check for a cached version	// This differs from the standard cache in the sense that the	// image and CSIM map HTML file is written relative to the directory	// the script executes in and not the specified cache directory.	// The reason for this is that the cache directory is not necessarily	// accessible from the HTTP server.	if( $this->csimcachename != '' ) {	    $dir = dirname($this->csimcachename);	    $base = basename($this->csimcachename);	    $base = strtok($base,'.');	    $suffix = strtok('.');	    $basecsim = $dir.'/'.$base.'_csim_.html';	    $baseimg = $dir.'/'.$base.'.'.$this->img->img_format;	    $timedout=false;			    // Does it exist at all ?	    	    if( file_exists($basecsim) && file_exists($baseimg) ) {		// Check that it hasn't timed out		$diff=time()-filemtime($basecsim);		if( $this->csimcachetimeout>0 && ($diff > $this->csimcachetimeout*60) ) {		    $timedout=true;		    @unlink($basecsim);		    @unlink($baseimg);		}		else {		    if ($fh = @fopen($basecsim, "r")) {			fpassthru($fh);			return true;		    }		    else			JpGraphError::RaiseL(25027,$basecsim);//(" Can't open cached CSIM \"$basecsim\" for reading.");		}	    }	}	return false;    }    function StrokeCSIM($aScriptName='auto',$aCSIMName='',$aBorder=0) {	if( $aCSIMName=='' ) {	    // create a random map name	    srand ((double) microtime() * 1000000);	    $r = rand(0,100000);	    $aCSIMName='__mapname'.$r.'__';	}	if( $aScriptName=='auto' )	    $aScriptName=basename($_SERVER['PHP_SELF']);	if( empty($_GET[_CSIM_DISPLAY]) ) {	    // First determine if we need to check for a cached version	    // This differs from the standard cache in the sense that the	    // image and CSIM map HTML file is written relative to the directory	    // the script executes in and not the specified cache directory.	    // The reason for this is that the cache directory is not necessarily	    // accessible from the HTTP server.	    if( $this->csimcachename != '' ) {		$dir = dirname($this->csimcachename);		$base = basename($this->csimcachename);		$base = strtok($base,'.');		$suffix = strtok('.');		$basecsim = $dir.'/'.$base.'_csim_.html';		$baseimg = $base.'.'.$this->img->img_format;		// Check that apache can write to directory specified		if( file_exists($dir) && !is_writeable($dir) ) {		    JpgraphError::RaiseL(25028,$dir);//('Apache/PHP does not have permission to write to the CSIM cache directory ('.$dir.'). Check permissions.');		}				// Make sure directory exists		$this->cache->MakeDirs($dir);		// Write the image file		$this->Stroke(CSIMCACHE_DIR.$baseimg);		// Construct wrapper HTML and write to file and send it back to browser		$htmlwrap = $this->GetHTMLImageMap($aCSIMName)."\n".		    '<img src="'.htmlentities(CSIMCACHE_HTTP_DIR.$baseimg).'" ismap usemap="#'.$aCSIMName.'" border='.$aBorder.' width='.$this->img->width.' height='.$this->img->height." alt=\"\" />\n";		if($fh =  @fopen($basecsim,'w') ) {		    fwrite($fh,$htmlwrap);		    fclose($fh);		    echo $htmlwrap;		}		else		    JpGraphError::RaiseL(25029,$basecsim);//(" Can't write CSIM \"$basecsim\" for writing. Check free space and permissions.");	    }	    else {		if( $aScriptName=='' ) {		    JpGraphError::RaiseL(25030);//('Missing script name in call to StrokeCSIM(). You must specify the name of the actual image script as the first parameter to StrokeCSIM().');		    exit();		}				// This is a JPGRAPH internal defined that prevents		// us from recursively coming here again		$urlarg='?'._CSIM_DISPLAY.'=1';		// Now reconstruct any user URL argument		reset($_GET);		while( list($key,$value) = each($_GET) ) {		    if( is_array($value) ) {			$n = count($value);			for( $i=0; $i < $n; ++$i ) {			    $urlarg .= '&'.$key.'%5B%5D='.urlencode($value[$i]);			}		    }		    else {			$urlarg .= '&'.$key.'='.urlencode($value);		    }		}		// It's not ideal to convert POST argument to GET arguments		// but there is little else we can do. One idea for the 		// future might be recreate the POST header in case.		reset($_POST);		while( list($key,$value) = each($_POST) ) {		    if( is_array($value) ) {			$n = count($value);			for( $i=0; $i < $n; ++$i ) {			    $urlarg .= '&'.$key.'%5B%5D='.urlencode($value[$i]);			}		    }		    else {			$urlarg .= '&'.$key.'='.urlencode($value);		    }		}		echo $this->GetHTMLImageMap($aCSIMName);		echo "<img src='".htmlentities($aScriptName.$urlarg)."' ismap usemap='#".$aCSIMName.'\' border='.$aBorder.'  width='.$this->img->width.' height='.$this->img->height." alt=\"\" />\n";	    }	}	else {	    $this->Stroke();	}    }    function GetTextsYMinMax($aY2=false) {	if( $aY2 ) 	    $txts = $this->y2texts;	else	    $txts = $this->texts;	$n = count($txts);	$min=null;	$max=null;	for( $i=0; $i < $n; ++$i ) {	    if( $txts[$i]->iScalePosY !== null && 		$txts[$i]->iScalePosX !== null  ) {		if( $min === null  ) {		    $min = $max = $txts[$i]->iScalePosY ;		}		else {		    $min = min($min,$txts[$i]->iScalePosY);		    $max = max($max,$txts[$i]->iScalePosY);		}	    }	}	if( $min !== null ) {	    return array($min,$max);	}	else	    return null;    }    function GetTextsXMinMax($aY2=false) {	if( $aY2 ) 	    $txts = $this->y2texts;	else	    $txts = $this->texts;	$n = count($txts);	$min=null;	$max=null;	for( $i=0; $i < $n; ++$i ) {	    if( $txts[$i]->iScalePosY !== null && 		$txts[$i]->iScalePosX !== null  ) {		if( $min === null  ) {		    $min = $max = $txts[$i]->iScalePosX ;		}		else {		    $min = min($min,$txts[$i]->iScalePosX);		    $max = max($max,$txts[$i]->iScalePosX);		}	    }	}	if( $min !== null ) {	    return array($min,$max);	}	else	    return null;    }    function GetXMinMax() {	list($min,$ymin) = $this->plots[0]->Min();	list($max,$ymax) = $this->plots[0]->Max();	foreach( $this->plots as $p ) {	    list($xmin,$ymin) = $p->Min();	    list($xmax,$ymax) = $p->Max();				    $min = Min($xmin,$min);	    $max = Max($xmax,$max);	}	if( $this->y2axis != null ) {	    foreach( $this->y2plots as $p ) {		list($xmin,$ymin) = $p->Min();		list($xmax,$ymax) = $p->Max();					$min = Min($xmin,$min);		$max = Max($xmax,$max);	    }		    	}	$n = count($this->ynaxis);	for( $i=0; $i < $n; ++$i ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -