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

📄 jpgraph.php

📁 最近在做软交换时研究的一个软交换的东东
💻 PHP
📖 第 1 页 / 共 5 页
字号:
		$lres = $this->GetLinesYMinMax($this->y2lines);		if( is_array($lres) ) {		    list($linmin,$linmax) = $lres ;		    $min = min($min,$linmin);		    $max = max($max,$linmax);		}		$tres = $this->GetTextsYMinMax(true);		if( is_array($tres) ) {		    list($tmin,$tmax) = $tres ;		    $min = min($min,$tmin);		    $max = max($max,$tmax);		}		$this->y2scale->AutoScale($this->img,$min,$max,$this->img->plotheight/$this->ytick_factor);	    }				    elseif( $this->y2scale->IsSpecified() && 		    ( $this->y2scale->auto_ticks || !$this->y2scale->ticks->IsSpecified()) ) {		// The tick calculation will use the user suplied min/max values to determine		// the ticks. If auto_ticks is false the exact user specifed min and max		// values will be used for the scale. 		// If auto_ticks is true then the scale might be slightly adjusted		// so that the min and max values falls on an even major step.		$min = $this->y2scale->scale[0];		$max = $this->y2scale->scale[1];		$this->y2scale->AutoScale($this->img,$min,$max,					  $this->img->plotheight/$this->ytick_factor,					  $this->y2scale->auto_ticks);	    }	}					//Check if we should autoscale x-axis	if( !$this->xscale->IsSpecified() ) {	    if( substr($this->axtype,0,4) == "text" ) {		$max=0;		foreach( $this->plots as $p ) {		    $max=max($max,$p->numpoints-1);		}		$min=0;		if( $this->y2axis != null ) {		    foreach( $this->y2plots as $p ) {			$max=max($max,$p->numpoints-1);		    }		    		}		$this->xscale->Update($this->img,$min,$max);		$this->xscale->ticks->Set($this->xaxis->tick_step,1);		$this->xscale->ticks->SupressMinorTickMarks();	    }	    else {		list($min,$max) = $this->GetXMinMax();		$lres = $this->GetLinesXMinMax($this->lines);		if( $lres ) {		    list($linmin,$linmax) = $lres ;		    $min = min($min,$linmin);		    $max = max($max,$linmax);		}		$lres = $this->GetLinesXMinMax($this->y2lines);		if( $lres ) {		    list($linmin,$linmax) = $lres ;		    $min = min($min,$linmin);		    $max = max($max,$linmax);		}		$tres = $this->GetTextsXMinMax();		if( $tres ) {		    list($tmin,$tmax) = $tres ;		    $min = min($min,$tmin);		    $max = max($max,$tmax);		}		$tres = $this->GetTextsXMinMax(true);		if( $tres ) {		    list($tmin,$tmax) = $tres ;		    $min = min($min,$tmin);		    $max = max($max,$tmax);		}		$this->xscale->AutoScale($this->img,$min,$max,$this->img->plotwidth/$this->xtick_factor);	    }				    //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale	    if( !is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos) )	    	$this->yaxis->SetPos($this->xscale->GetMinVal());	    if( $this->y2axis != null ) {		if( !is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos) )		    $this->y2axis->SetPos($this->xscale->GetMaxVal());		$this->y2axis->SetTitleSide(SIDE_RIGHT);	    }	}		elseif( $this->xscale->IsSpecified() &&  		( $this->xscale->auto_ticks || !$this->xscale->ticks->IsSpecified()) ) {	    // The tick calculation will use the user suplied min/max values to determine	    // the ticks. If auto_ticks is false the exact user specifed min and max	    // values will be used for the scale. 	    // If auto_ticks is true then the scale might be slightly adjusted	    // so that the min and max values falls on an even major step.	    $min = $this->xscale->scale[0];	    $max = $this->xscale->scale[1];	    $this->xscale->AutoScale($this->img,$min,$max,				     $this->img->plotwidth/$this->xtick_factor,				     false);	    if( $this->y2axis != null ) {		if( !is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos) )		    $this->y2axis->SetPos($this->xscale->GetMaxVal());		$this->y2axis->SetTitleSide(SIDE_RIGHT);	    }	}			// If we have a negative values and x-axis position is at 0	// we need to supress the first and possible the last tick since	// they will be drawn on top of the y-axis (and possible y2 axis)	// The test below might seem strange the reasone being that if	// the user hasn't specified a value for position this will not	// be set until we do the stroke for the axis so as of now it	// is undefined.	// For X-text scale we ignore all this since the tick are usually	// much further in and not close to the Y-axis. Hence the test 	// for 'text'		if( ($this->yaxis->pos==$this->xscale->GetMinVal() || 	     (is_string($this->yaxis->pos) && $this->yaxis->pos=='min')) &&  	    !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && 	    substr($this->axtype,0,4) != 'text' && $this->xaxis->pos!="min" ) {	    //$this->yscale->ticks->SupressZeroLabel(false);	    $this->xscale->ticks->SupressFirst();	    if( $this->y2axis != null ) {		$this->xscale->ticks->SupressLast();	    }	}	elseif( !is_numeric($this->yaxis->pos) && $this->yaxis->pos=='max' ) {	    $this->xscale->ticks->SupressLast();	}		if( !$_csim ) {	    $this->StrokePlotArea();	}	$this->StrokeAxis();	// Stroke bands	if( $this->bands != null && !$_csim) 	    for($i=0; $i < count($this->bands); ++$i) {		// Stroke all bands that asks to be in the background		if( $this->bands[$i]->depth == DEPTH_BACK )		    $this->bands[$i]->Stroke($this->img,$this->xscale,$this->yscale);	    }	if( $this->y2bands != null && $this->y2scale != null && !$_csim )	    for($i=0; $i < count($this->y2bands); ++$i) {		// Stroke all bands that asks to be in the foreground		if( $this->y2bands[$i]->depth == DEPTH_BACK )		    $this->y2bands[$i]->Stroke($this->img,$this->xscale,$this->y2scale);	    }	if( $this->grid_depth == DEPTH_BACK && !$_csim) {	    $this->ygrid->Stroke();	    $this->xgrid->Stroke();	}					// Stroke Y2-axis	if( $this->y2axis != null && !$_csim) {			    $this->y2axis->Stroke($this->xscale); 					    $this->y2grid->Stroke();	}			$oldoff=$this->xscale->off;	if(substr($this->axtype,0,4)=="text") {	    $this->xscale->off += 		ceil($this->xscale->scale_factor*$this->text_scale_off*$this->xscale->ticks->minor_step);	}	if( $this->iDoClipping ) {	    $oldimage = $this->img->CloneCanvasH();	}	if( ! $this->y2orderback ) {	    // Stroke all plots for Y1 axis	    for($i=0; $i < count($this->plots); ++$i) {		$this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale);		$this->plots[$i]->StrokeMargin($this->img);	    }							}	// Stroke all plots for Y2 axis	if( $this->y2scale != null )	    for($i=0; $i< count($this->y2plots); ++$i ) {			$this->y2plots[$i]->Stroke($this->img,$this->xscale,$this->y2scale);	    }			if( $this->y2orderback ) {	    // Stroke all plots for Y1 axis	    for($i=0; $i < count($this->plots); ++$i) {		$this->plots[$i]->Stroke($this->img,$this->xscale,$this->yscale);		$this->plots[$i]->StrokeMargin($this->img);	    }							}	if( $this->iDoClipping ) {	    // Clipping only supports graphs at 0 and 90 degrees	    if( $this->img->a == 0 ) {		$this->img->CopyCanvasH($oldimage,$this->img->img,					$this->img->left_margin,$this->img->top_margin,					$this->img->left_margin,$this->img->top_margin,					$this->img->plotwidth+1,$this->img->plotheight);	    }	    elseif( $this->img->a == 90 ) {		$adj = ($this->img->height - $this->img->width)/2;		$this->img->CopyCanvasH($oldimage,$this->img->img,					$this->img->bottom_margin-$adj,$this->img->left_margin+$adj,					$this->img->bottom_margin-$adj,$this->img->left_margin+$adj,					$this->img->plotheight+1,$this->img->plotwidth);	    }	    else {		JpGraphError::Raise('You have enabled clipping. Cliping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (='.$this->img->a.' degrees) or disable clipping.');	    }	    $this->img->Destroy();	    $this->img->SetCanvasH($oldimage);	}	$this->xscale->off=$oldoff;			if( $this->grid_depth == DEPTH_FRONT && !$_csim ) {	    $this->ygrid->Stroke();	    $this->xgrid->Stroke();	}	// Stroke bands	if( $this->bands!= null )	    for($i=0; $i < count($this->bands); ++$i) {		// Stroke all bands that asks to be in the foreground		if( $this->bands[$i]->depth == DEPTH_FRONT )		    $this->bands[$i]->Stroke($this->img,$this->xscale,$this->yscale);	    }	if( $this->y2bands!= null && $this->y2scale != null )	    for($i=0; $i < count($this->y2bands); ++$i) {		// Stroke all bands that asks to be in the foreground		if( $this->y2bands[$i]->depth == DEPTH_FRONT )		    $this->y2bands[$i]->Stroke($this->img,$this->xscale,$this->y2scale);	    }	// Stroke any lines added	if( $this->lines != null ) {	    for($i=0; $i < count($this->lines); ++$i) {		$this->lines[$i]->Stroke($this->img,$this->xscale,$this->yscale);	    }	}	if( $this->y2lines != null && $this->y2scale != null ) {	    for($i=0; $i < count($this->y2lines); ++$i) {		$this->y2lines[$i]->Stroke($this->img,$this->xscale,$this->y2scale);	    }	}	// Finally draw the axis again since some plots may have nagged	// the axis in the edges.	if( !$_csim )	    $this->StrokeAxis();	if( $this->y2scale != null && !$_csim ) 	    $this->y2axis->Stroke($this->xscale); 				if( !$_csim ) {	    $this->StrokePlotBox();	}			// The titles and legends never gets rotated so make sure	// that the angle is 0 before stroking them					$aa = $this->img->SetAngle(0);	$this->StrokeTitles();	$this->footer->Stroke($this->img);	$this->legend->Stroke($this->img);			$this->StrokeTexts();		$this->img->SetAngle($aa);		if( !$_csim ) {	    $this->img->SetAngle($aa);					    // Draw an outline around the image map		    if(_JPG_DEBUG) {		$this->DisplayClientSideaImageMapAreas();			    }	    	    // Adjust the appearance of the image	    $this->AdjustSaturationBrightnessContrast();	    // Should we do any final image transformation	    if( $this->iImgTrans ) {		if( !class_exists('ImgTrans') ) {		    require_once('jpgraph_imgtrans.php');		    //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.');		}	       		$tform = new ImgTrans($this->img->img);		$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,						 $this->iImgTransDirection,$this->iImgTransHighQ,						 $this->iImgTransMinSize,$this->iImgTransFillColor,						 $this->iImgTransBorder);	    }	    // If the filename is given as the special "__handle"	    // then the image handler is returned and the image is NOT	    // streamed back	    if( $aStrokeFileName == _IMG_HANDLER ) {		return $this->img->img;	    }	    else {		// Finally stream the generated picture							$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);			    }	}    }//---------------// PRIVATE METHODS	    function StrokeAxis() {			// Stroke axis	if( $this->iAxisStyle != AXSTYLE_SIMPLE ) {	    switch( $this->iAxisStyle ) {	        case AXSTYLE_BOXIN :	            $toppos = SIDE_DOWN;		    $bottompos = SIDE_UP;	            $leftpos = SIDE_RIGHT;	            $rightpos = SIDE_LEFT;	            break;		case AXSTYLE_BOXOUT :		    $toppos = SIDE_UP;	            $bottompos = SIDE_DOWN;	    	            $leftpos = SIDE_LEFT;		    $rightpos = SIDE_RIGHT;	            break;		case AXSTYLE_YBOXIN:	            $toppos = -100;		    $bottompos = SIDE_UP;	            $leftpos = SIDE_RIGHT;	            $rightpos = SIDE_LEFT;		    break;		case AXSTYLE_YBOXOUT:		    $toppos = -100;	            $bottompos = SIDE_DOWN;	    	            $leftpos = SIDE_LEFT;		    $rightpos = SIDE_RIGHT;		    break;		default:	            JpGRaphError::Raise('Unknown AxisStyle() : '.$this->iAxisStyle);	            break;	    }	    $this->xaxis->SetPos('min');	    	    // By default we hide the first label so it doesn't cross the	    // Y-axis in case the positon hasn't been set by the user.	    // However, if we use a box we always want the first value	    // displayed so we make sure it will be displayed.	    $this->xscale->ticks->SupressFirst(false);	    	    $this->xaxis->SetLabelSide(SIDE_DOWN);	    $this->xaxis->scale->ticks->SetSide($bottompos);	    $this->xaxis->Stroke($this->yscale);	    if( $toppos != -100 ) {		// To avoid side effects we work on a new copy		$maxis = $this->xaxis;		$maxis->SetPos('max');		$maxis->SetLabelSide(SIDE_UP);		$maxis->SetLabelMargin(7);		$this->xaxis->scale->ticks->SetSide($toppos);		$maxis->Stroke($this->yscale);	    }	    $this->yaxis->SetPos('min');	    $this->yaxis->SetLabelMargin(10);	    $this->yaxis->SetLabelSide(SIDE_LEFT);	    $this->yaxis->scale->ticks->SetSide($leftpos);	    $this->yaxis->Stroke($this->xscale);	    $myaxis = $this->yaxis;	    $myaxis->SetPos('max');	    $myaxis->SetLabelMargin(10);	    $myaxis->SetLabelSide(SIDE_RIGHT);	    $myaxis->title->Set('');	    $myaxis->scale->ticks->SetSide($rightpos);	    $myaxis->Stroke($this->xscale);	    	}	else {	    $this->xaxis->Stroke($this->yscale);	    $this->yaxis->Stroke($this->xscale);			}    }    // Private helper function for backgound image    function LoadBkgImage($aImgFormat='',$aFile='') {	if( $aFile == '' )	    $aFile = $this->background_image;	// Remove case sensitivity and setup appropriate function to create image	// Get file extension. This should be the LAST '.' separated part of the filename	$e = explode('.',$aFile);	$ext = strtolower($e[count($e)-1]);	if ($ext == "jpeg")  {	    $ext = "jpg";	}		if( trim($ext) == '' ) 	    $ext = 'png';  // Assume PNG if no extension specified	if( $aImgFormat == '' )	    $imgtag = $ext;	else	    $imgtag = $aImgFormat;	$supported = imagetypes();	if( ( $ext == 'jpg' && !($supported & IMG_JPG) ) ||	    ( $ext == 'gif' && !($supported & IMG_GIF) ) ||	    ( $ext == 'png' && !($supported & IMG_PNG) ) ) {	    JpGraphError::Raise('The im

⌨️ 快捷键说明

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