2

我有一个类名“MonthReport.class.php”,其结构如下:

    class MonthReport{
    .....
    //some member variables


    public function pieChart(){
      ........
      //the image data comes from mysql and data belongs to a specified user
      $myPicture->Stroke();
   }

   public function lineChart(){
      ........
      //the image data comes from mysql and data belongs to a specified user
      $myPicture->Stroke();
  }

   public function render html(){
    $html.=str1<<<
    .....
    //some html code
str1;
   $html.=<<<str2
   <img src="$this->pieChart()" />    //can not work
str2;
  }
}

当我在 src 位置调用 pieChart() 函数时,它将覆盖我的整个页面并仅显示图像。我该怎么做?我尝试在单独的页面中呈现图像,但图像需要一些指定的用户数据,例如'userId'。换句话说,当我新建一个对象时,它指定了 userId,因此我无法在单独的页面中呈现图像。对不起我的英语不好!但我需要你的帮助!谢谢你!

4

1 回答 1

1

您的问题有点不清楚,但是如果您的问题是我假设的问题,那么我曾经遇到过类似的问题(创建的图形只是一个图像,我的所有其余页面内容都没有显示)。我的解决方案是生成一个临时图像,pchart然后将该文件嵌入到 html

 $myfilename = "temp_image.png";      // temp file name
 $myPicture = new pImage(700,500,$myData);  

 // other image creation code....


 $myPicture->Render($myfilename);     // generate image "temp_image.png"
 $image_html = '<img src="' . $myfilename . '">';   //generate the link
 print("$htmlline");

由于您的问题尚不清楚,因此这里再次进行了一些猜测。以上对我有用,使我能够将动态创建的图像嵌入pChart到我的php页面中。

于 2013-12-25T11:01:30.223 回答