JPowered.com

Graphing Tutorials - Dynamic Configuration

 

Dynamic Configuration

This tutorial demonstrates how to dynamically calculate the values of configuration parameters at runtime.

For example the data and x-axis labels may need to be constructed based upon selections made be the user.

Prerequisites

The following tutorials assume you have already downloaded and installed the
PHP Advanced Graphs and Charts package.

The latest release can be downloaded here

Directory Structure

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/ )

Step 1 - Create a test MySQL Database

For the purpose of this tutorial the following MySQL database should be created.-

Now add the following data to the 'salesPerYear' table:-

Step 2 - Create a Custom Data Function

Create a file named datafunction.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.

Step 3 - Create the config file

Create a file named 'config.php' and add the following contents to it. This file should then be placed in the /graphtest/ directory.