我正在尝试使用 pchart 包(通过 php)来构建(并直接显示)图形/图表。
此时,我只是尝试运行他们提供的示例(Example1.php
),我刚刚将最后的:替换
$Test->Render("example1.png");
为
$Test->Stroke();
但是当我这样做时,我得到:“图像无法显示因为它在浏览器上包含错误”。
如果我保留原始的 $Test->Render(...)
生成的图像就可以了。 (但未发送)
我读到,mozilla/Firefox 浏览器存在(曾经?)关于需要两次图像和 REFER URL 的问题,但是当我浏览 pchart 主页时,我可以使用它们的“sanboxes”和将测试结果直接显示在浏览器上(http://pchart.sourceforge.net/demo.php) PHP)。
...
因此,它们必须是一种将生成的图形直接成功发送到浏览器的方法(或一个很好的解决方法)。
如果您的答案是生成图像(即使用渲染)然后发送,请准确说明如何执行此操作(如何自动销毁生成的文件、权限...)
我对此很陌生,抱歉提前如果很明显的话...;-)
I am trying to use the pchart package (over php) to build (and directly display) graphs/charts.
At this time, I am just trying to run their provided example (Example1.php
), where I just have replaced the final:
$Test->Render("example1.png");
by
$Test->Stroke();
But When I do this, I get:" The image cannot be displayed because it contains errors" on the browser.
If I leave the original $Test->Render(...)
the generated image is OK. (but not sent)
I have read that there is (was?) an issue with mozilla/Firefox browsers regarding images being required twice and the REFER URL, but when I browse at the pchart home page, I can use their "sanboxes" and get the result of my tests directly displayed on my browser (http://pchart.sourceforge.net/demo.php).
...
So their must be a way (or a nice work around) to send the generated graphs directely to the browser successfuly.
If your answer is to generate the image (i.e. use Render) and then send it afterwards, please but accurate on how to do this (how do I destroy the generated files automaticaly, permissions...)
I am new to this, sorry advance if it's obvious...;-)
发布评论
评论(3)
确保
括号之外没有任何内容...这会在图像数据之前发送空格或任何内容,从而导致混乱和坏事。
除此之外,尝试在脚本顶部添加一个
header("Content-type: image/png");
,我怀疑这会有所帮助,但你永远不知道......Make sure you don't have anything outside the
<?php ?>
brackets...this will send that whitespace or whatever before the image data, causing general chaos and badness.Barring that, try adding a
header("Content-type: image/png");
to the top of the script, I doubt that would help but you never know...我不知道 PChart,但类似这样的事情通常是由于 PHP 错误消息污染了 PNG 图像。
尝试将损坏的图像保存到磁盘,然后使用 Notepad++ 等编辑器打开它。查看文件的前几行是否有任何有意义的内容。
I don't know PChart, but stuff like this is most often down to PHP error messages polluting the PNG image.
Try saving the damaged image to disk, and opening it with an Editor like Notepad++. See whether there is anything meaningful in the first few lines of the file.
是的,Sylae 的回答是正确的!确保在 、 之前和之后没有任何内容。连一个空格都没有。
Yes, Sylae answer is right! Make sure you don't have anything outside the , before and after it. Not even single space.