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

📄 jpgraph_pie3d.php

📁 极限网络智能办公系统 - Office Automation 2008 官方100% 源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php
 

class PiePlot3D extends PiePlot
{

	private $labelhintcolor = "red";
	private $showlabelhint = true;
	private $angle = 50;
	private $edgecolor = "";
	private $edgeweight = 1;
	private $iThickness = false;

	public function PiePlot3d( $data )
	{
		$this->radius = 0.5;
		$this->data = $data;
		$this->title = new Text( "" );
		$this->title->SetFont( FF_FONT1, FS_BOLD );
		$this->value = new DisplayValue( );
		$this->value->Show( );
		$this->value->SetFormat( "%.0f%%" );
	}

	public function SetLegends( $aLegend )
	{
		$this->legends = array_reverse( array_slice( $aLegend, 0, count( $this->data ) ) );
	}

	public function SetSliceColors( $aColors )
	{
		$this->setslicecolors = $aColors;
	}

	public function Legend( $aGraph )
	{
		parent::legend( $aGraph );
		$aGraph->legend->txtcol = array_reverse( $aGraph->legend->txtcol );
	}

	public function SetCSIMTargets( $targets, $alts = null )
	{
		$this->csimtargets = $targets;
		$this->csimalts = $alts;
	}

	public function SetEdge( $aColor = "black", $aWeight = 1 )
	{
		$this->edgecolor = $aColor;
		$this->edgeweight = $aWeight;
	}

	public function ShowBorder( $exterior = true, $interior = true )
	{
		JpGraphError::raisel( 14001 );
	}

	public function SetAngle( $a )
	{
		if ( $a < 5 || 90 < $a )
		{
			JpGraphError::raisel( 14002 );
		}
		else
		{
			$this->angle = $a;
		}
	}

	public function Add3DSliceToCSIM( $i, $xc, $yc, $height, $width, $thick, $sa, $ea )
	{
		$sa *= M_PI / 180;
		$ea *= M_PI / 180;
		$coords = "{$xc}, {$yc}";
		$xp = floor( $width * cos( $sa ) / 2 + $xc );
		$yp = floor( $yc - $height * sin( $sa ) / 2 );
		$coords .= ", ".$xp.", {$yp}";
		if ( M_PI <= $sa && $sa <= 2 * M_PI * 1.01 )
		{
			$yp = floor( $yp + $thick );
			$coords .= ", ".$xp.", {$yp}";
		}
		$a = $sa + 0.2;
		while ( $a < $ea )
		{
			$xp = floor( $width * cos( $a ) / 2 + $xc );
			if ( M_PI <= $a && $a <= 2 * M_PI * 1.01 )
			{
				$yp = floor( $yc - $height * sin( $a ) / 2 + $thick );
			}
			else
			{
				$yp = floor( $yc - $height * sin( $a ) / 2 );
			}
			$coords .= ", ".$xp.", {$yp}";
			$a += 0.2;
		}
		$xp = floor( $width * cos( $ea ) / 2 + $xc );
		$yp = floor( $yc - $height * sin( $ea ) / 2 );
		if ( M_PI <= $ea && $ea <= 2 * M_PI * 1.01 )
		{
			$coords .= ", ".$xp.", ".floor( $yp + $thick );
		}
		$coords .= ", ".$xp.", {$yp}";
		$alt = "";
		if ( !empty( $this->csimalts[$i] ) )
		{
			$tmp = sprintf( $this->csimalts[$i], $this->data[$i] );
			$alt = "alt=\"".$tmp."\" title=\"{$tmp}\"";
		}
		if ( !empty( $this->csimtargets[$i] ) )
		{
			$this->csimareas .= "<area shape=\"poly\" coords=\"".$coords."\" href=\"".$this->csimtargets[$i].( "\" ".$alt." />\n" );
		}
	}

	public function SetLabels( $aLabels, $aLblPosAdj = "auto" )
	{
		$this->labels = $aLabels;
		$this->ilabelposadj = $aLblPosAdj;
	}

	public function SetLabelMargin( $m )
	{
		$this->value->SetMargin( $m );
	}

	public function ShowLabelHint( $f = true )
	{
		$this->showlabelhint = $f;
	}

	public function SetLabelHintColor( $c )
	{
		$this->labelhintcolor = $c;
	}

	public function SetHeight( $aHeight )
	{
		$this->iThickness = $aHeight;
	}

	public function NormAngle( $a )
	{
		if ( 0 < $a )
		{
			while ( 360 < $a )
			{
				$a -= 360;
			}
		}
		else
		{
			while ( $a < 0 )
			{
				$a += 360;
			}
		}
		if ( $a < 0 )
		{
			$a += 360;
		}
		if ( $a == 360 )
		{
			$a = 0;
		}
		return $a;
	}

	public function Pie3DSlice( $img, $xc, $yc, $w, $h, $sa, $ea, $z, $fillcolor, $shadow = 0.65 )
	{
		if ( !( $sa < 90 ) && 90 < $ea || 90 < $sa && $sa < 270 && 270 < $ea )
		{
			JpGraphError::raisel( 14003 );
			exit( 1 );
		}
		$p[] = array( );
		$rsa = $sa / 180 * M_PI;
		$rea = $ea / 180 * M_PI;
		$sinsa = sin( $rsa );
		$cossa = cos( $rsa );
		$sinea = sin( $rea );
		$cosea = cos( $rea );
		$step = 0.05;
		if ( 270 <= $sa )
		{
			if ( 360 < $ea || 0 < $ea && $ea <= 90 )
			{
				if ( 0 < $ea && $ea <= 90 )
				{
					$rea += 2 * M_PI;
				}
				$p = array(
					$xc,
					$yc,
					$xc,
					$yc + $z,
					$xc + $w * $cossa,
					$z + $yc - $h * $sinsa
				);
				$pt = array(
					$xc,
					$yc,
					$xc + $w * $cossa,
					$yc - $h * $sinsa
				);
				$a = $rsa;
				for ( ;	$a < 2 * M_PI;	$a += $step	)
				{
					$tca = cos( $a );
					$tsa = sin( $a );
					$p[] = $xc + $w * $tca;
					$p[] = $z + $yc - $h * $tsa;
					$pt[] = $xc + $w * $tca;
					$pt[] = $yc - $h * $tsa;
				}
				$pt[] = $xc + $w;
				$pt[] = $yc;
				$p[] = $xc + $w;
				$p[] = $z + $yc;
				$p[] = $xc + $w;
				$p[] = $yc;
				$p[] = $xc;
				$p[] = $yc;
				$a = 2 * M_PI + $step;
				for ( ;	$a < $rea;	$a += $step	)
				{
					$pt[] = $xc + $w * cos( $a );
					$pt[] = $yc - $h * sin( $a );
				}
				$pt[] = $xc + $w * $cosea;
				$pt[] = $yc - $h * $sinea;
				$pt[] = $xc;
				$pt[] = $yc;
			}
			else
			{
				$p = array(
					$xc,
					$yc,
					$xc,
					$yc + $z,
					$xc + $w * $cossa,
					$z + $yc - $h * $sinsa
				);
				$pt = array(
					$xc,
					$yc,
					$xc + $w * $cossa,
					$yc - $h * $sinsa
				);
				$rea = $rea == 0 ? 2 * M_PI : $rea;
				$a = $rsa;
				for ( ;	$a < $rea;	$a += $step	)
				{
					$tca = cos( $a );
					$tsa = sin( $a );
					$p[] = $xc + $w * $tca;
					$p[] = $z + $yc - $h * $tsa;
					$pt[] = $xc + $w * $tca;
					$pt[] = $yc - $h * $tsa;
				}
				$pt[] = $xc + $w * $cosea;
				$pt[] = $yc - $h * $sinea;
				$pt[] = $xc;
				$pt[] = $yc;
				$p[] = $xc + $w * $cosea;
				$p[] = $z + $yc - $h * $sinea;
				$p[] = $xc + $w * $cosea;
				$p[] = $yc - $h * $sinea;
				$p[] = $xc;
				$p[] = $yc;
			}
		}
		else if ( 180 <= $sa )
		{
			$p = array(
				$xc,
				$yc,
				$xc,
				$yc + $z,
				$xc + $w * $cosea,
				$z + $yc - $h * $sinea
			);
			$pt = array(
				$xc,
				$yc,
				$xc + $w * $cosea,
				$yc - $h * $sinea
			);
			$a = $rea;
			for ( ;	$rsa < $a;	$a -= $step	)
			{
				$tca = cos( $a );
				$tsa = sin( $a );
				$p[] = $xc + $w * $tca;
				$p[] = $z + $yc - $h * $tsa;
				$pt[] = $xc + $w * $tca;
				$pt[] = $yc - $h * $tsa;
			}
			$pt[] = $xc + $w * $cossa;
			$pt[] = $yc - $h * $sinsa;
			$pt[] = $xc;
			$pt[] = $yc;
			$p[] = $xc + $w * $cossa;
			$p[] = $z + $yc - $h * $sinsa;
			$p[] = $xc + $w * $cossa;
			$p[] = $yc - $h * $sinsa;
			$p[] = $xc;
			$p[] = $yc;
		}
		else if ( 90 <= $sa )
		{
			if ( 180 < $ea )
			{
				$p = array(
					$xc,
					$yc,
					$xc,
					$yc + $z,
					$xc + $w * $cosea,
					$z + $yc - $h * $sinea
				);
				$pt = array(
					$xc,
					$yc,
					$xc + $w * $cosea,
					$yc - $h * $sinea
				);
				$a = $rea;
				for ( ;	M_PI < $a;	$a -= $step	)
				{
					$tca = cos( $a );
					$tsa = sin( $a );
					$p[] = $xc + $w * $tca;
					$p[] = $z + $yc - $h * $tsa;
					$pt[] = $xc + $w * $tca;
					$pt[] = $yc - $h * $tsa;
				}
				$p[] = $xc - $w;
				$p[] = $z + $yc;
				$p[] = $xc - $w;
				$p[] = $yc;
				$p[] = $xc;
				$p[] = $yc;
				$pt[] = $xc - $w;
				$pt[] = $z + $yc;
				$pt[] = $xc - $w;
				$pt[] = $yc;
				$a = M_PI - $step;
				for ( ;	$rsa < $a;	$a -= $step	)
				{
					$pt[] = $xc + $w * cos( $a );
					$pt[] = $yc - $h * sin( $a );
				}
				$pt[] = $xc + $w * $cossa;
				$pt[] = $yc - $h * $sinsa;
				$pt[] = $xc;
				$pt[] = $yc;
			}
			else
			{
				$p = array(
					$xc,
					$yc,
					$xc,
					$yc + $z,
					$xc + $w * $cosea,
					$z + $yc - $h * $sinea,
					$xc + $w * $cosea,
					$yc - $h * $sinea,
					$xc,
					$yc
				);
				$pt = array(
					$xc,
					$yc,
					$xc + $w * $cosea,
					$yc - $h * $sinea
				);
				$a = $rea;
				for ( ;	$rsa < $a;	$a -= $step	)
				{
					$pt[] = $xc + $w * cos( $a );
					$pt[] = $yc - $h * sin( $a );
				}
				$pt[] = $xc + $w * $cossa;
				$pt[] = $yc - $h * $sinsa;
				$pt[] = $xc;
				$pt[] = $yc;
			}
		}
		else
		{
			$p = array(
				$xc,
				$yc,
				$xc,
				$yc + $z,
				$xc + $w * $cossa,
				$z + $yc - $h * $sinsa,
				$xc + $w * $cossa,
				$yc - $h * $sinsa,
				$xc,
				$yc
			);
			$pt = array(
				$xc,
				$yc,
				$xc + $w * $cossa,
				$yc - $h * $sinsa
			);
			$a = $rsa;
			for ( ;	$a < $rea;	$a += $step	)
			{
				$pt[] = $xc + $w * cos( $a );
				$pt[] = $yc - $h * sin( $a );
			}
			$pt[] = $xc + $w * $cosea;
			$pt[] = $yc - $h * $sinea;
			$pt[] = $xc;
			$pt[] = $yc;
		}
		$img->PushColor( $fillcolor.":".$shadow );
		$img->FilledPolygon( $p );
		$img->PopColor( );
		$img->PushColor( $fillcolor );
		$img->FilledPolygon( $pt );
		$img->PopColor( );
	}

	public function SetStartAngle( $aStart )
	{
		if ( $aStart < 0 || 360 < $aStart )
		{
			JpGraphError::raisel( 14004 );
		}
		$this->startangle = $aStart;
	}

	public function Pie3D( $aaoption, $img, $data, $colors, $xc, $yc, $d, $angle, $z, $shadow = 0.65, $startangle = 0, $edgecolor = "", $edgeweight = 1 )
	{
		$h = $angle / 90 * $d;
		$sum = 0;
		$i = 0;
		for ( ;	$i < count( $data );	++$i	)
		{
			$sum += $data[$i];
		}
		if ( $sum == 0 )
		{
			return;
		}
		if ( $this->labeltype == 2 )
		{
			$this->adjusted_data = $this->AdjPercentage( $data );
		}
		$accsum = 0;
		$a = $startangle;
		$a = $this->NormAngle( $a );
		$idx = 0;
		$adjexplode = array( );
		$numcolors = count( $colors );
		$i = 0;
		for ( ;	$i < count( $data );	++$i,	++$idx	)
		{
			$da = $data[$i] / $sum * 360;
			if ( empty( $this->explode_radius[$i] ) )
			{
				$this->explode_radius[$i] = 0;
			}
			$expscale = 1;
			if ( $aaoption == 1 )
			{
				$expscale = 2;
			}
			$la = $a + $da / 2;
			$explode = array(
				$xc + $this->explode_radius[$i] * cos( $la * M_PI / 180 ) * $expscale,
				$yc - $this->explode_radius[$i] * sin( $la * M_PI / 180 ) * ( $h / $d ) * $expscale
			);
			$adjexplode[$idx] = $explode;
			$labeldata[$i] = array(
				$la,
				$explode[0],

⌨️ 快捷键说明

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