JPowered.com

Graph and Chart Software Documentation

Database Information File

With this method the database information file will contain the necessary information for the graphng software to connect to your database and the queries to run for each data series. At runtime the graphing software will read this file, connect to the database and execute each of the queries. It will then automatically extract the data from the result set(s) for plotting on the graph.

The database information file is a PHP script which assigns various options to a PHP array '$jpDatabase'. This file is used by the graphing software to connect to the database and execute the queries.

The array contains three sections of information:-

  • Database Connection Information
  • Data Queries
  • Database Abstraction Code

An example file can be found in the Sample Application directory ./jpowered/sampleApplication/dataQueries/dbConfig.php

To tell the graph to use a database information file the 'data' parameter of the IMG tag should be replaced with 'dbinfo' parameter, like this:-

The [RELATIVEpathTOdbinfoFILE] should be a relative filesystem file path to the database information file. This file path is relative to the location of the graph software and NOT the page which contains the IMG tag.

Database Connection Information
This section contains 4 parameters which provide the graphing software with the necessary information to open a connection to the database. The parameters are:-

e.g.

Data Queries
The data query section contains the SQL the graph should issue to the database server to extract the data to be plotted. For each series of data the graph needs to know:-

  • The SQL Query
  • The name of the field(s) in the table/resultset to pick the value(s) from
For example if we have 3 series of data then the data query section would look like this:-

The above example will provide the graph with a single value for each data point. However some graph styles require 2 or 3 values (e.g. the X-Y scatter graph requires 2 values and the Bubble chart requires 3 values for each data point). For these graph styles the format would be like this:-

NOTE: All PHP Global variables ($_REQUEST, $_GET, $_POST, $_SESSION etc) are available to be used within the database information file. For instance if you wish to dynamically construct a query based on the value of "userID" held in the session then you could do something like this:-

Database Abstraction Code
This parameter tells the graphing software to use database access methods located in the file specified. The software will look for the file in the dir ./jpowered/graph/common/ Currently database methods are supplied for the MySQL database system and are located in the DBMySQL.class.php file. As such the parameter should be set like this:-

Putting it all together the database information file should look like this:-

« back to Graph Data

 

Documentation

Demo Index

Troubleshooting Guide

Support

Documentation Contents

Adding Graphs to Web Pages

Configuration Options and Parameters

Supplying the Graph with Data

Sample Image Tags

Database Connections

Database Information method

Custom Data Function

Installation Help

Upgrade PHP

Upgrade GD

Log File

Allow URL Fopen