在页面上嵌入图表?

如何在我的HTML页面上的特定位置获得
pchart
?现在,当我按照例子使用时
$myPicture->autoOutput();
它只是覆盖了我的整个页面,只显示了图表。 看着
pChart
源我在
pImage.class.php
里找到了一个相关的功能
   function stroke()
    {
     if ( $this->TransparentBackground ) { imagealphablending($this->Picture,false); imagesavealpha($this->Picture,true); }

     header('Content-type: image/png');
     imagepng($this->Picture);
    }
我试图将其更改为此但它似乎返回null并且我得到了一堆错误   警告:imagettfbbox()[function.imagettfbbox]:**中的字体文件名无效
   function stroke()
    {   
    ob_start(NULL,4096);
    $this->Picture;
    header('Content-type: text/html');
    return base64_encode(ob_get_clean();  
    }
    
已邀请:
最简单的方法是将项目拆分为2个单独的文件。一个文件保存您的网页,另一个文件保存图像(图表)。我们将第二个文件命名为chart.php 正如您所提到的,它仅输出图像。您需要做的是将此文件嵌入到保存网页的第一个文件中。 在你的HTML代码中添加
<img src="chart.php" width="x" height="y" />
。 HtH,Thor     
我得到了它的工作,我扩展了pImage类,所以我添加了以下功能:
function strokeToBase64()
{
   ob_start();
   imagepng($this->Picture);
   $contents =  ob_get_contents();
   ob_end_clean();
   return base64_encode($contents);
}
然后使用pChart lib的PHP代码调用这样的函数:
echo $myPicture->strokeToBase64();
通过这种方式,我可以在客户端使用jQuery轻松调用Ajax调用,而无需在服务器中创建图像文件,如上面提到的帖子中所述。     

要回复问题请先登录注册