Login   Register  
PHP Classes
elePHPant
Icontem

File: phpgraph.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of BasicA  >  PHP Graph Plotting * Simple Version  >  phpgraph.php  >  Download  
File: phpgraph.php
Role: ???
Content type: text/plain
Description: Actual Graph Plotting Module
Class: PHP Graph Plotting * Simple Version
Author: By
Last change:
Date: 2001-03-19 22:52
Size: 3,005 bytes
 

Contents

Class file image Download
<?php

	/*
		This is BasicA's DAMN BAREBONE graph plottng package...
		Can use in download hit indicator? or any other hitindicator... 
		
		it can even be bundled with a database script :p  
		
		if this package is used in conjunction with an XML database
		activated with my XML_Library... there are certain relations from the 
		data extracted from the XML database with the XML_DBarrayDump function and the
		graph plotting function proper.
		
		Relations:
			Total Number of Records: Number of bars
			Value Array, NameArray, ColorArray can all be the data from the field where the
			data is stored.
			
			pxperunit is pixels per unit value this is to be defined by the user as there
			is no specific functions provided to calculate a default value for this constant
			this value would depend on the minimum and max values and the range...
			
			cos there might be outliers.      
			
		-------------------------------------	
		In this package there are many GUI that should be redefined or altered by 
		whoever the user is.
			
			
  		__________________________________________________________________________
		BasicA <basica@k-designs.com.sg> | <http://staff.k-designs.com.sg/basica/>    
		ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
	 */

	function Plot($NumBars, $ValArray, $NameArray, $ColorArray, $PxPerUnit) {

		print "<table><tr><td>";  

		for ($i = 0; $i < $NumBars; $i++) {
			print "<table><tr><td>";
			print $NameArray[$i];
			print "</td></tr></table>";
		}

		print "</td><td>";
		                      
		for ($i = 0; $i < $NumBars; $i++) {
			print "<table><tr><td bgcolor=" . $ColorArray[$i]. " width=" . $ValArray[$i] * $PxPerUnit . ">";
			//for ($j = 1; $j < $ValArray[$i]; $j += $ScalePerUnit) {
				print "&nbsp;";
			//}
			print "</td><td>" . $ValArray[$i] . "</td></tr></table>";
		}  	       
		
		print "</td></tr></table>";
		
	}                   
	
	
	function GenerateRandomColor() {
	
		$HexCode = "";

		for ($i = 0; $i < 6; $i++) {   
			
			mt_srand((double)microtime() * 1000000); 
			$Num = mt_rand(1,15); 
			
			if ($Num >= 10) {
				$HexCode .= chr($Num + 55);
			} else {
				$HexCode .= strval($Num);
			}
			
		}
		
		return "#" . $HexCode;                     
		
	}
	
	$temp1[0] = "70";	
	$temp1[1] = "25";	
	$temp1[2] = "112";	
	$temp1[3] = "80";	
	$temp1[4] = "50";	

	$temp2[0] = "haha";	
	$temp2[1] = "hehe";	
	$temp2[2] = "hoho";	
	$temp2[3] = "kaka";	
	$temp2[4] = "gee";	

	/* of cos you can define ur own colors.
	$temp3[0] = "#FFAAAA";	
	$temp3[1] = "#AAAAFF";	
	$temp3[2] = "#AAFFAA";	   
	$temp3[3] = "#FFFFAA";	   
	$temp3[4] = "#FFAAFF";	   
	*/
	
	for ($i = 0; $i < 5; $i++) {
		$temp3[$i] = GenerateRandomColor();
	}
	        
 	print "<table border=1 cellpadding=0 cellspacing=0><tr><td>";
	Plot(5,$temp1,$temp2,$temp3,2);                       
	print "</td></tr></table>";

?>