ChartDirector Ver 4.1 (PHP Edition Edition)

BaseChart.makeSession


Usage

makeSession(name[, imageFormat])

Description

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

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 makeSession method returns an HTTP query string as follows:

img={name}&id={unique_random_string}&[SID]

where {name} is the name of the session variable, and {unique_random_string} is a string generated by ChartDirector for creating unique URL. (This is to avoid caching problems with browsers.) [SID] is a query parameter automatically generated by PHP for browsers that do not support cookies. Its purpose is to allow PHP to support session variables without using cookies.

The HTTP query string is designed to be used with another ChartDirector utility "getchart.php", which retrieves the image from the session variable and returns it to the browser

In a typical application, the chart is created in the main HTML web page using code similar to:

$query1 = $c->makeSession("chart1")

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

<IMG SRC="getchart.php?<?php echo $query1 ?>">

When the browser reads the HTML web page and sees the <IMG> tag, it will load the image using "getchart.php" from another HTTP connection.

Note that the above assumes the "getchart.php" is located in the same directory as your web page. If it is in a different directory, you would need to modify the path in the <IMG> tag.

Arguments

ArgumentDefaultDescription
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 the "getchart.php" utility.