graph demo

Graphs and Charts Applet Tutorial

graph demo[ Home ] [ Products ] [ Downloads ] [ Purchase ]
[ Support ] [ About Us ]

Utilizing Server Side Scripts to dynamically populate the Line Graph Applet or Servlet

Prerequisites
Graphs and Charts Package - For this tutorial you will need the Advanced Graph and Chart package. If you haven't already done so then you should first download the software here

The Web Server must be capable of running a Scripting Language (eg. ASP, PHP, JSP etc).
Overview
This method provides the ability to add Real-Time Dynamic Database Graphing to your web pages. This method is extremely powerful and allows the construction of graphs from virtually any database system running on virtually any platform.

The idea behind this method is that the graph function will make a request to a server side script for the data. This means that the script can be written to first read data from a database before returning the data values back to the graph function. Hence the result is real-time graphing capability.

Although this tutorial focuses on the Line Graph Applet, this method can be used for any chart style provided in the Advanced Graphs and Charts package (including bar, pie and area graphs).
Method
The graph applet is incorporated into a a static HTML page but rather than supplying the data with PARAM tags or flat file, the graph is set to acquire data from a server side script. The server side script accesses the database and returns the graph data to the applet. At page view time the graph function will request the data from the server side script. The server side script will then acquire the data in real time from a data source (eg. database) and return it to the graph function. Hence producing a Real-Time Dynamic Graph with data from a database within the web page.

Step 1 - Construct the Data Script
The dynamic script can be constructed in any language of your choice. Most Web Servers these days come set up with a dynamic scripting language which is configured to access your database system. For convenience we recommend using the language already configured on your web server.

(if you haven't used or are unsure about what's already available on your web server then you should in the first instance speak to your Web Server Administrator or ISP Hosting company ).

The following are the most common Scripting languages and cover over 90% of web servers in use today,

  • PHP
  • ASP (and ASP.NET)
  • JSP
  • Java Servlet
The following text boxes contain some example script written in the above languages. These are provided for you to copy and base your own script on. In each case the script is written to connect to MySQL database and retrieve data from a table. The data from the database is then formatted before being returned to the graph.

Template PHP Data Process:-


Template ASP Data Process:-


Template JSP Data Process:-


Template Java Servlet Data Process:-


Step 2 - Construct the HTML Page
Add the following to your HTML page replacing "[SCRIPT NAME HERE]" with the URL to the dynamic data script created in step 1 (eg. linedata.php )


Adjust the values to create the line graph style you require.

For a full description of each property please see the following section in the Documentation,
"Line Graph Parameter Reference"

Step 3 - Upload the jar and script file to your web server.
The final step is to simply to upload the script to your web server and place the Linegraph.jar (contained in the ./AppletFiles/ files directory of the downloaded package) file in the same directory as your web page.

The Graphs and Charts Package can be downloaded here

The jar file contains the compiled Java code (software) which produces the graph image at page view time.

Further Help and Support
If it any stage you require help, advice or simply have a general enquiry then please feel free to contact us.

Contact Support here
Related Information
Documentation
Demos and Examples
Custom Solutions Center
If would like us to perform the set-up process, create custom built data scripts or help with any other part of your web application then we are pleased to offer you the following services:-
JavaScript CSS Image Gallery