Login   Register  
PHP Classes
elePHPant
Icontem

File: Demo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Abhishek Shukla  >  Bar Graph Class  >  Demo.php  >  Download  
File: Demo.php
Role: Example script
Content type: text/plain
Description: Demonstration File
Class: Bar Graph Class
Display a bar chart on a page using HTML tables
Author: By
Last change:
Date: 1 year ago
Size: 4,589 bytes
 

Contents

Class file image Download
<html>
<head>
<title>Bar Graph Class Demo</title>
<style>
h1,h2,h3{color:brown}
</style>
</head>
<body style="background-color:whitesmoke">
<h1>Bar Graph Class Demonstration</h1>
 * This class is intended to produce single parameter simple fluid bargraphs 
 using simple customization in vertical as well as horizontal style <br/>
 * Author: Abhishek Shukla, Lucknow, India; <br/>
 * mail: abhi_rttc@yahoo.com; 
 web: www.eeyesolutions.com; <br/>
 * Version: 1.0 /28.11.2012 <br/>
 * (C)Author : You may not use it for commercial purpose witout explicit written permission of the author <br/>
<h2>Data/Customizations Used for this Demonstration</h2>
<table border="1">
<tr>
<th style="background-color:grey;color:white;">Set Method</th>
<th style="background-color:grey;color:white;">Values Used</th>
<th style="background-color:grey;color:white;">Remarks</th>
</tr><tr>
<td>setTitles($title,$objtitle,$valtitle)</td>
<td>$title="My Bar Graph";<br/>$objtitle="Objects";<br/>$valtitle="Values";</td>
<td>Various Titles</td>
</tr><tr>
<td>setValues($objarray,$valarray)</td>
<td>$Objarray=array("Obj1","Obj2","Obj3","Obj4","Obj5","Obj6","Obj7","Obj8",<br/>
"Obj9","Obj10");<br/>
$valarray=array("Obj1"=>12,"Obj2"=>10,"Obj3"=>15,"Obj4"=>18,"Obj5"=>7,<br/>
"Obj6"=>5,"Obj7"=>9,"Obj8"=>20,"Obj9"=>11,"Obj10"=>16););</td>
<td>Parameter Objects & Values</td>
</tr><tr>
<td>setLink($linkatt)</td>
<td>Default:#</td>
<td>Custom Link for Values</td>
</tr><tr>
<td>setChartHeight($chartheight)</td>
<td>Default:250px<br/>Custom:100px</td>
<td>Chart height for vertical type</td>
</tr><tr>
<td>setBarHeight($barheight)</td>
<td>Default:30px<br/>Custom:18px</td>
<td>Bar height for horizontal type</td>
</tr><tr>
<td>setBarColor($barcolor,$shadecolor)</td>
<td>Default:#01A9DB,violet<br/>Custom: Red,Brown <br/>Custom: Green,Orange</td>
<td>Bar Color & Shade</td>
</tr><tr>
<td>setColor($titlecolor,$labelcolor)</td>
<td>Default:#000,#000<br/>Custom:Brown,Grey<br/>Custom:Orange,Grey</td>
<td>Title Color & Shade</td>
</tr>
</table>
<?php
//data
$Objarray=array("Obj1","Obj2","Obj3","Obj4","Obj5","Obj6","Obj7","Obj8","Obj9","Obj10");
$valarray=array("Obj1"=>12,"Obj2"=>10,"Obj3"=>15,"Obj4"=>18,"Obj5"=>7,
"Obj6"=>5,"Obj7"=>9,"Obj8"=>20,"Obj9"=>11,"Obj10"=>16);
//titles
$title="My Bar Graph";
$objtitle="Objects";
$valtitle="Values";

include_once(
'bar_graph_class.php');
$graph=new bar_graph();
$graph->setValues($Objarray,$valarray);
$graph->setTitles($title,$objtitle,$valtitle);
?>
<h2>Minimal Customization: Only Values & Titles used</h2>
<h3>Full Width Vertical Bar Graph</h3>
<?php echo $graph->drawGraph($type="V");?>
<h3>Full Width Horizontal Bar Graph</h3>
<?php echo $graph->drawGraph($type="H");?>
<h3>Half Width Bar Graph </h3>
<table width="100%"><tr>
<td width="50%"><?php echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php echo $graph->drawGraph($type="H");?></td>
</tr></table>
<h2>Extended Customization Demonstration</h2>
<h3>Half Width Bar Graph </h3>
(Custom Chart height for Vertical Graph & Custom Bar height for Horizontal Graph)
<table width="100%"><tr>
<td width="50%"><?php $graph->setChartHeight(100);echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php $graph->setBarHeight(18);echo $graph->drawGraph($type="H");?></td>
</tr></table>
<h3>Custom Bar Color : Red with Brown Shadow</h3>
<?php $graph->setBarColor("red","brown");    ?>
<table width="100%"><tr>
<td width="50%"><?php $graph->setChartHeight(100);echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php $graph->setBarHeight(18);echo $graph->drawGraph($type="H");?></td>
</tr></table>
<h3>Custom Title & Label Color : Brown & Grey</h3>
<?php $graph->setColor("brown","grey");    ?>
<table width="100%"><tr>
<td width="50%"><?php $graph->setChartHeight(100);echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php $graph->setBarHeight(18);echo $graph->drawGraph($type="H");?></td>
</tr></table>
<h3>Custom Bar Color : Green with Orange Shadow</h3>
<?php $graph->setBarColor("green","orange");$graph->setColor("#000","#000");    ?>
<table width="100%"><tr>
<td width="50%"><?php $graph->setChartHeight(100);echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php $graph->setBarHeight(18);echo $graph->drawGraph($type="H");?></td>
</tr></table>

<h3>Custom Title & Label Color : Orange & Grey</h3>
<?php $graph->setColor("orange","grey");    ?>
<table width="100%"><tr>
<td width="50%"><?php $graph->setChartHeight(100);echo $graph->drawGraph($type="V");?></td>
<td width="50%"><?php $graph->setBarHeight(18);echo $graph->drawGraph($type="H");?></td>
</tr></table>
</body>
</html>