require_once("jpgraph/jpgraph.php");
require_once ('jpgraph/jpgraph_bar.php');
for($p=1;$p<=8;$p++){
$tbname=array("host","project","archited","engineering","contractor","wall","roofing","plaster");
$datay=array($result_array[$p][1],$result_array[$p][2],$result_array[$p][3], $result_array[$p][4],$result_array[$p][4],$result_array[$p][6],$result_array[$p][7],$result_array[$p][8],$result_array[$p][9],$result_array[$p][10], $result_array[$p][11],$result_array[$p][12],$result_array[$p][13],$result_array[$p][14],$result_array[$p][15],$result_array[$p][16]);
//$datay=array(12,26,9,17,31);
// Create the graph.
$datax=array("TV","Redio","News","Mag","Out","6A","6B","7A","7B","MRT","Web","SMS","Fly","Car","Direct","Movie");
$graph = new Graph(400,250);
$graph->SetScale("textlin");
// Create a bar pot
$bplot = new BarPlot($datay);
// Create targets for the image maps so that the details are opened in a separate window
$fmtStr= "javascript:window.open('barcsim_details.php?id=%d','_new','width=600,height=350');void(1)";
$n = count($datay);
$targ=array();
$alts=array();
for($i=0; $i < $n; ++$i) {
$targ[$i] = sprintf($fmtStr,$i+1);
$alts[$i] = 'val=%d';
// Note: The format placeholder val=%d will be replaced by the actual value in the ouput HTML by the
// library so that when the user hoovers the mouse over the bar the actual numerical value of the bar
// will be d?splayed
}
$bplot->SetCSIMTargets($targ,$alts);
// Add plot to graph
$graph->Add($bplot);
// Setup the title, also wih a CSIM area
$graph->title->Set(" $tbname[$p] ");
$graph->title->SetFont(FF_FONT2,FS_BOLD);
// Assume we can give more details on the graph
$graph->title->SetCSIMTarget(sprintf($fmtStr,-1),'Title for Bar');
// Setup X-axis labels
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(50);
// Send back the HTML page which will call this script again to retrieve the image.
$graph->StrokeCSIM();
}
?>