jpgraph.php

来自「通达OA2007SE源代码 非常好的」· PHP 代码 · 共 2,039 行 · 第 1/5 页

PHP
2,039
字号
	    }	    $this->yscale->AutoScale($this->img,$min,$max,				     $this->img->plotheight/$this->ytick_factor);	}	elseif( $this->yscale->IsSpecified() && 		( $this->yscale->auto_ticks || !$this->yscale->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->yscale->scale[0];	    $max = $this->yscale->scale[1];	    $this->yscale->AutoScale($this->img,$min,$max,				     $this->img->plotheight/$this->ytick_factor,				     $this->yscale->auto_ticks);	}	if( $this->y2scale != null) {	    if( !$this->y2scale->IsSpecified() && count($this->y2plots)>0 ) {		list($min,$max) = $this->GetPlotsYMinMax($this->y2plots);		$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);	    }	}					//	// Autoscale the extra Y-axises	//	$n = count($this->ynaxis);	for( $i=0; $i < $n; ++$i ) {	  if( $this->ynscale[$i] != null) {	    if( !$this->ynscale[$i]->IsSpecified() && count($this->ynplots[$i])>0 ) {	      list($min,$max) = $this->GetPlotsYMinMax($this->ynplots[$i]);	      $this->ynscale[$i]->AutoScale($this->img,$min,$max,$this->img->plotheight/$this->ytick_factor);	    }				    elseif( $this->ynscale[$i]->IsSpecified() && 		    ( $this->ynscale[$i]->auto_ticks || !$this->ynscale[$i]->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->ynscale[$i]->scale[0];	      $max = $this->ynscale[$i]->scale[1];	      $this->ynscale[$i]->AutoScale($this->img,$min,$max,					    $this->img->plotheight/$this->ytick_factor,					    $this->ynscale[$i]->auto_ticks);	    }	  }	}			//Check if we should autoscale x-axis	if( !$this->xscale->IsSpecified() ) {	    if( substr($this->axtype,0,4) == "text" ) {		$max=0;		$n = count($this->plots);		for($i=0; $i < $n; ++$i ) {		    $p = $this->plots[$i];		    // We need some unfortunate sub class knowledge here in order		    // to increase number of data points in case it is a line plot		    // which has the barcenter set. If not it could mean that the		    // last point of the data is outside the scale since the barcenter		    // settings means that we will shift the entire plot half a tick step		    // to the right in oder to align with the center of the bars.		    if( class_exists('BarPlot',false) ) {			$cl = strtolower(get_class($p));			if( (class_exists('BarPlot',false) && ($p instanceof BarPlot)) || 			    empty($p->barcenter) ) 			    $max=max($max,$p->numpoints-1);			else {			    $max=max($max,$p->numpoints);			}		    }		    else {			if( empty($p->barcenter) ) {			    $max=max($max,$p->numpoints-1);			}			else {			    $max=max($max,$p->numpoints);			}		    }		}		$min=0;		if( $this->y2axis != null ) {		    foreach( $this->y2plots as $p ) {			$max=max($max,$p->numpoints-1);		    }		    		}		$n = count($this->ynaxis);		for( $i=0; $i < $n; ++$i ) {		    if( $this->ynaxis[$i] != null) {			foreach( $this->ynplots[$i] 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,round($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);	    }	    $n = count($this->ynaxis);	    $nY2adj = $this->y2axis != null ? $this->iYAxisDeltaPos : 0;	    for( $i=0; $i < $n; ++$i ) { 		if( $this->ynaxis[$i] != null ) {		    if( !is_numeric($this->ynaxis[$i]->pos) && !is_string($this->ynaxis[$i]->pos) ) {			$this->ynaxis[$i]->SetPos($this->xscale->GetMaxVal());		  $this->ynaxis[$i]->SetPosAbsDelta($i*$this->iYAxisDeltaPos + $nY2adj);		    }		    $this->ynaxis[$i]->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,				     round($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();	    if( $this->iIconDepth == DEPTH_BACK ) {		$this->StrokeIcons();	    }	}	$this->StrokeAxis(false);	// 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();	}	// Stroke yn-axis	$n = count($this->ynaxis); 	for( $i=0; $i < $n; ++$i ) {	    $this->ynaxis[$i]->Stroke($this->xscale); 					}	$oldoff=$this->xscale->off;	if(substr($this->axtype,0,4)=="text") {	    if( $this->text_scale_abscenteroff > -1 ) {		// For a text scale the scale factor is the number of pixel per step. 		// Hence we can use the scale factor as a substitute for number of pixels		// per major scale step and use that in order to adjust the offset so that		// an object of width "abscenteroff" becomes centered.		$this->xscale->off += round($this->xscale->scale_factor/2)-round($this->text_scale_abscenteroff/2);	    }	    else {		$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);	    }							}	$n = count($this->ynaxis); 	for( $i=0; $i < $n; ++$i ) {	    $m = count($this->ynplots[$i]);	    for( $j=0; $j < $m; ++$j ) { 		$this->ynplots[$i][$j]->Stroke($this->img,$this->xscale,$this->ynscale[$i]);		$this->ynplots[$i][$j]->StrokeMargin($this->img);	    }	}	if( $this->iIconDepth == DEPTH_FRONT) {	    $this->StrokeIcons();	}		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::RaiseL(25035,$this->img->a);//('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,false); 				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->img->SetAngle($aa);		$this->StrokeTexts();		$this->StrokeTables();	if( !$_

⌨️ 快捷键说明

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