Location: PHPKode > projects > XDB Money > money/xdbgraph.php
<?php

//	Class to create graphs 

//	Author: 	Carl Beech

//	History:	24/4/03	- Initial Creation

//	Overview
//	========

//	Basic class which creates a graphic file. NOTE: the graphic is put into a filename
//	that the class creates dynamically, so that multiple users can use the same system

//	Note that the program DOES NOT use the header function as this means only one graph
//	can be output and no formatting text, or inclusion within a web page.


class xdbgraph {

//	-----------------------------DEFAULTS--------------------------------------
var $Default_Filename="output_file";

var $Default_Output_Location="graphics";

var $Default_Expiry_Time=60;		//	Delete graphics files more than 1 mins old.

var $Override_Graphics_Format="JPG";	//	Or use 'AUTO' to let the routine pick it's own or JPG/PNG/GIF
					//	Depending upon your internet server setup i.e. what version of 
					//	GD you've got installed.

var $Default_Background_Image="none";	//	If anything else but NONE, the program will attempt to read that
					//	as the image name. NOTE: if an image is used as a background,
					//	the Graphic Size parameter must be the same size as the graphic
					//	used.

var $Default_ImageSize_X=100;
var $Default_ImageSize_Y=50;

var $Default_Display_Value_Labels=0;	//	Don't display value labels.
var $Default_Display_Yaxis_Labels=1;	//	Display Y axis labels.
var $Default_Display_Xaxis_Labels=1;	//	Display X axis labels.

var $Default_X_Range_Low=0;
var $Default_X_Range_High=100;
var $Default_Y_Range_Low=0;
var $Default_Y_Range_High=100;

var $Default_X_Scale=1;			//	i.e. 1:1 scaling factor
var $Default_Y_Scale=1;			//	i.e. 1:1 scaling factor

var $Default_XAxis_Width=20;		//	Space to allow for X and Y axes.
var $Default_YAxis_Width=20;

var $Default_No_Items=1;		//	For lines and bars. - to work out the distance between points.

var $Default_BorderColor_r=0;
var $Default_BorderColor_g=0;
var $Default_BorderColor_b=0;

var $Default_TitleColor_r=0;
var $Default_TitleColor_g=0;
var $Default_TitleColor_b=250;

var $Default_AxisColor_r=120;
var $Default_AxisColor_g=120;
var $Default_AxisColor_b=120;

var $Default_DrawColor_r=0;
var $Default_DrawColor_g=0;
var $Default_DrawColor_b=0;
var $Default_Bar_Width=10;
var $Default_PointSize=2;		//	Points are 2 pixels square.

var $Default_GridYColor_r=-1;		//	-1 means no grid - simply give it a colour to turn it on.
var $Default_GridYColor_g=-1;
var $Default_GridYColor_b=-1;

var $Default_GridXColor_r=-1;
var $Default_GridXColor_g=-1;
var $Default_GridXColor_b=-1;

var $Default_GridCount=5;		//	There are 5 grid lines on the graph by default

var $Default_TitleText="Graph";
var $Default_TitleFont=5;
var $Default_TitlePos=5;		//	How far down to begin drawing

var $Default_XAxisTitle="X Axis";
var $Default_YAxisTitle="Y Axis";
var $Default_AxisFont=1;

var $Debug_Level=0;			//	0 - off, 	1 -lowest,	9-highest

//	-----------------------------END DEFAULTS--------------------------------------

var $Supported_Graphic;

var $Output_Filename;

var $ImageID;

var $Background_Image;

var $Display_Value_Labels;
var $Display_Xaxis_Labels;
var $Display_Yaxis_Labels;

var $X_Origin;
var $Y_Origin;

var $ImageTextColor;

var $ImageBackGroundColor;

var $ImageBorderColor;

var $ImageAxisColor;

var $DrawColor_r;
var $DrawColor_g;
var $DrawColor_b;
var $ImageDrawColor;

var $ColorBlack;
var $ColorWhite;
var $ColorGrey;
var $ColorLtGrey;
var $ColorDkGrey;
var $ColorRed;
var $ColorLtRed;
var $ColorDkRed;
var $ColorOrange;
var $ColorLtOrange;
var $ColorDkOrange;
var $ColorYellow;
var $ColorLtYellow;
var $ColorDkYellow;
var $ColorGreen;
var $ColorLtGreen;
var $ColorDkGreen;
var $ColorBlue;
var $ColorLtBlue;
var $ColorDkBlue;
var $ColorIndego;
var $ColorLtIndego;
var $ColorDkIndego;
var $ColorViolet;
var $ColorLtViolet;
var $ColorDkViolet;



var $PointSize;

var $GridYColor_r;
var $GridYColor_g;
var $GridYColor_b;
var $GridYColor;
var $GridXColor_r;
var $GridXColor_g;
var $GridXColor_b;
var $GridXColor;
var $GridCount;

var $ImageSizeX;

var $ImageSizeY;

var $X_Range_Low=0;
var $X_Range_High=100;
var $Y_Range_Low=0;
var $Y_Range_High=100;

var $X_Scale;
var $Y_Scale;

var $No_Items;
var $Inter_Point_Distance;
var $Bar_Width;

var $LastXPoint;		//	Used when plotting continuous lines / bars.
var $LastYPoint;

var $LastXPoint_set;		//	Lets the system know if this is a new plot - not to save old values
var $LastYPoint_set;		//	Lets the system know if this is a new plot - not to save old values

var $TitleText;
var $XAxisTitle;
var $YAxisTitle;
var $CenterPos;

var $GeneralXpoint;
var $GeneralYpoint;
var $GeneralX1point;
var $GeneralY1point;

var $Pie_MidX;
var $Pie_MidY;
var $Pie_Diameter;
var $Pie_OriginX;
var $Pie_OriginY;

//	Contructor class: initialisation.

function xdbgraph() {

if ( $this->Debug_Level > 0 )
	printf("\n<br>XDBDebug: xdbgraph: initialise");

//	Check: do we have graph support? if so, what?
if (function_exists("imagegif")) {
	$this->Supported_Graphic="GIF";
	}
elseif (function_exists("imagejpeg")) {
	$this->Supported_Graphic="JPG";
	}
elseif (function_exists("imagepng")) {
	$this->Supported_Graphic="PNG";
	}
elseif (function_exists("imagewbmp")) {
	$this->Supported_Graphic="BMP";
	}
else
	{
	$this->Supported_Graphic="NONE";
	die("No image support in this PHP server");
	}

if ( $this->Override_Graphics_Format != "AUTO" )
	$this->Supported_Graphic=$this->Override_Graphics_Format;

if ( $this->Debug_Level > 0 )
	printf("\n<br>XDBDebug: xdbgraph: Found: %s",$this->Supported_Graphic);

//	Default the background image to NONE

$this->Background_Image=$this->Default_Background_Image;


//	Create the default sizes

$this->ImageSizeX=$this->Default_ImageSize_X + $this->Default_XAxis_Width;
$this->ImageSizeY=$this->Default_ImageSize_Y + $this->Default_YAxis_Width;

//	Create the default titles

$this->TitleText = $this->Default_TitleText;
$this->XAxisTitle = $this->Default_XAxisTitle;
$this->YAxisTitle = $this->Default_YAxisTitle;

//	Create the default no of items

$this->No_Items = $this->Default_No_Items;
$this->Inter_Point_Distance=( $this->ImageSizeX - $this->Default_XAxis_Width ) / ($this->No_Items+1);
$this->Bar_Width=$this->Inter_Point_Distance-5;
$this->LastXPoint=$this->Default_YAxis_Width;			//	Start at beginning.
$this->LastYPoint=$this->ImageSizeY-$this->Default_XAxis_Width;			//	Start at beginning.
$this->LastXPoint_set="no";
$this->LastYPoint_set="no";

//	Default drawcolor
$this->DrawColor_r = $this->Default_DrawColor_r=0;
$this->DrawColor_g = $this->Default_DrawColor_g=0;
$this->DrawColor_b = $this->Default_DrawColor_b=0;

//	Default graph range to draw points and scaling factors
$this->X_Range_Low=$this->Default_X_Range_Low;
$this->X_Range_High=$this->Default_X_Range_High;
$this->Y_Range_Low=$this->Default_Y_Range_Low;
$this->Y_Range_High=$this->Default_Y_Range_High;

$this->X_Scale=$this->Default_X_Scale;
$this->Y_Scale=$this->Default_Y_Scale;

//	And default grid colours
$this->GridYColor_r=$this->Default_GridYColor_r;
$this->GridYColor_g=$this->Default_GridYColor_g;
$this->GridYColor_b=$this->Default_GridYColor_b;
$this->GridXColor_r=$this->Default_GridXColor_r;
$this->GridXColor_g=$this->Default_GridXColor_g;
$this->GridXColor_b=$this->Default_GridXColor_b;

$this->GridCount=$this->Default_GridCount;

//	Default point / line size
$this->PointSize = $this->Default_PointSize;

//	Whether value labels should be displayed
$this->Display_Value_Labels= $this->Default_Display_Value_Labels;

$this->Display_Xaxis_Labels= $this->Default_Display_Xaxis_Labels;
$this->Display_Yaxis_Labels= $this->Default_Display_Yaxis_Labels;

//	As part of initialisation -read all graphic files within the directory, and
//	delete all those who are more than the expiry time.

// $this->$Default_Expiry_Time;

$DirectoryHandle=opendir($this->Default_Output_Location);

while (( $GraphicFile = readdir ( $DirectoryHandle )) !==false) {

	$GraphicFile=$this->Default_Output_Location."/".$GraphicFile;
	$ModificationTime=filemtime($GraphicFile);
	$FileAge=time()-$ModificationTime;
	if ( $this->Debug_Level > 0 )
		printf("\n<br>Filename:%s, Modified:%d Age:%d",$GraphicFile,$ModificationTime,$FileAge );
	if( $FileAge > $this->Default_Expiry_Time && is_file($GraphicFile) )
		{
		//	File is too old (and it isn't a directory (. / ..) : remove it.
		if ( $this->Debug_Level > 0 )
			printf(" - Removing file ");
		unlink( $GraphicFile );		
		}
	}

}


function xdbgraph_report_graphictype() {

printf("%s",$this->Supported_Graphic);
}



function xdbgraph_set_ranges($XLow,$XHigh,$YLow,$YHigh) {

$this->X_Range_Low=$XLow;
$this->X_Range_High=$XHigh;
$this->Y_Range_Low=$YLow;
$this->Y_Range_High=$YHigh;

//	Work out scaling factors - multiply by 0.9 to ensure it all fits in the area.
$this->X_Scale=0.9*($this->ImageSizeX / ($this->X_Range_High - $this->X_Range_Low));
$this->Y_Scale=0.9*($this->ImageSizeY / ($this->Y_Range_High - $this->Y_Range_Low));

$this->X_Origin=($XLow*-1)*$this->X_Scale;
$this->Y_Origin=($YLow)*$this->Y_Scale;

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: setRange: Xl:%d Xh:%d Yl:%d Yh:%d ScaleX:%d ScaleY:%d, OriginX:%d, OriginY:%d",
		$XLow,$XHigh,$YLow,$YHigh,$this->X_Scale,$this->Y_Scale,$this->X_Origin,$this->Y_Origin);

}



function xdbgraph_graph_title($GraphTitle) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: GraphTitle: %s",$GraphTitle);

$this->TitleText=$GraphTitle;

}


function xdbgraph_xaxis_title($GraphTitle) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: X Axis Title: %s",$GraphTitle);

$this->XAxisTitle=$GraphTitle;

}


function xdbgraph_yaxis_title($GraphTitle) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Y Axis Title: %s",$GraphTitle);

$this->YAxisTitle=$GraphTitle;

}


function xdbgraph_graphic_size ($Xsize,  $Ysize) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: ImageResize: %dx%d",$Xsize,$Ysize);

$this->ImageSizeX=$Xsize + $this->Default_XAxis_Width;
$this->ImageSizeY=$Ysize + $this->Default_YAxis_Width;
}

/*
function xdbgraph_set_draw_color ($DrawRed, $DrawGreen, $DrawBlue) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set DrawColor: R%d G%d B%d",$DrawRed,$DrawGreen,$DrawBlue);

$this->DrawColor_r=$DrawRed;
$this->DrawColor_g=$DrawGreen;
$this->DrawColor_b=$DrawBlue;
$this->ImageDrawColor = ImageColorAllocate ($this->ImageID, $this->DrawColor_r, 
								$this->DrawColor_g, 
								$this->DrawColor_b);
}
*/

function xdbgraph_set_draw_color ($SetColor) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set DrawColor: Setcolor %s",$SetColor);

switch ( strtoupper($SetColor) ){

	case "BLACK":
		$this->ImageDrawColor=$this->ColorBlack;
		break;
	case "WHITE":
		$this->ImageDrawColor=$this->ColorWhite;
		break;
	case "GREY":
		$this->ImageDrawColor=$this->ColorGrey;
		break;
	case "LTGREY":
		$this->ImageDrawColor=$this->ColorLtGrey;
		break;
	case "DKGREY":
		$this->ImageDrawColor=$this->ColorDkGrey;
		break;
	case "RED":
		$this->ImageDrawColor=$this->ColorRed;
		break;
	case "LTRED":
		$this->ImageDrawColor=$this->ColorLtRed;
		break;
	case "DKRED":
		$this->ImageDrawColor=$this->ColorDkRed;
		break;
	case "ORANGE":
		$this->ImageDrawColor=$this->ColorOrange;
		break;
	case "LTORANGE":
		$this->ImageDrawColor=$this->ColorLtOrange;
		break;
	case "DKORANGE":
		$this->ImageDrawColor=$this->ColorDkOrange;
		break;
	case "YELLOW":
		$this->ImageDrawColor=$this->ColorYellow;
		break;
	case "LTYELLOW":
		$this->ImageDrawColor=$this->ColorLtYellow;
		break;
	case "DKYELLOW":
		$this->ImageDrawColor=$this->ColorDkYellow;
		break;
	case "GREEN":
		$this->ImageDrawColor=$this->ColorGreen;
		break;
	case "LTGREEN":
		$this->ImageDrawColor=$this->ColorLtGreen;
		break;
	case "DKGREEN":
		$this->ImageDrawColor=$this->ColorDkGreen;
		break;
	case "BLUE":
		$this->ImageDrawColor=$this->ColorBlue;
		break;
	case "LTBLUE":
		$this->ImageDrawColor=$this->ColorLtBlue;
		break;
	case "DKBLUE":
		$this->ImageDrawColor=$this->ColorDkBlue;
		break;
	case "INDEGO":
		$this->ImageDrawColor=$this->ColorIndego;
		break;
	case "LTINDEGO":
		$this->ImageDrawColor=$this->ColorLtIndego;
		break;
	case "DKINDEGO":
		$this->ImageDrawColor=$this->ColorDkIndego;
		break;
	case "VIOLET":
		$this->ImageDrawColor=$this->ColorViolet;
		break;
	case "LTVIOLET":
		$this->ImageDrawColor=$this->ColorLtViolet;
		break;
	case "DKVIOLET":
		$this->ImageDrawColor=$this->ColorDkViolet;
		break;
	default:
		$this->ImageDrawColor=$this->ColorBlack;
		break;
	}
}


function xdbgraph_set_xgrid_color ($DrawRed, $DrawGreen, $DrawBlue) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set XGridColor: R%d G%d B%d",$DrawRed,$DrawGreen,$DrawBlue);

$this->GridXColor_r=$DrawRed;
$this->GridXColor_g=$DrawGreen;
$this->GridXColor_b=$DrawBlue;
}


function xdbgraph_set_ygrid_color ($DrawRed, $DrawGreen, $DrawBlue) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set YGridColor: R%d G%d B%d",$DrawRed,$DrawGreen,$DrawBlue);

$this->GridYColor_r=$DrawRed;
$this->GridYColor_g=$DrawGreen;
$this->GridYColor_b=$DrawBlue;
}


function xdbgraph_set_grid_count ($GridCount) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set GridCount: %d",$GridCount);

$this->GridCount=$GridCount;
}



function xdbgraph_set_display_values ($ValueLabels) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set ValueLabel: %d",$ValueLabels);

$this->Display_Value_Labels=$ValueLabels;
}


function xdbgraph_set_display_yaxis_labels ($ValueLabels) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set YaxisLabel: %d",$ValueLabels);

$this->Display_Yaxis_Labels=$ValueLabels;
}


function xdbgraph_set_display_xaxis_labels ($ValueLabels) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set XaxisLabel: %d",$ValueLabels);

$this->Display_Xaxis_Labels=$ValueLabels;
}



function xdbgraph_set_background_image ($ImageName) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set Background: %s",$ImageName);


$this->Background_Image=$ImageName;
}


function xdbgraph_set_pointsize ($PSize) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set Pointsize: %d",$PSize);

$this->PointSize=$PSize;
}



function xdbgraph_start_image () {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: StartImage: ");

//	Create the image.

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: StartImage: Background %s",$this->Background_Image);

if ( $this->Background_Image=="none" )
	{
	//	No image specified - use a normal blank background
	$this->ImageID=@ImageCreate ($this->ImageSizeX, $this->ImageSizeY)
	or die ("Cannot Initialize new GD image stream");
	}
else
	{
	$this->ImageID=@ImageCreateFromJPEG($this->Background_Image) or die (" Cannot use / find image $this->Background_Image");
	}

$this->ImageBackGroundColor = ImageColorAllocate ($this->ImageID, 255, 255, 255);

//	Put a border around the image
$this->ImageBorderColor = ImageColorAllocate ($this->ImageID, $this->Default_BorderColor_r, 
								$this->Default_BorderColor_g, 
								$this->Default_BorderColor_b);
if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Create border:");

imagerectangle( $this->ImageID,0,0,$this->ImageSizeX-1,$this->ImageSizeY-1, $this->ImageBorderColor);


//	Create and allocate all the pre-set colors - these can be used later for efficiency.
$this->ColorBlack=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorWhite=ImageColorAllocate ($this->ImageID, 255,255,255);
$this->ColorGrey=ImageColorAllocate ($this->ImageID, 128,128,128);
$this->ColorLtGrey=ImageColorAllocate ($this->ImageID, 200,200,200);
$this->ColorDkGrey=ImageColorAllocate ($this->ImageID, 50,50,50);
$this->ColorRed=ImageColorAllocate ($this->ImageID, 255,0,0);
$this->ColorLtRed=ImageColorAllocate ($this->ImageID, 255,128,128);
$this->ColorDkRed=ImageColorAllocate ($this->ImageID, 128,0,0);
$this->ColorOrange=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorLtOrange=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorDkOrange=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorYellow=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorLtYellow=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorDkYellow=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorGreen=ImageColorAllocate ($this->ImageID, 0,255,0);
$this->ColorLtGreen=ImageColorAllocate ($this->ImageID, 128,255,128);
$this->ColorDkGreen=ImageColorAllocate ($this->ImageID, 0,128,0);
$this->ColorBlue=ImageColorAllocate ($this->ImageID, 0,0,255);
$this->ColorLtBlue=ImageColorAllocate ($this->ImageID, 128,128,255);
$this->ColorDkBlue=ImageColorAllocate ($this->ImageID, 0,0,128);
$this->ColorIndego=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorLtIndego=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorDkIndego=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorViolet=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorLtViolet=ImageColorAllocate ($this->ImageID, 0,0,0);
$this->ColorDkViolet=ImageColorAllocate ($this->ImageID, 0,0,0);
}


function xdbgraph_plot_point ($Xpos,  $Ypos) {

// imagesetpixel($this->ImageID,$Xsize,$Ysize,$this->ImageDrawColor);

$this->GeneralYpoint=($this->ImageSizeY-($Ypos * $this->Y_Scale))- $this->Default_XAxis_Width;
$this->GeneralXpoint=($Xpos * $this->X_Scale) + $this->Default_YAxis_Width;

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotPoint: %dx%d (Real: %dx%d)",$Xpos,$Ypos,$this->GeneralXpoint,$this->GeneralYpoint);

for ($i=0; $i< $this->PointSize; $i=$i+1 )
	{
	for ($j=0; $j< $this->PointSize; $j=$j+1 )
		{
		imagesetpixel($this->ImageID,$this->GeneralXpoint+$this->X_Origin+$i,$this->GeneralYpoint+$this->Y_Origin+$j,$this->ImageDrawColor);
		}
	}

if ($this->Display_Value_Labels==1)
	{
	ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralXpoint+$this->X_Origin,$this->GeneralYpoint-10+$this->Y_Origin, $Xpos."x".$Ypos, $this->ImageDrawColor);
	}
}



function xdbgraph_set_no_points($NoPoints) {

$this->No_Items=$NoPoints;

$this->Inter_Point_Distance=( $this->ImageSizeX - $this->Default_XAxis_Width ) / ($this->No_Items+1);
$this->Bar_Width=$this->Inter_Point_Distance-5;

if ( $this->Debug_Level > 0 )
	{
        printf("\n<br>XDBDebug: xdbgraph: no points set to: %d, InterPointDistance:%d, Bar_Width:%d",
			$this->No_Items,
			$this->Inter_Point_Distance,
			$this->Bar_Width);
	}

$this->LastXPoint=$this->Default_YAxis_Width;			//	Start at beginning.
$this->LastYPoint=$this->ImageSizeY-$this->Default_XAxis_Width;			//	Start at beginning.

}







function xdbgraph_plot_sets ( $DataSetArray, $PlotTypeArray ) {

//	Get an array of array sets.


if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotSets:");

$MaxXVal="NotSet";
$MinXVal="NotSet";
$MaxYVal="NotSet";
$MinYVal="NotSet";
$MaxNoItems=0;

$PlotType="LINE";

//	Go through all elements of the array - get the parameters of the graph
 
foreach( $DataSetArray as $ArrayName => $DataSet )
	{

	$NoItems=0;

	if ( $this->Debug_Level > 0 )
        	printf("\n<br>XDBDebug: xdbgraph: PlotSets: Set:(%s)",$ArrayName);

	foreach( $DataSet as $ArrayElement )
		{
		if( $MaxXVal=="NotSet" )
			{
			$MaxXVal=$ArrayElement->DataXValue;
			$MinaXVal=$ArrayElement->DataXValue;
			}		

		if( $MaxYVal=="NotSet" )
			{
			$MaxYVal=$ArrayElement->DataYValue;
			$MinYVal=$ArrayElement->DataYValue;
			}		

		if( $ArrayElement->DataXValue > $MaxXVal )
			{
			$MaxXVal=$ArrayElement->DataXValue;
			}

		if( $ArrayElement->DataXValue < $MinaXVal )
			{
			$MinaXVal=$ArrayElement->DataXValue;
			}

		if( $ArrayElement->DataYValue > $MaxYVal )
			{
			$MaxYVal=$ArrayElement->DataYValue;
			}

		if( $ArrayElement->DataYValue < $MinYVal )
			{
			$MinYVal=$ArrayElement->DataYValue;
			}

		if ( $this->Debug_Level > 0 )
			printf("<br>xdbgraph_plot_Sets ValueY:%d, ValueX:%d, Color:%s, Tag:%s, MinX:%d,MaxX:%d MinY:%d,MaxY:%d",
				$ArrayElement->DataYValue, 
				$ArrayElement->DataXValue, 
				$ArrayElement->DataColor, 
				$ArrayElement->DataTag,
				$MinaXVal,
				$MaxXVal,
				$MinYVal,
				$MaxYVal);


		$NoItems=$NoItems+1;
		}

	if( $NoItems > $MaxNoItems )
		{
		$MaxNoItems=$NoItems;
		}

	}

if ( $this->Debug_Level > 0 )
	printf("<br>xdbgraph_plot_set: Pass 1 complete MinX:%d, MaxX:%d, MinY:%d, MaxY:%d, No:%d",
		$MinXVal, $MaxXVal, $MinYVal, $MaxYVal, $NoItems); 


$this->xdbgraph_set_ranges($MinaXVal,$MaxXVal,$MinYVal,$MaxYVal);
$this->xdbgraph_set_grid_count($MaxNoItems);



foreach ( $DataSetArray as $SetName => $DataSet )
	{
	$this->xdbgraph_set_no_points($MaxNoItems);
	if( $PlotTypeArray[$SetName]=="BAR")
		{
		$this->xdbgraph_plot_bar_array( $DataSet,"N" );
		}
		
	if( $PlotTypeArray[$SetName]=="LINE")
		{
		$this->xdbgraph_plot_line_array( $DataSet,"N" );
		}
		
	}

if ($PlotTypeArray["PARAMETERS_CUSTOM_XAXIS_TITLES"]==1)
	{
	/*	Use custom X axis title array	*/
	/*	Setup */
	$this->xdbgraph_set_ranges($MinXVal,$MaxXVal,$MinYVal,$MaxYVal);
	$this->xdbgraph_set_grid_count($NoItems);
	$this->xdbgraph_set_no_points($NoItems);

	$this->xdbgraph_custom_xaxis_titles( $PlotTypeArray["XAXIS_TITLES"] );
	}

if ($PlotTypeArray["PARAMETERS_CUSTOM_YAXIS_TITLES"]==1)
	{
	/*	Use custom Y axis title array	*/
	$this->xdbgraph_custom_yaxis_titles( $PlotTypeArray["YAXIS_TITLES"] );
	}

}



function xdbgraph_custom_xaxis_titles ($TitleArray) {


/*	Create bottom titles	*/

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Create Custom x axis:");

$this->CenterPos=($this->ImageSizeX / 2)- (strlen($this->XAxisTitle)*5);

ImageString ($this->ImageID, $this->Default_AxisFont, $this->CenterPos,$this->ImageSizeY-10, $this->XAxisTitle, $this->ImageTextColor);

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Create X axis labels: count:%d",$this->GridCount);

//	Go through all elements of the array - get the parameters of the graph

//	Put the axis titles on - note that we use the same logic as the plot line.

$this->ImageTextColor = ImageColorAllocate ($this->ImageID, $this->Default_TitleColor_r, 
						$this->Default_TitleColor_g, 
						$this->Default_TitleColor_b);

foreach( $TitleArray as $TitleName)
	{

	if ( $this->Debug_Level > 0 )
	        printf("\n<br>XDBDebug: xdbgraph: PlotLine: %d",$Ypos);

	$this->GeneralXpoint=$this->LastXPoint;
	$this->GeneralYpoint=$this->LastYPoint;

	$this->GeneralY1point=($this->ImageSizeY-($Ypos * $this->Y_Scale))- $this->Default_XAxis_Width;
	$this->GeneralX1point=$this->LastXPoint + $this->Inter_Point_Distance;

	if ( $this->Debug_Level > 0 )
	        printf(" > x1:%d,y1:%d, x2:%d, y2:%d",$this->GeneralXpoint,$this->GeneralYpoint,
				   $this->GeneralX1point,$this->GeneralY1point);

	if ($this->LastXPoint_set=="YES" || $this->LastYPoint_set=="YES")
		{
		ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralX1point, $this->ImageSizeY-20, $TitleName, $this->ImageTextColor);

		}
	
	$this->LastXPoint_set="YES";
	$this->LastYPoint_set="YES";

	$this->LastXPoint=$this->GeneralX1point;
	$this->LastYPoint=$this->GeneralY1point;
	}




}



function xdbgraph_custom_Yaxis_titles ($TitleArray) {

printf("\n<br>Title Y Custom");


}






function xdbgraph_plot_line_array ($DataArray, $SetRanges="Y") {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotLineArray:");

//	Set the graph ranges
if ( $SetRanges=="Y" )
	{

	$MaxXVal="NotSet";
	$MinXVal="NotSet";
	$MaxYVal="NotSet";
	$MinYVal="NotSet";
	$NoItems=0;

	//	Go through all elements of the array - get the parameters of the graph
	foreach( $DataArray as $ArrayElement)
		{
		if ( $this->Debug_Level > 0 )
			printf("<br>xdbgraph_plot_line_array ValueY:%d, ValueX:%d, Color:%s, Tag:%s",
				$ArrayElement->DataYValue, 
				$ArrayElement->DataXValue, 
				$ArrayElement->DataColor, 
				$ArrayElement->DataTag);

		$XValues[]= $ArrayElement->DataXValue;
		$YValues[]= $ArrayElement->DataYValue;

		$NoItems=$NoItems+1;

		}

	$MinXVal=min($XValues);
	$MaxXVal=max($XValues);

	$MinYVal=min($YValues);
	$MaxYVal=max($YValues);

	if ( $this->Debug_Level > 0 )
		printf("<br>xdbgraph_plot_line_array: Pass 1 complete MinX:%d, MaxX:%d, MinY:%d, MaxY:%d, No:%d",
			$MinXVal, $MaxXVal, $MinYVal, $MaxYVal, $NoItems); 

	$this->xdbgraph_set_ranges($MinXVal,$MaxXVal,$MinYVal,$MaxYVal);
	$this->xdbgraph_set_grid_count($NoItems);
	$this->xdbgraph_set_no_points($NoItems);
	}

if ( $this->Debug_Level > 0 )
	printf("<br>xdbgraph_plot_line_array Pass 2: Plot points");

//	Go through all elements of the array - get the parameters of the graph
foreach( $DataArray as $ArrayElement)
	{
	$this->xdbgraph_set_draw_color($ArrayElement->DataColor);
	
	$this->xdbgraph_plot_line( $ArrayElement->DataYValue,$ArrayElement->DataTag);
	}

}




function xdbgraph_plot_bar_array ($DataArray, $SetRanges="Y") {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotBarArray:");

//	Set the graph ranges
if ( $SetRanges=="Y" )
	{

	$MaxXVal="NotSet";
	$MinXVal="NotSet";
	$MaxYVal="NotSet";
	$MinYVal="NotSet";
	$NoItems=0;

	//	Go through all elements of the array - get the parameters of the graph
	foreach( $DataArray as $ArrayElement)
		{
		if ( $this->Debug_Level > 0 )
			printf("<br>xdbgraph_plot_line_array ValueY:%d, ValueX:%d, Color:%s, Tag:%s",
				$ArrayElement->DataYValue, 
				$ArrayElement->DataXValue, 
				$ArrayElement->DataColor, 
				$ArrayElement->DataTag);

		$XValues[]= $ArrayElement->DataXValue;
		$YValues[]= $ArrayElement->DataYValue;

		$NoItems=$NoItems+1;

		}

	$MinXVal=min($XValues);
	$MaxXVal=max($XValues);

	$MinYVal=min($YValues);
	$MaxYVal=max($YValues);

	if ( $this->Debug_Level > 0 )
		printf("<br>xdbgraph_plot_bar_array: Pass 1 complete MinX:%d, MaxX:%d, MinY:%d, MaxY:%d, No:%d",
			$MinXVal, $MaxXVal, $MinYVal, $MaxYVal, $NoItems); 

	//	Set the graph ranges
	$this->xdbgraph_set_ranges($MinXVal,$MaxXVal,$MinYVal,$MaxYVal);
	$this->xdbgraph_set_grid_count($NoItems);
	$this->xdbgraph_set_no_points($NoItems);
	}
	
if ( $this->Debug_Level > 0 )
	printf("<br>xdbgraph_plot_bar_array Pass 2: Plot points");

//	Go through all elements of the array - get the parameters of the graph
foreach( $DataArray as $ArrayElement)
	{
	$this->xdbgraph_set_draw_color($ArrayElement->DataColor);
	
	$this->xdbgraph_plot_bar( $ArrayElement->DataYValue,$ArrayElement->DataTag);
	}

}




function xdbgraph_plot_line ($Ypos,$TitleText) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotLine: %d",$Ypos);

$this->GeneralXpoint=$this->LastXPoint;
$this->GeneralYpoint=$this->LastYPoint;

$this->GeneralY1point=($this->ImageSizeY-($Ypos * $this->Y_Scale))- $this->Default_XAxis_Width;
$this->GeneralX1point=$this->LastXPoint + $this->Inter_Point_Distance;

if ( $this->Debug_Level > 0 )
        printf(" > x1:%d,y1:%d, x2:%d, y2:%d",$this->GeneralXpoint,$this->GeneralYpoint,
			   $this->GeneralX1point,$this->GeneralY1point);

if ($this->LastXPoint_set=="YES" || $this->LastYPoint_set=="YES")
	{
	imageline( $this->ImageID, $this->GeneralXpoint,$this->GeneralYpoint+$this->Y_Origin,
			   $this->GeneralX1point,$this->GeneralY1point+$this->Y_Origin, $this->ImageDrawColor);

	}

$this->ImageTextColor = ImageColorAllocate ($this->ImageID, $this->Default_TitleColor_r, 
							$this->Default_TitleColor_g, 
							$this->Default_TitleColor_b);

if ($this->Display_Value_Labels==1)
	{
	ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralX1point,$this->GeneralY1point-10+$this->Y_Origin, $TitleText, $this->ImageDrawColor);
	}
else
	{	
	ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralX1point,$this->ImageSizeY-20, $TitleText, $this->ImageTextColor);
	}
	
	
$this->LastXPoint_set="YES";
$this->LastYPoint_set="YES";

$this->LastXPoint=$this->GeneralX1point;
$this->LastYPoint=$this->GeneralY1point;
}






function xdbgraph_plot_bar ($Ypos,$TitleText) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: PlotLine: %d",$Ypos);

$this->GeneralXpoint=$this->LastXPoint + ($this->Inter_Point_Distance*.5);
$this->GeneralYpoint=($this->ImageSizeY-($Ypos * $this->Y_Scale))- $this->Default_XAxis_Width;

$this->GeneralX1point=$this->LastXPoint+($this->Bar_Width*1.5);
$this->GeneralY1point=$this->ImageSizeY - $this->Default_XAxis_Width;

if ( $this->Debug_Level > 0 )
        printf(" > x1:%d,y1:%d, x2:%d, y2:%d",$this->GeneralXpoint,$this->GeneralYpoint,
			   $this->GeneralX1point,$this->GeneralY1point);

if($this->GeneralXpoint < $this->GeneralX1point )
	{
	$Xl=$this->GeneralXpoint;
	$Xh=$this->GeneralX1point;
	}
else
	{
	$Xh=$this->GeneralXpoint;
	$Xl=$this->GeneralX1point;
	}

if ( ($this->GeneralYpoint+$this->Y_Origin) < ($this->GeneralY1point+$this->Y_Origin))
	{
	$Yl=$this->GeneralYpoint+$this->Y_Origin;
	$Yh=$this->GeneralY1point+$this->Y_Origin;
	}
else
	{
	$Yh=$this->GeneralYpoint+$this->Y_Origin;
	$Yl=$this->GeneralY1point+$this->Y_Origin;
	}

imagefilledrectangle( $this->ImageID, $Xl,$Yl,$Xh,$Yh, $this->ImageDrawColor);

imagerectangle( $this->ImageID, $this->GeneralXpoint,$this->GeneralYpoint+$this->Y_Origin,
			   $this->GeneralX1point,$this->GeneralY1point+$this->Y_Origin, $this->ColorBlack);


$this->ImageTextColor = ImageColorAllocate ($this->ImageID, $this->Default_TitleColor_r, 
								$this->Default_TitleColor_g, 
								$this->Default_TitleColor_b);

if ($this->Display_Value_Labels==1)
	{
	ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralXpoint+($this->Bar_Width*.5),$this->GeneralYpoint-10+$this->Y_Origin, $TitleText, $this->ImageDrawColor);
	}
else
	{
	ImageString ($this->ImageID, $this->Default_AxisFont, $this->GeneralXpoint+($this->Bar_Width*.5),$this->ImageSizeY-20, $TitleText, $this->ImageTextColor);
	}
	
$this->LastXPoint=$this->LastXPoint+$this->Inter_Point_Distance;
}






function xdbgraph_render_image() {

$this->ImageTextColor = ImageColorAllocate ($this->ImageID, $this->Default_TitleColor_r, 
								$this->Default_TitleColor_g, 
								$this->Default_TitleColor_b);

$this->ImageAxisColor = ImageColorAllocate ($this->ImageID, $this->Default_AxisColor_r, 
								$this->Default_AxisColor_g, 
								$this->Default_AxisColor_b);
//	Put in the axes

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Create axes:");

imageline( $this->ImageID, 20,0, 20, $this->ImageSizeY-20, $this->ImageAxisColor );
imageline( $this->ImageID, 20,$this->ImageSizeY-20, $this->ImageSizeX, $this->ImageSizeY-20, $this->ImageAxisColor );


//	Put in graph title
if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Create title:");

$this->CenterPos=($this->ImageSizeX / 2)- (strlen($this->TitleText)*5);

ImageString ($this->ImageID, $this->Default_TitleFont, $this->CenterPos,$this->$Default_TitlePos, $this->TitleText, $this->ImageTextColor);


// printf("\n<br> Yaxis labels: (%d)",$this->Display_Yaxis_Labels);
// printf("\n<br> Xaxis labels: (%d)",$this->Display_Xaxis_Labels);

//	Only show Y axes if told to do so.
if ( $this->Display_Xaxis_Labels == 1)
	{
	if ( $this->Debug_Level > 0 )
	        printf("\n<br>XDBDebug: xdbgraph: Create y axis:");

	$this->CenterPos=($this->ImageSizeX / 2)- (strlen($this->XAxisTitle)*5);

	ImageString ($this->ImageID, $this->Default_AxisFont, $this->CenterPos,$this->ImageSizeY-10, $this->XAxisTitle, $this->ImageTextColor);

	if ( $this->Debug_Level > 0 )
	        printf("\n<br>XDBDebug: xdbgraph: Create Y axis labels: count:%d",$this->GridCount);

	$Interval=($this->X_Range_High - $this->X_Range_Low) / $this->GridCount;
	for ( $Loop=$this->X_Range_Low; $Loop <= $this->X_Range_High; $Loop=$Loop+$Interval )
		{
		$TextPos=$this->Default_YAxis_Width + ($Loop*$this->X_Scale);
	
		if ( $this->Debug_Level > 0 )
	        	printf("\n<br>XDBDebug: xdbgraph: Create X axis labels: '%s' @ %d (interval:%d)",$Loop,$TextPos,$Interval);

		ImageString ($this->ImageID, $this->Default_AxisFont, $TextPos+$this->X_Origin, $this->ImageSizeY-20, round($Loop), $this->ImageTextColor);

		//	And put in the Y grid if required.
		if ( $this->GridXColor_r > -1 )
			{
			//	Got a color turned on - create the grid.
			$this->GridXColor = ImageColorAllocate ($this->ImageID, $this->GridXColor_r, 
									$this->GridXColor_g, 
									$this->GridXColor_b);
			imageline( $this->ImageID, $TextPos+$this->X_Origin,0, $TextPos+$this->X_Origin, $this->ImageSizeY-20, $this->GridXColor );
			}
		}
	}


//	Only show X axes if told to do so.
if ( $this->Display_Yaxis_Labels == 1)
	{
	if ( $this->Debug_Level > 0 )
	        printf("\n<br>XDBDebug: xdbgraph: Create Y axis:");

	// $this->CenterPos=($this->ImageSizeY / 2)- (strlen($this->YAxisTitle)*5);
	$this->CenterPos=($this->ImageSizeY / 2);
	ImageStringUp ($this->ImageID, $this->Default_AxisFont, 1, $this->CenterPos, $this->YAxisTitle, $this->ImageTextColor);

	if ( $this->Debug_Level > 0 )
	        printf("\n<br>XDBDebug: xdbgraph: Create Y axis labels: count:%d",$this->GridCount);

	$Interval=($this->Y_Range_High - $this->Y_Range_Low) / $this->GridCount;
	for ( $Loop=$this->Y_Range_Low; $Loop <= $this->Y_Range_High; $Loop=$Loop+$Interval )
		{
		$TextPos=($this->ImageSizeY - $this->Default_YAxis_Width) - ($Loop*$this->Y_Scale);	

		if ( $this->Debug_Level > 0 )
	       	 	printf("\n<br>XDBDebug: xdbgraph: Create Y axis labels: '%s' @ %d (interval:%d)",$Loop,$TextPos,$Interval);

		ImageStringUp ($this->ImageID, $this->Default_AxisFont, 10, $TextPos+$this->Y_Origin, round($Loop), $this->ImageTextColor);
	
		//	And put in the Y grid if required.
		if ( $this->GridYColor_r > -1 )
			{
			//	Got a color turned on - create the grid.
			$this->GridYColor = ImageColorAllocate ($this->ImageID, $this->GridYColor_r, 
									$this->GridYColor_g, 
									$this->GridYColor_b);
			imageline( $this->ImageID, 20,$TextPos+$this->Y_Origin, $this->ImageSizeX, $TextPos+$this->Y_Origin, $this->GridYColor );
			}
		}
	}
}


function xdbgraph_set_pie ( $OriginX, $OriginY, $SizeX, $SizeY ) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set Pie (%d,%d: %dx%d)",
			$OriginX, $OriginY, $SizeX, $SizeY);


$this->Pie_OriginX=$OriginX;
$this->Pie_OriginY=$OriginY;

$this->Pie_MidX = $OriginX + ( $SizeX / 2 );
$this->Pie_MidY = $OriginY + ( $SizeY / 2 );

$this->Pie_Diameter=(min($SizeX, $SizeY))*0.7;	// Make sure there's enough space around the pie.

//	Draw the border of the arc.
if ( $this->Debug_Level > 0 )
        printf("\nMiddle: (%d,%d), Diameter:(%d):",$this->Pie_MidX, $this->Pie_MidY, $this->Pie_Diameter);

}


function xdbgraph_set_pie_title ( $TitleText ) {

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Set Pie Title (%s)",
			$TitleText);

ImageString ($this->ImageID, 5, $this->Pie_OriginX, $this->Pie_OriginY, $TitleText, $this->ColorBlack);

}

function xdbgraph_plot_pie ( $StartAngle, $EndAngle, $tag ) {


if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Plot Pie (%d %d) (%s)",
			$StartAngle, $EndAngle, $tag);

imagearc( $this->ImageID, $this->Pie_MidX, $this->Pie_MidY, $this->Pie_Diameter, $this->Pie_Diameter, $StartAngle, $EndAngle, $this->ColorBlack );

//	Put lines bounding the pie
$out_x = ($this->Pie_Diameter/2) * cos(deg2rad($StartAngle));
$out_y = ($this->Pie_Diameter/2) * sin(deg2rad($StartAngle));

if ( $this->Debug_Level > 0 )
        printf("\n<br>Start Line: (%d,%d - %d,%d)",$this->Pie_MidX, $this->Pie_MidY, $this->Pie_MidX+$out_x, $this->Pie_MidY+$out_y);

imageline($this->ImageID, $this->Pie_MidX, $this->Pie_MidY, $out_x+$this->Pie_MidX, $out_y+$this->Pie_MidY, $this->ColorBlack);

$out_x1 = ($this->Pie_Diameter/2) * cos(deg2rad($EndAngle));
$out_y1 = ($this->Pie_Diameter/2) * sin(deg2rad($EndAngle));

if ( $this->Debug_Level > 0 )
        printf("\n<br>End Line: (%d,%d - %d,%d)",$this->Pie_MidX, $this->Pie_MidY, $this->Pie_MidX+$out_x1, $this->Pie_MidY+$out_y1);

imageline($this->ImageID, $this->Pie_MidX, $this->Pie_MidY, $out_x1+$this->Pie_MidX, $out_y1+$this->Pie_MidY, $this->ColorBlack);

//	Get the mid-point for the fill.

$out_xm=($out_x1 + $out_x)/2;
$out_ym=($out_y1 + $out_y)/2;

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Fillarea: (%d,%d) actual:(%d,%d) ",$out_xm, $out_ym, $out_xm+$this->Pie_MidX, $out_ym+$this->Pie_MidY);


imagefilltoborder( $this->ImageID, $out_xm+$this->Pie_MidX, $out_ym+$this->Pie_MidY, $this->ColorBlack, $this->ImageDrawColor);

//	And put text in.

$MidPointAngle= ($StartAngle+$EndAngle)/2;

//	Put lines bounding the pie
$out_x = (($this->Pie_Diameter/2)-10) * cos(deg2rad($MidPointAngle));
$out_y = (($this->Pie_Diameter/2)-10) * sin(deg2rad($MidPointAngle));

//	Put lines bounding the pie
$out_x1 = (($this->Pie_Diameter/2)+10) * cos(deg2rad($MidPointAngle));
$out_y1 = (($this->Pie_Diameter/2)+10) * sin(deg2rad($MidPointAngle));

imageline($this->ImageID, $this->Pie_MidX+$out_x, $this->Pie_MidY+$out_y, $out_x1+$this->Pie_MidX, $out_y1+$this->Pie_MidY, $this->ColorBlack);

//	Put lines bounding the pie
$out_x1 = (($this->Pie_Diameter/2)+15) * cos(deg2rad($MidPointAngle));
$out_y1 = (($this->Pie_Diameter/2)+15) * sin(deg2rad($MidPointAngle));

//	If the text appears on the left of the pie (i.e. angles 90>x>270) - alter the X value to accomodate.

if ($MidPointAngle >90 && $MidPointAngle < 270 )
	{
	$out_x1=$out_x1-(strlen($tag)*8);
	}

// ImageString ($this->ImageID, $this->Default_AxisFont, $out_x1+$M_MidX, $out_y1+$M_MidY, $tag, $this->ImageDrawColor);
ImageString ($this->ImageID, 5, $out_x1+$this->Pie_MidX, $out_y1+$this->Pie_MidY, $tag, $this->ColorBlack);


								

}







function xdbgraph_create_file() {

// phpinfo();
// printf("<br>Session:%s",$_SERVER["UNIQUE_ID"]);
$this->Output_Filename=$this->Default_Output_Location."/".$this->Default_Filename."-".$_SERVER["UNIQUE_ID"].".".$this->Supported_Graphic;

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: Fileoutput: %s",$this->Output_Filename);

if ($this->Supported_Graphic=="GIF") {
        ImageGIF($this->ImageID, $this->Output_Filename);
        }
elseif ($this->Supported_Graphic=="JPG") {
        ImageJPEG($this->ImageID, $this->Output_Filename, 100);
        }
elseif ($this->Supported_Graphic=="PNG") {
        ImagePNG($this->ImageID, $this->Output_Filename);
        }
elseif ($this->Supported_Graphic=="BMP") {
        ImageWBMP($this->ImageID , $this->Output_Filename);
        }

if ( $this->Debug_Level > 0 )
        printf("\n<br>XDBDebug: xdbgraph: File Created:");

return $this->Output_Filename;

}



}




//	DATA CLASSES
//
//	Classes which can be entered into an array, to pre-create all the data required before
//	calling plotting functions.

class xdbdata {

var	$DataValue;		//	Actual data value
var	$DataColor;		//	Color of data to be presented.
var	$DataTag;		//	Text information to be presented with the data.

var 	$Debug=0;		//	Debug Level

//	Instantiate and set values.
function xdbdata ( $MX_Value, $MY_Value, $M_Color, $M_Tag )
{

if( $this->Debug > 0 )
	printf("<br>DataClass: instantiate ValueY:%d, ValueX:%d, Color:%s, Tag:%s",$MY_Value, $MX_Value, $M_Color, $M_Tag);

$this->DataYValue = $MY_Value;
$this->DataXValue = $MX_Value;
$this->DataColor = $M_Color;
$this->DataTag   = $M_Tag;

}

}










?>
































Return current item: XDB Money