<?php 
include("conn/conn.php");
include("jpgraph/jpgraph.php");
include("jpgraph/jpgraph_bar.php");
//统计投票的总量
$query=mysql_query("select sum(tb_vote_counts) as vote_gross from tb_vote_odd where tb_vote_subject='".$_GET[vote_subject]."'");  
$vote_counts=mysql_result($query,0,"vote_gross");				//获取总的投票数量
if($vote_counts>0){
$querys=mysql_query("select * from tb_vote_odd where tb_vote_subject='".$_GET[vote_subject]."' ");
while($myrow=mysql_fetch_array($querys)){
	$vote_content[]=$myrow[tb_vote_content];		
	$results=number_format($myrow[tb_vote_counts]/1,2);		//计算每项投票数量占总投票量的比例
	$resultes[]=$results;			//将获取的值写入到数组中
}
$graph = new Graph(600,300,"auto");	//创建画布
$graph->SetScale("textlin");
$graph->yaxis->scale->SetGrace(20);

//创建画布阴影
$graph->SetShadow();
$graph->img->SetMargin(40,30,30,40);//设置显示区左、右、上、下距边线的距离，单位为像素
$bplot = new BarPlot($resultes);//创建一个矩形的对象
$bplot->SetFillColor('red');	//设置柱形图的颜色
$bplot->value->Show();//设置显示数字	
$bplot->value->SetFormat('%d');//在柱形图中显示格式化的评选结果
$graph->Add($bplot);//将柱形图添加到图像中
$graph->SetMarginColor("lightblue");//设置画布背景色为淡蓝色
$graph->title->Set("优秀员工评选结果");//创建标题
$graph->xaxis->SetTickLabels($vote_content); //设置X坐标轴文字
$graph->title->SetFont(FF_SIMSUN);//设置字体
$graph->xaxis->SetFont(FF_SIMSUN); //设置字体
$graph->Stroke();//输出矩形图表
}
?>
