ChartDirector 7.1 (.NET Edition)

BaseChart.makeSession


Usage

[C#]public string makeSession(System.Web.SessionState.HttpSessionState sess, string name [, int imageFormat ]);
[VB]Public Function makeSession(sess As System.Web.SessionState.HttpSessionState, name As String [, imageFormat As Integer ]) As String

Description

Generates the chart as an image, saves it to a session variable and returns query parameters for loading the image.

Note: This method is designed to address the limitation of older HTML standard that only allows the <IMG> tag to contain the URL of an image, but the image itself. The browser, after receiving the HTML, will need to connect to the URL with a separate HTTP connection to get the image.

The HTML was designed that way because when the web was invented, people were still using 2400 bps modem. Loading an image could be very slow, and the network connection was charged on a per minute basis. It was better to see the text first, and load the image later via separate connections. Earlier browsers even allowed users to disable loading images entirely.

Nowadays all browsers support embedding the images in HTML. Network speed is much faster that viewing video is common. Newer ChartDirector sample code no longer use this API.

The makeSession method is designed to support web applications in which the chart is generated in the same script that generates the HTML.

Older HTML standard that only allows the the <IMG> tag to contain the URL of an image, but the image itself. The browser, after receiving the HTML, will need to use a separate HTTP connection to get the image. That means the script that generates the HTML with the chart image cannot put the chart image in the web page. One way is to save the chart image as a file using a unique filename, and then include the url of that image file in the <IMG> tag. This would create many files on the server and another mechanism is needed to clean up old files.

The makeSession method saves the image in a session variable, avoiding creating image files on the hard disk. Almost all web servers today support session variables. The server will destroy the session variable when the user session ends, usually after a period of no activity.

The makeSession method returns query parameters to allow the image to be loaded with the ChartDirector utility script "getchart.aspx".

In a typical application, the chart is created like:

[VB]Dim query1 As String = c.makeSession(Session, "chart1")
[C#]string query1 = c.makeSession(Session, "chart1");

The web page then includes an <IMG> tag as follows:

<IMG SRC="getchart.aspx?<%=query1%>">

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 = "getchart.aspx?" & c.makeSession(Session, "chart1")
[C#]imgControl.ImageUrl = "getchart.aspx?" + c.makeSession(Session, "chart1");

Note that the above assumes "getchart.aspx" is in the same directory as your script. If it is in a different directory, you would need to modify the path in the <IMG> tag. Also, the directory that contains "getchart.aspx" must be in the same web application as your script, otherwise "getchart.aspx" will be unable to access the session variables created by your script.

Arguments

ArgumentDefaultDescription
sess(Mandatory)The session object of an IIS Active Server Page.
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, WMP, SVG, SVGZ or PDF.

Return Value

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