<?php
include 'C:\php\jpgraph-2.3\src\jpgraph.php';
include 'C:\php\jpgraph-2.3\src\jpgraph_line.php';
include 'C:\php\jpgraph-2.3\src\jpgraph_date.php';

$var_graph = $_POST["lsCompanyName"];

$db = @mysql_connect("localhost","root","ateet");
@mysql_select_db("test_schema",$db);

$result_id = mysql_query("select OrganizationID from organizationtable where OrganizationName = '$var_graph'") or die(mysql_error());
$c_id = mysql_fetch_array($result_id, MYSQL_NUM);

$company_id = $c_id[0];
$data = mysql_query("select Close,Date from organizationhistory where OrganizationID = '$company_id'");

$closearray = array();
$datearray = array();

while($row = mysql_fetch_array($data, MYSQL_NUM))
{
	array_push($closearray, $row[0]);
	array_push($datearray, $row[1]);
}

$max = max($closearray);
$graph = new Graph(800,600, 'auto');
$graph->SetScale("datlin",0,$max+10);

$graph->yaxis->scale->SetGrace(7);
$graph->img->SetMargin(50,30,40,130);
$graph->SetShadow();

$graph->yaxis->title->Set("Close");
$graph->xaxis->title->Set("Date");
$graph->title->Set($var_graph);

$lplot = new LinePlot($closearray);
$graph->xaxis->SetLabelAngle(90);
//$graph->SetTickDensity(TICKD_NORMAL,TICKD_SPARSE);
$graph->xaxis->SetTickLabels($datearray);
$lplot->SetFillColor('red@0.5');
$graph->Add($lplot);
$graph->Stroke();
?>
