Jump to content

Recommended Posts

Hi all,

 

I have PHP Version 5.2.8 with GD extended. I have installed PHPlot-5.0.6

(copied the files into directory called phplot)

 

gd

GD Support enabled

GD Version bundled (2.0.34 compatible)

FreeType Support enabled

FreeType Linkage with freetype

FreeType Version 2.1.9

T1Lib Support enabled

GIF Read Support enabled

GIF Create Support enabled

JPG Support enabled

PNG Support enabled

WBMP Support enabled

XBM Support enabled

 

After installation I am trying to run very simple phplot script, but it is showing the binary output.

But when I placed the code in separate file namely Graph.php and referred in image tag, it is working fine. (<IMG SRC="<?= $URL ?>Graph.php">)

Please advice what could be wrong in my side!!!

 

------------------

PHP Lot Code

------------------

<?

include("phplot/phplot.php");

$data = array(array('', 10), array('', 1));

$plot = new PHPlot();

$plot->SetDataValues($data);

$plot->SetTitle('First Test Plot');

$plot->DrawGraph();

?>

 

THANKS

Crew Kasy Raj

 

 

Link to comment
https://forums.phpfreaks.com/topic/173767-solved-phplot-graph-not-showing/
Share on other sites

Hi Mark

 

Thanks for your reply.

 

I understand the purpose of IMG tag. But I am getting this problem only when I try to run in my application. If I run this same code outside my application it is working fine (plotting the graph). Is it a rendering problem? :o

 

Kindly advice.

 

Thanks

Crew Kasy Raj

Ok let me tell you clearly. I have apache webser and I ran graph.php directly from my web browser. It is showing the graph. When I move the same code to a function and calling from particular place of my application then it is showing binary output.

 

Why it is happening? What am I missing?

 

THanks,

Crew Kasy Raj

If you want to send the image data directly to the browser, then you need to send the appropriate http header to advise the browser that it's about to receive a stream of binary data that should be treated as an image (PNG, JPG, GIF or whatever). These headings apply to the entire browser page, and default to HTML.

 

When you run graph.php directly, is clearly sending the necessary headers, so it displays correctly

 

When you run it from within a particular place in your application, you have already started rendering html in the page, or have (at the very least) send the http headers to advise the browser that it is about to receive html rather than image data

If your application is trying to embed the chart directly within normal html markup, then it will display binary data... the browser is already rendering the page as html, not as an image of any type

The way to embed an image within your html markup is using <img src="...

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.