您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> php >> 正文

贴段PHP画图的程序,给希望用PHP作图的朋友一点启发,帮助!

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-27 我要参与讨论

  主要包括三个文件:
1、view.php是调用程序。
2、chart.php是用来生成图表的程序。
3、gbtoutf8.php是用来中文解码的(注:已解决中英文混合不能正常显示的问题)

1、view.php
<?
include("gbtoutf8.php");
?>
<html>
<head>
<title>  </title>
<meta name="Author" content="XIANG Li">
</head>
<?
/*此处数据可从数据库中取得*/
$aStr = "IT,PC,Phone,Sever,Passport,Software";
$aSoft = "Win2000,Win98,Office,Foxmail,Outlook";
$aHard = gb2utf8("地板,窗户,玻璃,桌子,灯管,植被");
$title1 = gb2utf8('2002年IT维护report');
$title2 = gb2utf8('2002年软件维护report');
$title3 = gb2utf8('2002年固定资产report');
?>
<body>
<div align="center">
<table>
<tr>
    <td><input type="image" src="./chart.php?aStr=<?=$aStr?>&title=<?=$title1?>"></td>
</tr>
<tr><td> </td></tr>
<tr>
    <td><input type="image" src="./chart.php?aStr=<?=$aSoft?>&title=<?=$title2?>"></td>
</tr>
<tr><td> </td></tr>
<tr>
    <td><input type="image" src="./chart.php?aStr=<?=$aHard?>&title=<?=$title3?>"></td>
</tr>
</table></div>
</body>
</html>

2、chart.php
<?php
/*
*  功能:生成统计图表
*  程序员:wlxz
* 日期:2002-00-00
*/

Header("Content-type: image/png");
  $im = ImageCreate (350, 280);
  $col_oth = ImageColorAllocate($im, 0,0,0);
  $col_orn = ImageColorAllocate($im, 255,192,0);
  $col_yel = ImageColorAllocate($im, 255,255,0);
  $col_red = ImageColorAllocate($im, 255,0,0);
  $col_grn = ImageColorAllocate($im, 0,255,0);
  $col_blu = ImageColorAllocate($im, 0,0,255);
  $col_wit = ImageColorAllocate($im, 255,255,255);
  $col_array = array($col_oth, $col_orn, $col_yel, $col_red, $col_grn, $col_blu);

$dot1 = 28;
$dot2 = 20;
$font="c:/winnt/fonts/simhei.ttf";
$aStr = explode(",", trim($_GET['aStr']));
$title = trim($_GET['title']);

ImageTTFText($im,18,0,100,50,$col_wit,$font,$title);//写标题

  for($i=1;$i<count($col_array);$i++){
  ImageFilledRectangle($im,50*$i-$dot2,$dot1*$i,50*$i,200,$col_array[$i]);
  ImageRectangle($im,50*$i-$dot2,$dot1*$i,50*$i,200,$col_wit);
  ImageRectangle($im,50*$i-$dot2-1,$dot1*$i-1,50*$i+1,200,$col_wit);
  ImageTTFText($im,14,270,50*$i-15,205,$col_wit,$font,$aStr[$i-1]);
  
// ImageLine($im,50*$i-$dot2,$dot1*$i,50*$i-$dot2,200,$col_wit);
  ImageLine($im,50*$i-$dot2,$dot1*$i,50*$i,$dot1*$i,$col_wit

[1] [2] [3] 下一页

在google里搜索更多贴段PHP画图的程序,给希望用PHP作图的朋友一点启发,帮助!

Google
Web www.51ec.org
【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
我来说两句 对此文章发表了评论
  昵 称: *必填    ·注册用户·
  评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
评 论
内 容

 
评论列表 (最新 评论仅限网友观点!)

供求信息




| 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明