I have a class name 'MonthReport.class.php' and its structure like the following:

    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;
  }
}

when I call the pieChart() function with this in the place src it will overwrites my entire page and just shows the image.how can I do this? I try to render the image in a separate page but the image need some specified user data eg.'userId'.in others words when i new a object, it specify the userId,so I can not render the image in a separate page. sorry for my bad english!but I need your help!thanks in advancd!

有帮助吗?

解决方案

Your question is a little unclear but if your problem is what I am assuming it to be, then I used to have similar issues (Graphic created that is just an image with all of the rest of my page content not displaying). My solution was to generate a temporary image using pchart then embed that file in the 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");

Again there is some guesswork going on here as your question is unclear. The above works for me though and enables me to embed an image created on the fly by pChart into my php pages.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top