php JbGraph

<?php
header ( "Content-type: text/html; charset=UTF-8" ); //设置文件编码格式
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_line.php");
$conn = mysql_connect('localhost','root','') or die('数据库连接失败');
mysql_select_db('db_test9') or die('数据库不存在');
mysql_query('set names utf8');

$sql = 'select a.xm,b.cj from tb_stuinf a, tb_grade b where km="数学" and a.xh=b.xh';
$r = mysql_query($sql);
$x = array();
$y = array();
while($row = mysql_fetch_array($r)){
	$x[] = iconv("utf-8","gb2312",$row['xm']);
	$y[] = $row['cj'];
}



$graph = new Graph(450,275);		//创建图像
$graph->SetMargin(40,40,40,50);			//设置图像的边框
$graph->SetScale("textint");			//定义刻度值的类型
$graph->SetShadow();					//设置图像阴影
$graph->title->Set(iconv("utf-8","gb2312",'数学成绩'));		//定义标题
$graph->title->SetFont(FF_SIMSUN, FS_BOLD);     //设置标题字
$graph->title->SetMargin(10);     //设置标题字

$graph->xaxis->SetTickLabels($x);
$graph->xaxis->SetFont(FF_SIMSUN, FS_BOLD,8);	//定义字体

$graph->xaxis->title->Set(iconv("utf-8","gb2312",'学号'));			//设置X轴的标题
$graph->xaxis->title->SetFont(FF_SIMSUN, FS_BOLD);     //设置标题字

$graph->xaxis->title->SetMargin(10);	//定义字体

$p1 = new LinePlot($y);						//创建折线图像


$p1->value->SetFont(FF_ARIAL,FS_BOLD);	//定义图像值的字体



$graph->Add($p1);	

$p1->value->Show();					//输出图像对应的数据值

$graph->Stroke();									//输出图像
?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值