ChartDirector Ver 3.0 (Perl Edition)

BaseChart.makeTmpFile


Usage

makeTmpFile(path[, imageFormat[, lifeTime ]])

Description

Generate the chart as an image and save it to a temporary file, and automatically remove old files.

This method is designed to support web applications styles where the chart is generated in the HTML page (eg. applications involving clickable charts). In HTML, an image can only be delivered using an <IMG> tag in the page. So after the chart image is created, it needs to be stored in the server temporarily to wait for the browser to retreive it using the <IMG> tag URL.

(An alternative would be to create the chart image when the server receives the <IMG> tag URL request from the browser. In this method, the chart image can be streamed directly to the browser without any temporary storage.)

The makeTmpFile method creates the temporary file in the given path. To avoid building up of too many temporary files, the makeTmpFile method will automatically perform garbage collection by removing all files older than a certain life time (default 600 seconds).

If makeTmpFile is unsuccessful, an empty string will be returned. In this case, please check that the temporary directory exists, is readable and writable by the web server anonymous user .

It is highly recommended you use a dedicated directory for storing temporary chart images. The makeTmpFile garbage collection mechanism will remove all files older than a certain life time in that directory, irrespective of what the file is. If the directory contains some other files, they will also be removed.

Arguments

ArgumentDefaultDescription
path(Mandatory)The directory to store the temporary file and to remove old files.
imageFormatPNGA constant representing the format of the image. Must be one of the pre-defined constants PNG, JPG, GIF, BMP or WMP.
lifeTime600The life time of files in seconds. All files older than lifeTime will be deleted. A negative value disables automatic file removal.

Return Value

The temporary file name, or an empty string in case of failure.