PHP+jpgraph实现柱型图表,但是横坐标显示为框框,不知是何原因
query($sql); $rs = array(); while ($row = MySQLi_fetch_array($r)){ $rs[] = $row['counts']; } $sql_xy = "select * from xy_inf group by xy_id"; $r_xy = $conn -> query($sql_xy); $xy = array(); while ($row_xy = mysqli_fetch_array($r_xy)){ $xy[] = $row_xy['stu_xy']; } require_once 'src/jpgraph.php'; require_once 'src/jpgraph_bar.php'; $graph = new Graph(600, 300); $graph->SetScale('textlin'); $graph->SetShadow(); $graph->img->SetMargin(40, 30, 20, 40); $barplot = new BarPlot($rs); $graph->Add($barplot); $barplot->value->Show(); $graph->title->Set(iconv("utf-8","gb2312","全校学生数量")); $graph->xaxis->title->Set(iconv("utf-8","gb2312","学院")); $graph->xaxis->SetTickLabels($xy); $graph->yaxis->title->Set(iconv("utf-8","gb2312",'人数')); $graph->title->SetFont(FF_SIMSUN, FS_BOLD); $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD); $graph->Stroke(); ?>
专注于为中小企业提供网站建设、网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业根河免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千多家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。
数据库连接:conn.php
服务器失败!".mysqli_connect_err or()); mysqli_query($conn,'set names utf8'); ?>
数据库:
mysql> use db_student; mysql> desc stu_inf; +--------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+----------------+ | id | smallint(6) | NO | PRI | NULL | auto_increment | | stu_xh | varchar(8) | NO | UNI | NULL | | | stu_xm | varchar(40) | NO | | NULL | | | xb_id | smallint(6) | NO | MUL | NULL | | | xy_id | smallint(6) | NO | | NULL | | | stu_bj | varchar(4) | NO | | NULL | | +--------+-------------+------+-----+---------+----------------+ 6 rows in set (0.00 sec)
mysql> desc xy_inf; +--------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------+-------------+------+-----+---------+----------------+ | xy_id | smallint(6) | NO | PRI | NULL | auto_increment | | stu_xy | varchar(40) | NO | | NULL | | +--------+-------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec)
网站名称:PHP+jpgraph实现柱型图表,但是横坐标显示为框框,不知是何原因
文章地址:http://pwwzsj.com/article/pchhje.html