Implementing the Applet

Incorporating the graph applet into your web page involves the following four simple steps,

Step 1 - Add the applet html code to your web page
In your web page place the following code, where you wish the line graph to appear,

<applet code="LineGraphApplet.class" archive="Linegraph.jar" width="500" height="420">
</applet>

Adjusting the "width" and "height" element of this applet tag to specify the size (in pixels) of the desired graph display.

Step 2 - Set up the Configuration data.
The line graph applet provides the following three options for inputting the configuration data.

a) Configuration File.
The applet will read all the configuration parameters from a specified file. To use this option add the following PARAM tag to your html code between the <applet> and </applet> tags,

<PARAM name="chartproperties" value="lineprops.txt">

where "lineprops.txt" is the name of the file containing the configuration data ( click here for an example file ). As you will see from the example file each property is specified on a name, value basis. The first 20 character positions of each line represent the property name and position 21 onwards the value. (Also note that comments may be added to this file by placing "<!--" at the beginning of a line.).
Adjust the property values to specify the characteristics of the line graph and then place this file in the same directory as your web page.

For a full description of each property please see the "Configuration Options and Parameters".

b) HTML PARAM tags.
Using this option the applet will read all the configuration information from the standard applet <PARAM> tags. Simply add the <PARAM> tags, contained in the paramtags.txt file (click here), to your html between the <APPLET> and </APPLET> tag, adjusting the values to specify the characteristics of the line graph.

For a full description of each property please see the "Configuration Options and Parameters".

c) Server Side process
This option allows the line graph applet to obtain all the configuration data from a server side application. The server side script should be designed to output the configuration data in the same format as the file in option a) above (i.e.. First 20 character positions of each line specify the parameter name, whilst positions 21 onwards specify the value).

The following PARAM tag should be added to your html between the <APPLET> and </APPLET> tags.

<PARAM name="chartproperties" value="[URL of Server Process]">

inserting the URL of your server side application in the value element of this tag.
For an example script see LineConfigServlet.java in the ServerTemplateScripts directory.

For most implementations supplying the configuration data either from a data file or HTML parameters will be the most efficient, however supplying this data via a server side script is useful where you wish to hold this data in a database. A server side script would then be used to read the config data from the database and then supply to the applet at runtime.

Step 3 - Set up the line graph data
As with the configuration data there are three options for supplying the line data to the applet,

a) Data File.
The applet will read all the line data from a specified file. To use this option add the following PARAM tag to your html code between the <applet> and </applet> tags,

<PARAM name="chartdata" value="linedata.txt">

where "linedata.txt" is the name of the file containing the line data ( click here for an example file ). As you will see from the example file each piece of data is specified on a name, value basis. The first 20 character positions of each line represent the data name (specifying the series and data order) and position 21 onwards the value. (Also note that comments may be added to this file by placing "<!--" at the beginning of a line.).
Simply create a similar file, adding your line data in the values. For a full explanation of this file please see the "Retrieving Data from Files" under the "Data and Configuration" section ( or click here).

b) Server Side process
This option is the most powerful and gives the applet the ability to retrieve data from databases without compromising database security. This method involves specifying a server side script in the html page which in turn returns the data to the graph applet, giving enormous flexibility for data acquisition. The server side script can be constructed in the language of your choice and as such can be written to acquire data from the widest variety of sources, multiple databases etc.

To instruct the applet to retrieve data from a server side script simply insert the following <PARAM> tag between the <APPLET> and </APPLET> tags in your html page.

<PARAM name="chartdata" value="[URL of Server Process]"

inserting the URL of your server side application in the value element of this tag. The server side script should be designed to output the data in the same format as the file in option a) above (i.e.. First 20 character positions of each line specify the data name, whilst positions 21 onwards specify the value).

For an example script see LineDataServlet.java in the ServerTemplateScripts directory.

For a full description of constructing a server side script which retrieves data from a database see the section "Connecting the Graph to a database" under the "Data and Configuration" section ( or click here).

c) HTML PARAM tags.
Using this option the applet will read all the graph data from the standard applet <PARAM> tags. Simply add the <PARAM> tags, contained in the dataparamtags.txt file (click here), to your html between the <APPLET> and </APPLET> tag, adjusting the values to specify the data for the line graph.

This option is the simplest method of supplying data to the graph applet and is probably most useful where the graph data is either static or the html page is constructed dynamically, (e.g.. Via ASP or JSP.)

Step 4 - Upload the jar file to your web server.
The final step is to simply to place the LineGraph.jar file in the same directory as your web page. At only 13kb this jar file contains all the applet code for producing the graph in your page and as such is very fast to load and run.

 

If you experience any difficulties implementing then please do not hesitate to contact us at,
support@jpowered.com