免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3520 | 回复: 11

php 饼状图问题 [复制链接]

论坛徽章:
0
发表于 2012-06-12 10:38 |显示全部楼层

大家好,我想在一个php网页上加入一些数据统计图,目前使用的是jpgraph图库,我想在已有的php脚本中加入这些图库,应该如何做?

使用require调用么?我用require要报错。

论坛徽章:
0
发表于 2012-06-12 10:45 |显示全部楼层
<?php // content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_pie.php');
// Some data
$data = array(80,20);
// Create the Pie Graph.
$graph = new PieGraph(500,300);

$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());

// Set A title for the plot
$graph->title->Set("HDS AMS2500");
$graph->SetBox(true);

// Create
$p1 = new PiePlot($data);
$graph->Add($p1);

$p1->ShowBorder();
$p1->SetColor('black');
$p1->SetSliceColors(array('red','gray'));
$graph->Stroke();

?>
这是我的一个pie图。我想把它调用入另外的一个网页,作为数据显示,请问如何做?

论坛徽章:
0
发表于 2012-06-12 11:03 |显示全部楼层
是我没有表达清楚,还是?请大神指导

论坛徽章:
0
发表于 2012-06-12 11:53 |显示全部楼层
不明白你的问题出在哪里?是require引入有问题?

你最好将错误信息都贴出来。

论坛徽章:
0
发表于 2012-06-12 12:58 |显示全部楼层
用include试试

论坛徽章:
0
发表于 2012-06-12 13:40 |显示全部楼层
用include也不行呢?你有没有类似的例子

论坛徽章:
0
发表于 2012-06-12 13:44 |显示全部楼层
JpGraph Error: HTTP headers have already been sent.
Caused by output from file header.html at line 175.
Explanation:
HTTP headers have already been sent back to the browser indicating the data as text before the library got a chance to send it's image HTTP header to this browser. This makes it impossible for the library to send back image data to the browser (since that would be interpretated as text by the browser and show up as junk text).
Most likely you have some text in your script before the call to Graph::Stroke(). If this texts gets sent back to the browser the browser will assume that all data is plain text. Look for any text, even spaces and newlines, that might have been sent back to the browser.

For example it is a common mistake to leave a blank line before the opening "<?php".

论坛徽章:
0
发表于 2012-06-12 13:49 |显示全部楼层
本帖最后由 gooutya1 于 2012-06-12 13:52 编辑

<!--HTML>
   <HEAD>
      <TITLE>SAN </TITLE>
      <LINK rel="stylesheet" href="./my.css" type="text/css" />
      <LINK rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
   </HEAD>
   <BODY>
-->
<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->
<?php
   include('../config.inc.php');
   require("../header.html");
   print("&nbsp;");
   print("<P><H2><u><i>SAN Operatitions Page of $SAN_NAME</i></u></H2></P>");
   include('./pie.php');
?>
.......
下面还有一些form句,和一些表格。我就是想在这个位置插入我的pie图


或者有没有什么群,或者谁愿意给出及时通讯工具,那就最好了,谢谢大家!

论坛徽章:
1
2015年迎新春徽章
日期:2015-03-04 09:55:28
发表于 2012-06-13 09:55 |显示全部楼层
php文件里有header函数,但是你的文件前面又有html输出,当然会报错,跟require没关系。

解决办法:把php文件里涉及header的部分,放到最前面,生成饼图地址后,在你想要的位置输出。

论坛徽章:
0
发表于 2012-06-19 10:42 |显示全部楼层
问题已解决,用jpgraph生成的图形,先保存到一个文件中,然后主php文件调用图片就行了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP