【发布时间】:2012-08-05 07:25:15
【问题描述】:
我很尴尬,但我似乎无法创建由http://phpmaster.com/charting-with-pchart 创作的非常简单的 php 图表来工作。
我验证了以下几点:我的 Apache 服务器正在运行 PHP5,启用了 GD 和 Free Type 支持,并且我的目录路径良好(即 is_file 已确认,所有文件都已上传)。
下面是简单的代码:
<?php
session_start();
require_once('library/class/pData_class.php');
require_once('library/class/pChart_class.php');
$myDataset = array(0, 1, 2, 3, 4, 5, 7, 9);
$myData = new pData();
$myData->addPoints($myDataset);
$myImage = new pImage(500, 300, $myData);
$myImage->setFontProperties(array("FontName" => PCHART_PATH . "library/fonts/GeosansLight.ttf", "FontSize" => 15));
$myImage->setGraphArea(25, 25, 475, 275);
$myImage->drawScale();
$myImage->drawBarChart();
header("Content-Type: image/png");
$myImage->Render(null);
?>
我尝试了一些变体,但在我看来,上面的代码是正确的。我没主意了。非常感谢任何帮助。
谢谢,
私信
【问题讨论】:
-
有什么错误吗?顺便说一句,不是
<php?,而是<?php -
(
-
php页面调用就好了。我可以回显“测试”;在页面上并呈现,但就是这样吗?
-
请发布ajax请求代码。
-
在您发布的文章中,他们说
provide a file location as an argument and Render() will save the image file to that location on your server.. 这样您就可以保存图像并通过 Ajax 仅返回该图像的位置。