Generates 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 retrieve 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 directory specified by
dirname. To avoid building up of too many temporary files, it will automatically remove all files older than a certain life time (default 600 seconds) in that directory.
Note that the
dirname is a file system path, not a URL path. For example, the directory "/tmp/tmpcharts" means a path relative to the root of the hard disk, not the root of the web document directory.
It is not uncommon to use a temporary directory outside of the web document directory, (such as under the /tmp directory). However, that means the image cannot be referenced in the <IMG> tag URL. To address these cases, ChartDirector includes a utility script "getchart.pl" that can be used to load a temporary file created by makeTmpFile. The URL will be like:
my $url = "getchart.pl?img=/tmp/tmpcharts/" . $c->makeTmpFile("/tmp/tmpcharts");
In the above, the makeTmpFile method creates a temporary file in the "/tmp/tmpcharts" directory, and returns the filename. The "getchart.pl?img=[full_path_name]" is then used to load the file.
If makeTmpFile is unsuccessful, an empty string will be returned. In this case, please check that the temporary directory exists, and is readable and writable by the web server anonymous user .
It is highly recommended you use a dedicated directory for storing temporary files created by ChartDirector. This is to avoid makeTmpFile from accidentally removing old files belonging to other applications.
The temporary file name (not including the path), or an empty string in case of failure.
© 2006 Advanced Software Engineering Limited. All rights reserved.