ChartDirector Ver 4.1 (ColdFusion Edition)

BaseChart.makeSession


Usage

public String makeSession(PageContext pageContext, string name [, int imageFormat ]);

Description

Generates the chart as an image and save it to a session variable.

Creating a chart in an HTML web page requires two HTTP requests. The browser first sends a request to the web server, and the web server creates the chart and returns the web page. However, the web server cannot return the chart image directly. According to HTML standard, it can only return an <IMG> tag to represent the chart image.

When the browser sees the <IMG> tag, it sends the second HTTP request to load the chart image.

Between the first and second requests, the server must find some temporarily location to store the chart image. A common method is to store it in a session variable. In this case, the <IMG> tag will contain a URL for a standard ChartDirector JSP or Servlet that returns the image in the session variable.

(An alternative is to use a temporary file instead of session variable to store the chart image. Please refer to BaseChart.makeTmpFile for details.)

The makeSession method is used to generate the chart as an image and save it to a session variable. The code will be similar to:

chart1URL = c.makeSession(GetPageContext(), "chart1");

The makeSession method returns a URL query string that can be used in the <IMG> tag as follows:

<img src="getchart.cfm?#chart1URL#">

In the above line, getchart.cfm is a standard ChartDirector CFM that retrieves the chart image from a session variable and returns it to the browser. This CFM is included in the ChartDirector distribution. You should copy it to a directory that matches with the URL in the <IMG> tag.

Arguments

ArgumentDefaultDescription
pageContext(Mandatory)The PageContext object representing the current web page. This is typically obtained by using the ColdFusion "GetPageContext" function.
name(Mandatory)The name of the session variable used to store the chart image. If there are multiple chart images in the same web page, each image must use a different name.
imageFormatPNGA constant representing the format of the image. Must be one of the predefined constants PNG, JPG, GIF, BMP or WMP.

Return Value

A string representing the query parameters for retrieving the image using getchart.cfm.