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

📄 jpgraph_pie.php

📁 极限网络智能办公系统 - Office Automation 2.8 100% 源码
💻 PHP
📖 第 1 页 / 共 3 页
字号:
}

class pieplotc extends pieplot
{

	var $explode_radius = array( );
	var $explode_all = false;
	var $labels = null;
	var $legends = null;
	var $csimtargets = null;
	var $csimareas = "";
	var $csimalts = null;
	var $data = null;
	var $color = "black";
	var $show_labels = true;
	var $themearr = array
	(
		"earth" => array
		(
			0 => 136,
			1 => 34,
			2 => 40,
			3 => 45,
			4 => 46,
			5 => 62,
			6 => 63,
			7 => 134,
			8 => 74,
			9 => 10,
			10 => 120,
			11 => 136,
			12 => 141,
			13 => 168,
			14 => 180,
			15 => 77,
			16 => 209,
			17 => 218,
			18 => 346,
			19 => 395,
			20 => 89,
			21 => 430
		),
		"td" => array
		(
			0 => 136,
			1 => 22,
			2 => 40,
			3 => 45,
			4 => 49,
			5 => 74,
			6 => 119,
			7 => 149,
			8 => 430,
			9 => 105,
			10 => 333,
			11 => 4,
			12 => 141,
			13 => 168,
			14 => 180,
			15 => 209,
			16 => 218,
			17 => 395,
			18 => 89
		),
		"pastel" => array
		(
			0 => 27,
			1 => 415,
			2 => 128,
			3 => 59,
			4 => 66,
			5 => 79,
			6 => 105,
			7 => 110,
			8 => 42,
			9 => 147,
			10 => 152,
			11 => 230,
			12 => 236,
			13 => 240,
			14 => 331,
			15 => 337,
			16 => 405,
			17 => 38
		),
		"water" => array
		(
			0 => 8,
			1 => 370,
			2 => 24,
			3 => 40,
			4 => 335,
			5 => 56,
			6 => 213,
			7 => 237,
			8 => 268,
			9 => 14,
			10 => 326,
			11 => 387,
			12 => 10,
			13 => 388
		),
		"sand" => array
		(
			0 => 27,
			1 => 168,
			2 => 34,
			3 => 170,
			4 => 19,
			5 => 50,
			6 => 65,
			7 => 72,
			8 => 131,
			9 => 209,
			10 => 46,
			11 => 393
		)
	);
	var $theme = "earth";
	var $setslicecolors = array( );
	var $pie_border = true;
	var $pie_interior_border = true;
	var $ishadowcolor = "";
	var $legendcsimtargets = array( );
	var $legendcsimalts = array( );
	var $adjusted_data = array( );
	var $guideline = null;
	var $iShowGuideLineForSingle = false;
	var $iGuideLineCurve = false;
	var $imidsize = 0.5;
	var $imidcolor = "white";
	var $midtitle = "";
	var $middlecsimtarget = "";
	var $middlecsimalt = "";

	function addslicetocsim( $i, $xc, $yc, $radius, $sa, $ea )
	{
		while ( 2 * M_PI < $sa )
		{
			$sa = $sa - 2 * M_PI;
		}
		while ( 2 * M_PI < $ea )
		{
			$ea = $ea - 2 * M_PI;
		}
		$sa = 2 * M_PI - $sa;
		$ea = 2 * M_PI - $ea;
		if ( abs( $sa - $ea ) < 0.0001 )
		{
			$sa = 2 * M_PI;
			$ea = 0;
		}
		$xp = floor( $this->imidsize * $radius * cos( $ea ) + $xc );
		$yp = floor( $yc - $this->imidsize * $radius * sin( $ea ) );
		$coords = "{$xp}, {$yp}";
		$a = $ea + 0.25;
		if ( $sa < $ea )
		{
			while ( $a <= 2 * M_PI )
			{
				$xp = floor( $radius * cos( $a ) + $xc );
				$yp = floor( $yc - $radius * sin( $a ) );
				$coords .= ", {$xp}, {$yp}";
				$a += 0.25;
			}
			$a -= 2 * M_PI;
		}
		while ( $a < $sa )
		{
			$xp = floor( $this->imidsize * $radius * cos( $a ) + $xc );
			$yp = floor( $yc - $this->imidsize * $radius * sin( $a ) );
			$coords .= ", {$xp}, {$yp}";
			$a += 0.25;
		}
		$xp = floor( $this->imidsize * $radius * cos( $sa ) + $xc );
		$yp = floor( $yc - $this->imidsize * $radius * sin( $sa ) );
		$coords .= ", {$xp}, {$yp}";
		$xp = floor( $radius * cos( $sa ) + $xc );
		$yp = floor( $yc - $radius * sin( $sa ) );
		$coords .= ", {$xp}, {$yp}";
		$a = $sa - 0.25;
		while ( $ea < $a )
		{
			$xp = floor( $radius * cos( $a ) + $xc );
			$yp = floor( $yc - $radius * sin( $a ) );
			$coords .= ", {$xp}, {$yp}";
			$a -= 0.25;
		}
		$xp = floor( $radius * cos( $ea ) + $xc );
		$yp = floor( $yc - $radius * sin( $ea ) );
		$coords .= ", {$xp}, {$yp}";
		$xp = floor( $this->imidsize * $radius * cos( $ea ) + $xc );
		$yp = floor( $yc - $this->imidsize * $radius * sin( $ea ) );
		$coords .= ", {$xp}, {$yp}";
		if ( !empty( $this->csimtargets[$i] ) )
		{
			$this->csimareas .= "<area shape=\"poly\" coords=\"{$coords}\" href=\"".$this->csimtargets[$i]."\"";
			if ( !empty( $this->csimalts[$i] ) )
			{
				$tmp = sprintf( $this->csimalts[$i], $this->data[$i] );
				$this->csimareas .= " title=\"{$tmp}\"";
			}
			$this->csimareas .= " alt=\"{$tmp}\" />\n";
		}
	}

	function stroke( $img, $aaoption = 0 )
	{
		$tmp = $this->value->show;
		$this->value->show = false;
		pieplot::stroke( $img, $aaoption );
		$this->value->show = $tmp;
		$xc = round( $this->posx * $img->width );
		$yc = round( $this->posy * $img->height );
		$radius = floor( $this->radius * min( $img->width, $img->height ) );
		if ( 0 < $this->imidsize && $aaoption !== 2 )
		{
			if ( $this->ishadowcolor != "" )
			{
				$img->setcolor( $this->ishadowcolor );
				$img->filledcircle( $xc + $this->ishadowdrop, $yc + $this->ishadowdrop, round( $radius * $this->imidsize ) );
			}
			$img->setcolor( $this->imidcolor );
			$img->filledcircle( $xc, $yc, round( $radius * $this->imidsize ) );
			if ( $this->pie_border && $aaoption === 0 )
			{
				$img->setcolor( $this->color );
				$img->circle( $xc, $yc, round( $radius * $this->imidsize ) );
			}
			if ( !empty( $this->middlecsimtarget ) )
			{
				$this->addmiddlecsim( $xc, $yc, round( $radius * $this->imidsize ) );
			}
		}
		if ( $this->value->show && $aaoption !== 1 )
		{
			$this->strokealllabels( $img, $xc, $yc, $radius );
			$this->midtitle->pos( $xc, $yc, "center", "center" );
			$this->midtitle->stroke( $img );
		}
	}

	function strokelabel( $label, $img, $xc, $yc, $a, $r )
	{
		if ( $this->ilabelposadj === "auto" )
		{
			$this->ilabelposadj = ( 1 - $this->imidsize ) / 2 + $this->imidsize;
		}
		pieplot::strokelabel( $label, $img, $xc, $yc, $a, $r );
	}

	function pieplotc( $data, $aCenterTitle = "" )
	{
		pieplot::pieplot( $data );
		$this->midtitle = new text( );
		$this->midtitle->paragraphalign( "center" );
	}

	function setmid( $aTitle, $aColor = "white", $aSize = 0.5 )
	{
		$this->midtitle->set( $aTitle );
		$this->imidsize = $aSize;
		$this->imidcolor = $aColor;
	}

	function setmidtitle( $aTitle )
	{
		$this->midtitle->set( $aTitle );
	}

	function setmidsize( $aSize )
	{
		$this->imidsize = $aSize;
	}

	function setmidcolor( $aColor )
	{
		$this->imidcolor = $aColor;
	}

	function setmidcsim( $aTarget, $aAlt )
	{
		$this->middlecsimtarget = $aTarget;
		$this->middlecsimalt = $aAlt;
	}

	function addmiddlecsim( $xc, $yc, $r )
	{
		$xc = round( $xc );
		$yc = round( $yc );
		$r = round( $r );
		$this->csimareas .= "<area shape=\"circle\" coords=\"{$xc},{$yc},{$r}\" href=\"".$this->middlecsimtarget."\"";
		if ( !empty( $this->middlecsimalt ) )
		{
			$tmp = $this->middlecsimalt;
			$this->csimareas .= " title=\"{$tmp}\"";
		}
		$this->csimareas .= " alt=\"{$tmp}\" />\n";
	}

}

define( "PIE_VALUE_ABS", 1 );
define( "PIE_VALUE_PER", 0 );
define( "PIE_VALUE_PERCENTAGE", 0 );
define( "PIE_VALUE_ADJPERCENTAGE", 2 );
define( "PIE_VALUE_ADJPER", 2 );
class piegraph extends graph
{

	var $posx;
	var $posy;
	var $radius;
	var $legends = array( );
	var $plots = array( );
	var $pieaa = false;

	function piegraph( $width = 300, $height = 200, $cachedName = "", $timeout = 0, $inline = 1 )
	{
		$this->graph( $width, $height, $cachedName, $timeout, $inline );
		$this->posx = $width / 2;
		$this->posy = $height / 2;
		$this->setcolor( array( 255, 255, 255 ) );
	}

	function add( $aObj )
	{
		if ( is_array( $aObj ) && 0 < count( $aObj ) )
		{
			$cl = get_class( $aObj[0] );
		}
		else
		{
			$cl = get_class( $aObj );
		}
		if ( $cl == "text" )
		{
			$this->addtext( $aObj );
		}
		else if ( $cl == "iconplot" )
		{
			$this->addicon( $aObj );
		}
		else if ( is_array( $aObj ) )
		{
			$n = count( $aObj );
			$i = 0;
			for ( ;	$i < $n;	++$i	)
			{
				$this->plots[] = $aObj[$i];
			}
		}
		else
		{
			$this->plots[] = $aObj;
		}
	}

	function setantialiasing( $aFlg = true )
	{
		$this->pieaa = $aFlg;
	}

	function setcolor( $c )
	{
		$this->setmargincolor( $c );
	}

	function displaycsimareas( )
	{
		$csim = "";
		foreach ( $this->plots as $p )
		{
			$csim .= $p->getcsimareas( );
		}
		if ( preg_match_all( "/area shape=\"(\\w+)\" coords=\"([0-9\\, ]+)\"/", $csim, $coords ) )
		{
			$this->img->setcolor( $this->csimcolor );
			$i = 0;
			for ( ;	$i < count( $coords[0] );	++$i	)
			{
				if ( $coords[1][$i] == "poly" )
				{
					preg_match_all( "/\\s*([0-9]+)\\s*,\\s*([0-9]+)\\s*,*/", $coords[2][$i], $pts );
					$this->img->setstartpoint( $pts[1][count( $pts[0] ) - 1], $pts[2][count( $pts[0] ) - 1] );
					$j = 0;
					for ( ;	$j < count( $pts[0] );	++$j	)
					{
						$this->img->lineto( $pts[1][$j], $pts[2][$j] );
					}
				}
				else if ( $coords[1][$i] == "rect" )
				{
					$pts = preg_split( "/,/", $coords[2][$i] );
					$this->img->setstartpoint( $pts[0], $pts[1] );
					$this->img->lineto( $pts[2], $pts[1] );
					$this->img->lineto( $pts[2], $pts[3] );
					$this->img->lineto( $pts[0], $pts[3] );
					$this->img->lineto( $pts[0], $pts[1] );
				}
			}
		}
	}

	function stroke( $aStrokeFileName = "" )
	{
		$_csim = $aStrokeFileName === _CSIM_SPECIALFILE;
		$this->iHasStroked = true;
		$n = count( $this->plots );
		if ( $this->pieaa )
		{
			if ( !$_csim )
			{
				if ( $this->background_image != "" )
				{
					$this->strokeframebackground( );
				}
				else
				{
					$this->strokeframe( );
				}
			}
			$w = $this->img->width;
			$h = $this->img->height;
			$oldimg = $this->img->img;
			$this->img->createimgcanvas( 2 * $w, 2 * $h );
			$this->img->setcolor( $this->margin_color );
			$this->img->filledrectangle( 0, 0, 2 * $w - 1, 2 * $h - 1 );
			$ni = count( $this->iIcons );
			$i = 0;
			for ( ;	$i < $ni;	++$i	)
			{
				$this->iIcons[$i]->iScale *= 2;
			}
			$this->strokeicons( );
			$i = 0;
			for ( ;	$i < $n;	++$i	)
			{
				if ( 1 < $this->plots[$i]->posx )
				{
					$this->plots[$i]->posx *= 2;
				}
				if ( 1 < $this->plots[$i]->posy )
				{
					$this->plots[$i]->posy *= 2;
				}
				$this->plots[$i]->stroke( $this->img, 1 );
				if ( 1 < $this->plots[$i]->posx )
				{
					$this->plots[$i]->posx /= 2;
				}
				if ( 1 < $this->plots[$i]->posy )
				{
					$this->plots[$i]->posy /= 2;
				}
			}
			$indent = $this->doframe ? $this->frame_weight + ( $this->doshadow ? $this->shadow_width : 0 ) : 0;
			$indent += $this->framebevel ? $this->framebeveldepth + 1 : 0;
			$this->img->copycanvash( $oldimg, $this->img->img, $indent, $indent, $indent, $indent, $w - 2 * $indent, $h - 2 * $indent, 2 * ( $w - $indent ), 2 * ( $h - $indent ) );
			$this->img->img = $oldimg;
			$this->img->width = $w;
			$this->img->height = $h;
			$i = 0;
			for ( ;	$i < $n;	++$i	)
			{
				$this->plots[$i]->stroke( $this->img, 2 );
				$this->plots[$i]->legend( $this );
			}
		}
		else
		{
			if ( !$_csim )
			{
				if ( $this->background_image != "" )
				{
					$this->strokeframebackground( );
				}
				else
				{
					$this->strokeframe( );
				}
			}
			$this->strokeicons( );
			$i = 0;
			for ( ;	$i < $n;	++$i	)
			{
				$this->plots[$i]->stroke( $this->img );
				$this->plots[$i]->legend( $this );
			}
		}
		$this->legend->stroke( $this->img );
		$this->footer->stroke( $this->img );
		$this->stroketitles( );
		if ( !$_csim )
		{
			if ( $this->texts != null )
			{
				$n = count( $this->texts );
				$i = 0;
				for ( ;	$i < $n;	++$i	)
				{
					$this->texts[$i]->stroke( $this->img );
				}
			}
			if ( _JPG_DEBUG )
			{
				$this->displaycsimareas( );
			}
			if ( $this->iImgTrans )
			{
				if ( !class_exists( "ImgTrans" ) )
				{
					require_once( "jpgraph_imgtrans.php" );
				}
				$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 ( $aStrokeFileName == _IMG_HANDLER )
			{
				return $this->img->img;
			}
			else
			{
				$this->cache->putandstream( $this->img, $this->cache_name, $this->inline, $aStrokeFileName );
			}
		}
	}

}

?>

⌨️ 快捷键说明

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