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

📄 jpgraph_radar.php

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

class RadarGrid
{

	private $type = "solid";
	private $grid_color = "#DDDDDD";
	private $show = false;
	private $weight = 1;

	public function RadarGrid( )
	{
	}

	public function SetColor( $aMajColor )
	{
		$this->grid_color = $aMajColor;
	}

	public function SetWeight( $aWeight )
	{
		$this->weight = $aWeight;
	}

	public function SetLineStyle( $aType )
	{
		$this->type = $aType;
	}

	public function Show( $aShowMajor = true )
	{
		$this->show = $aShowMajor;
	}

	public function Stroke( $img, $grid )
	{
		if ( !$this->show )
		{
			return;
		}
		$nbrticks = count( $grid[0] ) / 2;
		$nbrpnts = count( $grid );
		$img->SetColor( $this->grid_color );
		$img->SetLineWeight( $this->weight );
		$i = 0;
		for ( ;	$i < $nbrticks;	++$i	)
		{
			$j = 0;
			for ( ;	$j < $nbrpnts;	++$j	)
			{
				$pnts[$j * 2] = $grid[$j][$i * 2];
				$pnts[$j * 2 + 1] = $grid[$j][$i * 2 + 1];
			}
			$k = 0;
			for ( ;	$k < $nbrpnts;	++$k	)
			{
				$l = ( $k + 1 ) % $nbrpnts;
				if ( $this->type == "solid" )
				{
					$img->Line( $pnts[$k * 2], $pnts[$k * 2 + 1], $pnts[$l * 2], $pnts[$l * 2 + 1] );
				}
				else if ( $this->type == "dotted" )
				{
					$img->DashedLine( $pnts[$k * 2], $pnts[$k * 2 + 1], $pnts[$l * 2], $pnts[$l * 2 + 1], 1, 6 );
				}
				else if ( $this->type == "dashed" )
				{
					$img->DashedLine( $pnts[$k * 2], $pnts[$k * 2 + 1], $pnts[$l * 2], $pnts[$l * 2 + 1], 2, 4 );
				}
				else if ( $this->type == "longdashed" )
				{
					$img->DashedLine( $pnts[$k * 2], $pnts[$k * 2 + 1], $pnts[$l * 2], $pnts[$l * 2 + 1], 8, 6 );
				}
			}
			$pnts = array( );
		}
	}

}

class RadarPlot
{

	public $mark = null;
	public $legend = "";
	private $data = array( );
	private $fill = false;
	private $fill_color = array
	(
		0 => 200,
		1 => 170,
		2 => 180
	);
	private $color = array
	(
		0 => 0,
		1 => 0,
		2 => 0
	);
	private $weight = 1;
	private $linestyle = "solid";

	public function RadarPlot( $data )
	{
		$this->data = $data;
		$this->mark = new PlotMark( );
	}

	public function Min( )
	{
		return min( $this->data );
	}

	public function Max( )
	{
		return max( $this->data );
	}

	public function SetLegend( $legend )
	{
		$this->legend = $legend;
	}

	public function SetLineStyle( $aStyle )
	{
		$this->linestyle = $aStyle;
	}

	public function SetLineWeight( $w )
	{
		$this->weight = $w;
	}

	public function SetFillColor( $aColor )
	{
		$this->fill_color = $aColor;
		$this->fill = true;
	}

	public function SetFill( $f = true )
	{
		$this->fill = $f;
	}

	public function SetColor( $aColor, $aFillColor = false )
	{
		$this->color = $aColor;
		if ( $aFillColor )
		{
			$this->SetFillColor( $aFillColor );
			$this->fill = true;
		}
	}

	public function GetCSIMareas( )
	{
		JpGraphError::raisel( 18001 );
	}

	public function Stroke( $img, $pos, $scale, $startangle )
	{
		$nbrpnts = count( $this->data );
		$astep = 2 * M_PI / $nbrpnts;
		$a = $startangle;
		$i = 0;
		for ( ;	$i < $nbrpnts;	++$i	)
		{
			$cs = $scale->RelTranslate( $this->data[$i] );
			$x = round( $cs * cos( $a ) + $scale->scale_abs[0] );
			$y = round( $pos - $cs * sin( $a ) );
			$pnts[$i * 2] = $x;
			$pnts[$i * 2 + 1] = $y;
			$a += $astep;
		}
		if ( $this->fill )
		{
			$img->SetColor( $this->fill_color );
			$img->FilledPolygon( $pnts );
		}
		$img->SetLineWeight( $this->weight );
		$img->SetColor( $this->color );
		$img->SetLineStyle( $this->linestyle );
		$pnts[] = $pnts[0];
		$pnts[] = $pnts[1];
		$img->Polygon( $pnts );
		$img->SetLineStyle( "solid" );
		if ( $this->mark->show )
		{
			$i = 0;
			for ( ;	$i < $nbrpnts;	++$i	)
			{
				$this->mark->Stroke( $img, $pnts[$i * 2], $pnts[$i * 2 + 1] );
			}
		}
	}

	public function GetCount( )
	{
		return count( $this->data );
	}

	public function Legend( $graph )
	{
		if ( $this->legend == "" )
		{
			return;
		}
		if ( $this->fill )
		{
			$graph->legend->Add( $this->legend, $this->fill_color, $this->mark );
		}
		else
		{
			$graph->legend->Add( $this->legend, $this->color, $this->mark );
		}
	}

}

require_once( "jpgraph_plotmark.inc.php" );
class RadarLogTicks extends Ticks
{

	public function RadarLogTicks( )
	{
	}

	public function Stroke( $aImg, &$grid, $aPos, $aAxisAngle, $aScale, &$aMajPos, &$aMajLabel )
	{
		$start = $aScale->GetMinVal( );
		$limit = $aScale->GetMaxVal( );
		$nextMajor = 10 * $start;
		$step = $nextMajor / 10;
		$count = 1;
		$ticklen_maj = 5;
		$dx_maj = round( sin( $aAxisAngle ) * $ticklen_maj );
		$dy_maj = round( cos( $aAxisAngle ) * $ticklen_maj );
		$ticklen_min = 3;
		$dx_min = round( sin( $aAxisAngle ) * $ticklen_min );
		$dy_min = round( cos( $aAxisAngle ) * $ticklen_min );
		$aMajPos = array( );
		$aMajLabel = array( );
		if ( $this->supress_first )
		{
			$aMajLabel[] = "";
		}
		else
		{
			$aMajLabel[] = $start;
		}
		$yr = $aScale->RelTranslate( $start );
		$xt = round( $yr * cos( $aAxisAngle ) ) + $aScale->scale_abs[0];
		$yt = $aPos - round( $yr * sin( $aAxisAngle ) );
		$aMajPos[] = $xt + 2 * $dx_maj;
		$aMajPos[] = $yt - $aImg->GetFontheight( ) / 2;
		$grid[] = $xt;
		$grid[] = $yt;
		$aImg->SetLineWeight( $this->weight );
		$y = $start;
		for ( ;	$y <= $limit;	$y += $step,	++$count	)
		{
			$yr = $aScale->RelTranslate( $y );
			$xt = round( $yr * cos( $aAxisAngle ) ) + $aScale->scale_abs[0];
			$yt = $aPos - round( $yr * sin( $aAxisAngle ) );
			if ( $count % 10 == 0 )
			{
				$grid[] = $xt;
				$grid[] = $yt;
				$aMajPos[] = $xt + 2 * $dx_maj;
				$aMajPos[] = $yt - $aImg->GetFontheight( ) / 2;
				if ( !$this->supress_tickmarks )
				{
					if ( $this->majcolor != "" )
					{
						$aImg->PushColor( $this->majcolor );
					}
					$aImg->Line( $xt + $dx_maj, $yt + $dy_maj, $xt - $dx_maj, $yt - $dy_maj );
					if ( $this->majcolor != "" )
					{
						$aImg->PopColor( );
					}
				}
				if ( $this->label_formfunc != "" )
				{
					$f = $this->label_formfunc;
					$l = call_user_func( $f, $nextMajor );
				}
				else
				{
					$l = $nextMajor;
				}
				$aMajLabel[] = $l;
				$nextMajor *= 10;
				$step *= 10;
				$count = 1;
			}
			else if ( !$this->supress_minor_tickmarks )
			{
				if ( $this->mincolor != "" )
				{
					$aImg->PushColor( $this->mincolor );
				}
				$aImg->Line( $xt + $dx_min, $yt + $dy_min, $xt - $dx_min, $yt - $dy_min );
				if ( $this->mincolor != "" )
				{
					$aImg->PopColor( );
				}
			}
		}
	}

}

class RadarLinearTicks extends Ticks
{

	private $minor_step = 1;
	private $major_step = 2;
	private $xlabel_offset = 0;
	private $xtick_offset = 0;
	private $maj_ticks_pos = array( );

	public function RadarLinearTicks( )
	{
	}

	public function GetMajor( )
	{
		return $this->major_step;
	}

	public function GetMinor( )
	{
		return $this->minor_step;
	}

	public function Set( $aMajStep, $aMinStep = false )
	{
		if ( $aMinStep == false )
		{
			$aMinStep = $aMajStep;
		}
		if ( $aMajStep <= 0 || $aMinStep <= 0 )
		{
			JpGraphError::raise( " Minor or major step size is 0. Check that you haven't\n\t\t\t\tgot an accidental SetTextTicks(0) in your code.<p>\n\t\t\t\tIf this is not the case you might have stumbled upon a bug in JpGraph.\n\t\t\t\tPlease report this and if possible include the data that caused the\n\t\t\t\tproblem." );
		}
		$this->major_step = $aMajStep;
		$this->minor_step = $aMinStep;
		$this->is_set = true;
	}

	public function Stroke( $aImg, &$grid, $aPos, $aAxisAngle, $aScale, &$aMajPos, &$aMajLabel )
	{
		$maj_step_abs = abs( $aScale->scale_factor * $this->major_step );
		$min_step_abs = abs( $aScale->scale_factor * $this->minor_step );
		$nbrmaj = floor( $aScale->world_abs_size / $maj_step_abs );
		$nbrmin = floor( $aScale->world_abs_size / $min_step_abs );
		$skip = round( $nbrmin / $nbrmaj );
		$ticklen2 = $this->major_abs_size;
		$dx = round( sin( $aAxisAngle ) * $ticklen2 );
		$dy = round( cos( $aAxisAngle ) * $ticklen2 );
		$label = $aScale->scale[0] + $this->major_step;
		$aImg->SetLineWeight( $this->weight );
		$aMajPos = array( );
		$aMajLabel = array( );
		$i = 1;
		for ( ;	$i <= $nbrmaj;	++$i	)
		{
			$xt = round( $i * $maj_step_abs * cos( $aAxisAngle ) ) + $aScale->scale_abs[0];
			$yt = $aPos - round( $i * $maj_step_abs * sin( $aAxisAngle ) );
			if ( $this->label_formfunc != "" )
			{
				$f = $this->label_formfunc;
				$l = call_user_func( $f, $label );
			}
			else
			{
				$l = $label;
			}
			$aMajLabel[] = $l;
			$label += $this->major_step;
			$grid[] = $xt;
			$grid[] = $yt;
			$aMajPos[( $i - 1 ) * 2] = $xt + 2 * $dx;
			$aMajPos[( $i - 1 ) * 2 + 1] = $yt - $aImg->GetFontheight( ) / 2;
			if ( !$this->supress_tickmarks )
			{
				if ( $this->majcolor != "" )
				{
					$aImg->PushColor( $this->majcolor );
				}
				$aImg->Line( $xt + $dx, $yt + $dy, $xt - $dx, $yt - $dy );
				if ( $this->majcolor != "" )
				{
					$aImg->PopColor( );
				}
			}
		}
		$ticklen2 = $this->minor_abs_size;
		$dx = round( sin( $aAxisAngle ) * $ticklen2 );
		$dy = round( cos( $aAxisAngle ) * $ticklen2 );
		if ( !$this->supress_tickmarks || !$this->supress_minor_tickmarks )
		{
			if ( $this->mincolor != "" )
			{
				$aImg->PushColor( $this->mincolor );

⌨️ 快捷键说明

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