Location: PHPKode > projects > Centralized Timeregistration System > website/graph.php
<?php
session_start();
//Include the code
include("./includes/phplot.php");
//Define the object
$graph = new PHPlot;

$graph->SetPrintImage(0);
$example_data = $HTTP_SESSION_VARS['y_data'];

$graph->SetPlotAreaWorld(0,0,$HTTP_SESSION_VARS['plot'],$HTTP_SESSION_VARS['max_y']);
$graph->SetVertTickPosition('plotleft');
$graph->SetSkipBottomTick(0);
$graph->SetDataValues($example_data);
$graph->SetPlotType('bars');
$graph->SetDrawDataLabels('1'); //print values in the graph
$graph->SetLabelScalePosition('1');
$graph->SetDataColors(array("blue"),array("black"));
$graph->SetMarginsPixels(100,70,50,50);
$graph->SetLegend(array('Hours   ')); //Lets have a legend
$graph->SetLegendWorld(6.5,$HTTP_SESSION_VARS['max_y']+3); //Lets have a legend positio

//Draw it
$graph->DrawGraph();
//////////////////////NEXT SETTINGS
if($HTTP_SESSION_VARS['planning'] && is_array($HTTP_SESSION_VARS['planning']))
{
	$example_data = $HTTP_SESSION_VARS['planning'];
	$graph->SetDataValues($example_data);
	$graph->SetDataColors(array("red"),array("black"));
	$graph->SetDrawXDataLabels(0); //We already got them in the first graph
	$graph->SetLegend(array('Planning')); //Lets add a second legend
	$graph->DrawLegend(55,10,'');

	//Set Params of another Y Axis
	$graph->SetVertTickPosition('yaxis');
	$graph->SetYGridLabelType('right');
	$graph->SetYAxisPosition(1);
	$graph->SetPrecisionY(0);
	$graph->SetTickColor('red');
	$graph->SetTextColor('red');
	$graph->SetGridColor('red');
	
	//Draw the New data over the first graph
	$graph->DrawLines();
	$graph->DrawDots();
}

$graph->SetOutputFile('statistics');

$graph->PrintImage();
unset ($HTTP_SESSION_VARS['y_data']);
unset ($HTTP_SESSION_VARS['max_y']);
?>
Return current item: Centralized Timeregistration System