Generates the chart as an image and save it to a temporary file, and automatically remove old files.
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 files older than a certain life time (default 600 seconds) in that directory.
Note that makeTmpFile expects
dirname be a file system path, not a URL path. For example, the directory "/tmp/tmpcharts" means a directory at the root of the hard disk, not the root of the web document directory. Also, a relative path like "tmpcharts" or "../tmpcharts" is relative to the "current working directory" of the file system, which may not be the same as the "current script directory". It depends on the brand and configuration of the web server. To avoid uncertainties, it is not suggested to use relative paths.
To use a directory that is under the web document directory (so that the browser can load the image), please use the Server.MapPath method to translate the URL path to a full file system path.
In a typical application, the code is like:
[VB] filename = c.makeTmpFile(Server.MapPath("/tmpcharts"))
[C#] filename = c.makeTmpFile(Server.MapPath("/tmpcharts"))
In the above, "/tmpcharts" is the URL path of the temporary directory. The makeTmpFile method returns the temporary file name, which can be used in an <IMG> tag to load the image.
<IMG SRC="/tmpcharts/<%=filename%>">
Note: The variable "filename" above should be declared as a text string as a member variable (as opposed to a local variable), so that the variable is visible at the scope of the <IMG> tag.
If an ASP.NET web image control is used for image display, the following code can be used (assuming "imgControl" is the web image control):
[VB] imgControl.ImageUrl = "/tmpcharts/" & c.makeTmpFile(Server.MapPath("/tmpcharts"))
[C#] imgControl.ImageUrl = "/tmpcharts/" + c.makeTmpFile(Server.MapPath("/tmpcharts"));
Please ensure the temporary file directory exists and is readable and writable by the web server anonymous user. ChartDirector will not create the directory. By default, most systems are configured to deny anonymous user write access to any web server directory. You may need to modify your directory security settings to allow the "Everyone" group to write to the temporary file directory.
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. Also, please ensure Server.MapPath has been used to map URL paths to file system paths.
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.
Note: To output true vector graphics in SVG or SVGZ format, please ensure
BaseChart.enableVectorOutput is called immediately after creating the BaseChart object. Otherwise the output will be a bitmap image embedded in SVG or SVGZ.
The temporary file name (not including the path), or an empty string in case of failure.
© 2012 Advanced Software Engineering Limited. All rights reserved.