graph chart

Area Graph Examples

[ Graph Home ] [ Documentation ] [ Getting Started ] [ Solutions ]

Applet Example 6 - Data from a Database

if you do not see the graph below then click here

 

This example demonstrates how to implement the applet so that the graph data is acquired from a database. Here we set up the applet to acquire the configuration from a text file and the graph data from a server side process which in turn acquires the data from a database.

The configuration data is acquired from the text file ../../area_graph/Examples/areaprops.txt (click here to view)

and here is the HTML code,

<applet code="AreaGraphApplet.class" archive="AreaGraph.jar" width="460" height="440">
<!-- Start Up Parameters -->
<PARAM name="LOADINGMESSAGE" value="Area Graph Loading - Please Wait."> <!-- Message to be displayed on Startup -->
<PARAM name="STEXTCOLOR" value="0,0,100"> <!-- Message Text Color-->
<PARAM name="STARTUPCOLOR" value="255,255,255"> <!-- Applet Background color -->

<!-- Data files -->
<PARAM name="chartproperties" value="../../area_graph/Examples/areaprops.txt">
<PARAM name="chartdata" value="http://www.jpowered.com/area_graph/areadata.php">

</applet>

The areadata.php script is designed to retrieve product sales data from a MySQL database, from a table with the following structure,

Table Name : ProductSales
ProductName Character
Quarter1sales Integer
Quarter2sales Integer
Quarter2sales Integer
Quarter2sales Integer
Year Integer

 

The script will pick out the sales figures for the year 2001 for three products ( ProductX, ProductY and ProductZ) and return the data in the correct format for the area graph.

The method is as follows,

  • Set the output characteristics for the return data
  • Establish the database connection
  • Build the query statement and retrieve the database records
  • Process the database records and return the Data
  • All finished so close the database connection

For a full explanation of and range of values for the above parameters please see the Documentation - Configuration Options».

« back to Examples Index

« back to Getting Started

[ Graph Home ] [ Documentation ] [ Getting Started ] [ Solutions ]

Getting Started

Documentation

Examples

Common Problems
This section describes and provides solutions to common problems.