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

📄 jpgraph_pie3d.php

📁 极限网络智能办公系统 - Office Automation 2008 官方100% 源码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
				$explode[1]
			);
			$originalangles[$i] = array(
				$a,
				$a + $da
			);
			$ne = $this->NormAngle( $a + $da );
			if ( $da <= 180 )
			{
				$split = -1;
				if ( !( $da <= 90 ) && !( $a <= 90 ) && 90 < $ne || $da <= 180 && 90 < $da && ( $a < 90 || 270 <= $a ) && 90 < $ne )
				{
					$split = 90;
				}
				else if ( !( $da <= 90 ) && !( $a <= 270 ) && 270 < $ne || $da <= 180 && 90 < $da && 90 <= $a && $a < 270 && 270 < $a + $da )
				{
					$split = 270;
				}
				if ( 0 < $split )
				{
					$angles[$idx] = array(
						$a,
						$split
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
					$angles[++$idx] = array(
						$split,
						$ne
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
				}
				else
				{
					$angles[$idx] = array(
						$a,
						$ne
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
				}
			}
			else
			{
				if ( $a < 90 )
				{
					$split = 90;
				}
				else if ( $a <= 270 )
				{
					$split = 270;
				}
				else
				{
					$split = 90;
				}
				$angles[$idx] = array(
					$a,
					$split
				);
				$adjcolors[$idx] = $colors[$i % $numcolors];
				$adjexplode[$idx] = $explode;
				if ( !( $a < 90 ) && 270 < $a + $da || !( 90 < $a ) && !( $a <= 270 ) && 450 < $a + $da || 270 < $a && 270 < $this->NormAngle( $a + $da ) )
				{
					$angles[++$idx] = array(
						$split,
						360 - $split
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
					$angles[++$idx] = array(
						360 - $split,
						$ne
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
				}
				else
				{
					$angles[++$idx] = array(
						$split,
						$ne
					);
					$adjcolors[$idx] = $colors[$i % $numcolors];
					$adjexplode[$idx] = $explode;
				}
			}
			$a += $da;
			$a = $this->NormAngle( $a );
		}
		$n = count( $angles );
		$i = 0;
		for ( ;	$i < $n;	++$i	)
		{
			list( $dbgs, $dbge ) = $angles[$i];
		}
		$minval = $angles[0][0];
		$min = 0;
		$i = 0;
		for ( ;	$i < $n;	++$i	)
		{
			if ( $angles[$i][0] < $minval )
			{
				$minval = $angles[$i][0];
				$min = $i;
			}
		}
		$j = $min;
		$cnt = 0;
		while ( $angles[$j][1] <= 90 )
		{
			++$j;
			if ( $n <= $j )
			{
				$j = 0;
			}
			if ( $n < $cnt )
			{
				JpGraphError::raisel( 14005 );
			}
			++$cnt;
		}
		$start = $j;
		$cnt = 0;
		while ( $angles[$j][0] < 270 && $aaoption !== 2 )
		{
			list( $x, $y ) = $adjexplode[$j];
			$this->Pie3DSlice( $img, $x, $y, $d, $h, $angles[$j][0], $angles[$j][1], $z, $adjcolors[$j], $shadow );
			$last = array(
				$x,
				$y,
				$j
			);
			++$j;
			if ( $n <= $j )
			{
				$j = 0;
			}
			if ( $n < $cnt )
			{
				JpGraphError::raisel( 14006 );
			}
			++$cnt;
		}
		$slice_left = $n - $cnt;
		$j = $start - 1;
		if ( $j < 0 )
		{
			$j = $n - 1;
		}
		$cnt = 0;
		while ( $cnt < $slice_left && $aaoption !== 2 )
		{
			list( $x, $y ) = $adjexplode[$j];
			$this->Pie3DSlice( $img, $x, $y, $d, $h, $angles[$j][0], $angles[$j][1], $z, $adjcolors[$j], $shadow );
			--$j;
			if ( $n < $cnt )
			{
				JpGraphError::raisel( 14006 );
			}
			if ( $j < 0 )
			{
				$j = $n - 1;
			}
			++$cnt;
		}
		if ( $aaoption !== 2 )
		{
			$this->Pie3DSlice( $img, $last[0], $last[1], $d, $h, $angles[$last[2]][0], $angles[$last[2]][1], $z, $adjcolors[$last[2]], $shadow );
		}
		if ( $aaoption !== 1 )
		{
			$this->value->ApplyFont( $img );
			$margin = $img->GetFontHeight( ) / 2 + $this->value->margin;
			$i = 0;
			for ( ;	$i < count( $data );	++$i	)
			{
				$la = $labeldata[$i][0];
				$x = $labeldata[$i][1] + cos( $la * M_PI / 180 ) * ( $d + $margin ) * $this->ilabelposadj;
				$y = $labeldata[$i][2] - sin( $la * M_PI / 180 ) * ( $h + $margin ) * $this->ilabelposadj;
				if ( 1 <= $this->ilabelposadj && 180 < $la && $la < 360 )
				{
					$y += $z;
				}
				if ( $this->labeltype == 0 )
				{
					if ( 0 < $sum )
					{
						$l = 100 * $data[$i] / $sum;
					}
					else
					{
						$l = 0;
					}
				}
				else if ( $this->labeltype == 1 )
				{
					$l = $data[$i];
				}
				else
				{
					$l = $this->adjusted_data[$i];
				}
				if ( isset( $this->labels[$i] ) && is_string( $this->labels[$i] ) )
				{
					$l = sprintf( $this->labels[$i], $l );
				}
				$this->StrokeLabels( $l, $img, $labeldata[$i][0] * M_PI / 180, $x, $y, $z );
				$this->Add3DSliceToCSIM( $i, $labeldata[$i][1], $labeldata[$i][2], $h * 2, $d * 2, $z, $originalangles[$i][0], $originalangles[$i][1] );
			}
		}
		if ( $edgecolor == "" || $aaoption !== 0 )
		{
			return;
		}
		$accsum = 0;
		$a = $startangle;
		$a = $this->NormAngle( $a );
		$a *= M_PI / 180;
		$idx = 0;
		$img->PushColor( $edgecolor );
		$img->SetLineWeight( $edgeweight );
		$fulledge = true;
		$i = 0;
		for ( ;	$i < count( $data ) && $fulledge;	++$i	)
		{
			if ( empty( $this->explode_radius[$i] ) )
			{
				$this->explode_radius[$i] = 0;
			}
			if ( 0 < $this->explode_radius[$i] )
			{
				$fulledge = false;
			}
		}
		$i = 0;
		for ( ;	$i < count( $data );	++$i,	++$idx	)
		{
			$da = $data[$i] / $sum * 2 * M_PI;
			$this->StrokeFullSliceFrame( $img, $xc, $yc, $a, $a + $da, $d, $h, $z, $edgecolor, $this->explode_radius[$i], $fulledge );
			$a += $da;
		}
		$img->PopColor( );
	}

	public function StrokeFullSliceFrame( $img, $xc, $yc, $sa, $ea, $w, $h, $z, $edgecolor, $exploderadius, $fulledge )
	{
		$step = 0.02;
		if ( 0 < $exploderadius )
		{
			$la = ( $sa + $ea ) / 2;
			$xc += $exploderadius * cos( $la );
			$yc -= $exploderadius * sin( $la ) * ( $h / $w );
		}
		$p = array(
			$xc,
			$yc,
			$xc + $w * cos( $sa ),
			$yc - $h * sin( $sa )
		);
		$a = $sa;
		for ( ;	$a < $ea;	$a += $step	)
		{
			$p[] = $xc + $w * cos( $a );
			$p[] = $yc - $h * sin( $a );
		}
		$p[] = $xc + $w * cos( $ea );
		$p[] = $yc - $h * sin( $ea );
		$p[] = $xc;
		$p[] = $yc;
		$img->SetColor( $edgecolor );
		$img->Polygon( $p );
		if ( $fulledge && ( !( 0 < $sa ) && !( $sa < M_PI ) && !( $ea < M_PI ) ) )
		{
			if ( $sa < M_PI && M_PI < $ea )
			{
				$sa = M_PI;
			}
			if ( $sa < 2 * M_PI && ( 2 * M_PI <= $ea || 0 < $ea && $ea < $sa ) )
			{
				$ea = 2 * M_PI;
			}
			if ( M_PI <= $sa && $ea <= 2 * M_PI )
			{
				$p = array(
					$xc + $w * cos( $sa ),
					$yc - $h * sin( $sa ),
					$xc + $w * cos( $sa ),
					$z + $yc - $h * sin( $sa )
				);
				$a = $sa + $step;
				for ( ;	$a < $ea;	$a += $step	)
				{
					$p[] = $xc + $w * cos( $a );
					$p[] = $z + $yc - $h * sin( $a );
				}
				$p[] = $xc + $w * cos( $ea );
				$p[] = $z + $yc - $h * sin( $ea );
				$p[] = $xc + $w * cos( $ea );
				$p[] = $yc - $h * sin( $ea );
				$img->SetColor( $edgecolor );
				$img->Polygon( $p );
			}
		}
	}

	public function Stroke( $img, $aaoption = 0 )
	{
		$n = count( $this->data );
		if ( $this->setslicecolors == null )
		{
			$colors = array_keys( $img->rgb->rgb_table );
			sort( &$colors );
			$idx_a = $this->themearr[$this->theme];
			$ca = array( );
			$m = count( $idx_a );
			$i = 0;
			for ( ;	$i < $m;	++$i	)
			{
				$ca[$i] = $colors[$idx_a[$i]];
			}
			$ca = array_reverse( array_slice( $ca, 0, $n ) );
		}
		else
		{
			$ca = $this->setslicecolors;
		}
		if ( $this->posx <= 1 && 0 < $this->posx )
		{
			$xc = round( $this->posx * $img->width );
		}
		else
		{
			$xc = $this->posx;
		}
		if ( $this->posy <= 1 && 0 < $this->posy )
		{
			$yc = round( $this->posy * $img->height );
		}
		else
		{
			$yc = $this->posy;
		}
		if ( $this->radius <= 1 )
		{
			$width = floor( $this->radius * min( $img->width, $img->height ) );
			$width = min( $width, min( $xc * 0.9, ( $yc * 90 / $this->angle - $width / 4 ) * 0.9 ) );
		}
		else
		{
			$width = $this->radius * ( $aaoption === 1 ? 2 : 1 );
		}
		if ( $width < 1 )
		{
			JpGraphError::raisel( 14007 );
		}
		if ( $this->iThickness )
		{
			$thick = $this->iThickness;
			$thick *= $aaoption === 1 ? 2 : 1;
		}
		else
		{
			$thick = $width / 12;
		}
		$a = $this->angle;
		if ( $a <= 30 )
		{
			$thick *= 1.6;
		}
		else if ( $a <= 40 )
		{
			$thick *= 1.4;
		}
		else if ( $a <= 50 )
		{
			$thick *= 1.2;
		}
		else if ( $a <= 60 )
		{
			$thick *= 1;
		}
		else if ( $a <= 70 )
		{
			$thick *= 0.8;
		}
		else if ( $a <= 80 )
		{
			$thick *= 0.7;
		}
		else
		{
			$thick *= 0.6;
		}
		$thick = floor( $thick );
		if ( $this->explode_all )
		{
			$i = 0;
			for ( ;	$i < $n;	++$i	)
			{
				$this->explode_radius[$i] = $this->explode_r;
			}
		}
		$this->Pie3D( $aaoption, $img, $this->data, $ca, $xc, $yc, $width, $this->angle, $thick, 0.65, $this->startangle, $this->edgecolor, $this->edgeweight );
		if ( $aaoption != 1 )
		{
			$this->title->SetPos( $xc, $yc - $this->title->GetFontHeight( $img ) - $width / 2 - $this->title->margin, "center", "bottom" );
			$this->title->Stroke( $img );
		}
	}

	public function StrokeLabels( $label, $img, $a, $xp, $yp, $z )
	{
		$this->value->halign = "left";
		$this->value->valign = "top";
		$this->value->ApplyFont( $img );
		$h = $img->GetTextHeight( $label );
		if ( is_numeric( $label ) )
		{
			if ( 0 <= $label )
			{
				$w = $img->GetTextWidth( sprintf( $this->value->format, $label ) );
			}
			else
			{
				$w = $img->GetTextWidth( sprintf( $this->value->negformat, $label ) );
			}
		}
		else
		{
			$w = $img->GetTextWidth( $label );
		}
		while ( 2 * M_PI < $a )
		{
			$a -= 2 * M_PI;
		}
		if ( 7 * M_PI / 4 <= $a || $a <= M_PI / 4 )
		{
			$dx = 0;
		}
		if ( M_PI / 4 <= $a && $a <= 3 * M_PI / 4 )
		{
			$dx = ( $a - M_PI / 4 ) * 2 / M_PI;
		}
		if ( 3 * M_PI / 4 <= $a && $a <= 5 * M_PI / 4 )
		{
			$dx = 1;
		}
		if ( 5 * M_PI / 4 <= $a && $a <= 7 * M_PI / 4 )
		{
			$dx = 1 - ( $a - M_PI * 5 / 4 ) * 2 / M_PI;
		}
		if ( 7 * M_PI / 4 <= $a )
		{
			$dy = ( $a - M_PI - 3 * M_PI / 4 ) * 2 / M_PI;
		}
		if ( $a <= M_PI / 4 )
		{
			$dy = 1 - $a * 2 / M_PI;
		}
		if ( M_PI / 4 <= $a && $a <= 3 * M_PI / 4 )
		{
			$dy = 1;
		}
		if ( 3 * M_PI / 4 <= $a && $a <= 5 * M_PI / 4 )
		{
			$dy = 1 - ( $a - 3 * M_PI / 4 ) * 2 / M_PI;
		}
		if ( 5 * M_PI / 4 <= $a && $a <= 7 * M_PI / 4 )
		{
			$dy = 0;
		}
		$x = round( $xp - $dx * $w );
		$y = round( $yp - $dy * $h );
		$oldmargin = $this->value->margin;
		$this->value->margin = 0;
		$this->value->Stroke( $img, $label, $x, $y );
		$this->value->margin = $oldmargin;
	}

}

?>

⌨️ 快捷键说明

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