Location: PHPKode > scripts > Simple Histogram > simple-histogram/test_graph_histo.php
<?php
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// MODULE: Teste la classe Graph
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

if (isset($_GET['vs']))
{
	ini_set('highlight.string',  '#999900');
	ini_set('highlight.comment', '#66cc00');
	ini_set('highlight.keyword', '#0000ff');
	ini_set('highlight.bg',      '#bcbcbc');
	ini_set('highlight.default', '#330066');
	ini_set('highlight.html',    '#8a8a8a');
	print "<html><head><title>Test Graph Histogramme -> source</title><head><body bgcolor=\"#ffffff\">";
	highlight_file(__FILE__);
	print "<br><br>";
	print "<a href=\"?\">Voir la page</a>";
	print "</body></html>";

	exit;
}

include("class.graph/class.graph.histogram.php");

header("Pragma: no-cache"); 
header("Cache-Control: no-cache");

$document_titre = "Test Graph Histogramme"; // Titre de la page

if (isset($_POST['h_width'])) $h_width = $_POST['h_width']; else $h_width = 500;
if (isset($_POST['h_height'])) $h_height = $_POST['h_height']; else $h_height = 250;
if (isset($_POST['h_border'])) $h_border = $_POST['h_border']; else $h_border = 0;
if (isset($_POST['h_drawscale']))$h_drawscale = "checked"; else $h_drawscale = "";
if (isset($_POST['h_drawgradline']))$h_drawgradline = "checked"; else $h_drawgradline = "";
if (isset($_POST['h_showvalue']))$h_showvalue = "checked"; else $h_showvalue = "";
if (isset($_POST['h_xaxislabel'])) $h_xaxislabel = $_POST['h_xaxislabel']; else $h_xaxislabel = "Month";
if (isset($_POST['h_yaxislabel'])) $h_yaxislabel = $_POST['h_yaxislabel']; else $h_yaxislabel = "Beers";
if (!isset($_POST['h_width']))
{
	$h_drawscale = "checked";
	$h_drawgradline = "";
	$h_showvalue = "";
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

?> 
<html>
  <head>
    <title><?echo $document_titre?></title>
	<style>
	  body{overflow:auto;}
	</style>
  </head>
  <body bgcolor="#EFFFDD">
  <table width="100%" border="1">
  <tr><td colspan="2" bgcolor="#FFFFCC"><small><b>PHP Array passed to the class :</b><br><cite>$vals = Array("January" => 25,"February" => 20,"March" => 22,"April" => 23,"May" => 21,"June" => 14,"July" => 21,"August" => 18,"September" => 14,"October" => 12,"November" => 28,"December" => 22);</cite></small></td></tr>
  <tr>
  <td>
<?php

	$vals = Array("January" => 25,"February" => 20,"March" => 22,"April" => 23,"May" => 21,"June" => 14,"July" => 21,"August" => 18,"September" => 14,"October" => 12,"November" => 28,"December" => 22);

	//$vals = Array(15,10,12,16,11,14,21,18,4,12,8,16);
	
	$H = new Histogram($vals);
    $H->width = $h_width;                        // 150 par défaut
    $H->height = $h_height;                      // 150 par défaut
    $H->bgcolor = "#EFFFDD";                     // #FFFFFF par défaut
    $H->DrawScale = ($h_drawscale != "");        // true par défaut
    $H->DrawGradLine = ($h_drawgradline != "");  // false par défaut     
    $H->border=$h_border;                        // 0 par défaut
    $H->ShowValue = ($h_showvalue != "");        // false par défaut
    $H->XAxisLabel = $h_xaxislabel;              //
    $H->YAxisLabel = $h_yaxislabel;              //
    $H->XAxisLabelColor = "#6666FF";             // #000000 par défaut
    $H->YAxisLabelColor = "#00CC66";             // #000000 par défaut
	$H->Draw();	
	//$H->Export('c:\\histogramme.png');
	//$H->ExportAndDraw('c:\\histogramme.png');
?>
  </td>
  <td valign="top">
	<form method="post" action="">
	  <table width="100%">
	  <tr>
	  	<td>Width&nbsp;:</td>	  
	  	<td><input type="text" name="h_width" value="<?php echo $h_width?>"></td>
	  </tr>
	  <tr>
	  	<td>Height&nbsp;:</td>
	  	<td><input type="text" name="h_height" value="<?php echo $h_height?>"></td>
	  </tr>
	  <tr>
	  	<td>Border&nbsp;:</td>
	  	<td><input type="text" name="h_border" value="<?php echo $h_border?>"></td>
	  </tr>
	  <tr>
	  	<td colspan="2"><input type="checkbox" name="h_drawscale" value="1" <?php echo $h_drawscale ?>> Draw Scale</td>
	  </tr>
	  <tr>
	  	<td colspan="2"><input type="checkbox" name="h_drawgradline" value="1" <?php echo $h_drawgradline ?>> Draw grad line</td>
	  </tr>
	  <tr>
	  	<td colspan="2"><input type="checkbox" name="h_showvalue" value="1" <?php echo $h_showvalue ?>>Show value</td>
	  </tr>
	  <tr>
	  	<td>X Axis Label&nbsp;:</td>	  
	  	<td><input type="text" name="h_xaxislabel" value="<?php echo $h_xaxislabel?>"></td>
	  </tr>
	  <tr>
	  	<td>Y Axis Label&nbsp;:</td>
	  	<td><input type="text" name="h_yaxislabel" value="<?php echo $h_yaxislabel?>"></td>
	  </tr>
	  <tr>
	  	<td colspan="2"><hr></td>
	  </tr>
	  <tr>
	  	<td colspan="2" align="center"><input type="submit" value="OK"></td>
	  </tr>
	  </table>
	</form>
  </td>
  </tr>
<?php
  if ($H->ErrorMsg != "")
   print("<tr><td colspan=\"2\" bgcolor=\"#FF0000\" style=\"color: #FFFF33;\">".$H->ErrorMsg."</td></tr>");
?>
  </table>
  <br><br><a href="?vs=1">Voir le source</a>
  </body>
</html>
<?
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
?>
Return current item: Simple Histogram