![]() |
FAQ » Script output
|
|
Latest updates
Toolbox
Google AdSense
|
Script output - How to deal with it There is basically two way to use the output stream of the pChart library. Rendering to the web browser The most common way to use this library. Your script are processing real time or archived data and then generate a picture that is sent directly to the user browser. Server side, you‘ll call the stroke() function, client side, you‘ll invoke the script from an <IMG> HTML tag. The whole stuff would be like : Server Side (mypic.php) /* Render the picture (choose the best way) */ $myPicture->stroke;Client side (mypage.html) <IMG SRC=‘mypic.php‘> Calling the Stroke() method in your script will automatically send the ‘Content-type: image/png‘ header to the user web browser and the raw picture in the HTTP GET data field. Rendering to a flat file This option is often used by scheduled tasks and automatic script that are run on a regular interval and generate a picture that will be access like a standard file from the web server. Those pictures may also be used inside complex documents (PDF, bigger pictures). To render a picture to a file, just invoke the render("myfile.png") function. Server Side (mypic.php) /* Render the picture (choose the best way) */ $myPicture->render("mypic.png");Client side (mypage.html) <IMG SRC=‘mypic.png‘> ..with this way, the user browser will NOT trigger the picture generation. the mypic.php should be called by another source. Automatic method choosing You may have noticed that the examples shipped with the pChart library can either be run from a web browser or the command line. This behavior is possible because of the autoOutput("myfile.png") method. If this method is called from a CLI session then the picture will be rendered to a file. If this method is called from any other type of session, the picture will be sent to the user browser. Server Side (mypic.php) /* Render the picture (choose the best way) */ $myPicture->autoOutput("mypic.png");Client side (mypage.html) <IMG SRC=‘mypic.php‘> ..if mypic.php is called from the IMG tag, the picture will be sent to the browser. If it is called from a CLI interface, a file named mypic.png will be created.
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has
been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 415 users have registered.
This page has been rendered in 0,02 seconds. Wiki revision 1.37.
|