This tutorial shows how to create a dynamic data interface script. The script can be written in any
server side language and designed to connect to virtually any data source.
For the purposes of this tutorial we will be using PHP and connecting to MySQL database. At runtime the graphing software will make a URL call to the interface script which in turn will return the data.
The following tutorials assume you have already downloaded and installed the
PHP Advanced Graphs and Charts package.
The latest release can be downloaded here
In this tutorial you will be create a web page and a couple of configuration files. For the purposes of this tutorial you should create a directory /graphtest/ directory under your web root directory.
This tutorial also assumes that you installed the graphing software directly under the web root
(e.g. /webRootFilePath/jpowered/graph/ )
For the purpose of this tutorial the following MySQL database should be created.-
Now add the following data to the 'sales' table:-
Create a file named dataInterface.php which contains the following:-
Replace [USER] and [PASSWORD] with valid logon details for your MySQL server.
Place the file on your web server in a directory /graphtest/ under your web root directory
Note: The above assumes that your MySQL server is running on the same machine as your Web Server. If this is not the case then you will need to replace "localhost:3306" with the correct route to your MySQL server.
Create a file named 'config.txt' and add the following contents to it. This file should then be placed in the /graphtest/ directory.
This config.txt file contains the parameters which determine certain aspects of the graph
like colors and fonts. For the function and options of each parameter see the following page:-
Graph Parameters »
Add this HTML code to your page (replacing [www.YourDomain.com] with the actual domain of your web site and [URL FilePath] with the url of the web directory where your page resides)
Save the web page and load it up to your web server placing it in the /graphtest/ directory.
Open your web browser and view the page. You should see a Stacked Vertical Cylinder Graph with 6 bars plotted.