# Advanced Graphs and Charts for PHP

- Graph Home
- Pricing / License Options
- Online Demos
- Documentation
- Tutorials

# Graph Data

Overview

Every graph requires the data to be plotted. The graphing software has been designed to take the data directly from the source and dynamically produce the graph image in real time. The graphing software can be configured to read the data from a variety of sources including:-

- Databases
- Files
- Other Server Side Processes

( Note: further data access methods may have been added since this documentation was written, as such please also check the online documentation here » )

Data from Databases

The graphing software provides two direct methods by which data can be read from databases:-
Custom Data Function
This method allows a custom data function to be constructed. At runtime the graphing software will dynamically include this function and run it to produce the data.
If you need to dynamically construct the SQL Queries (e.g. depending on the value of SESSION or REQUEST variables) or you need to process the query results before plotting (e.g. averaging a data set) then this is the method to use.
more »
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. more »

Further information and examples can found in the Online Tutorials here »

Data from Files

If the data is fairly static then you may wish to place the data in a flat file. In this case the graphing software is configured to read the data from that file.
To set the graph to read the data from file simply add the "data" parameter to the URL string of the <IMG> tag. For example if the data file is "graphdata.txt" then your <IMG> tag would become:- <img src="line-graph.php?data=graphdata.txt" width=500 height=500> Data Format Within the file the data should follow this format:-

> dataNseriesM: [value]

where
N represents the position of the data item in the series and
M represents the series number.
For example for 3 series of data each containing 6 points the contents of the data file would be:- data1series1: 30 data2series1: 20 data3series1: -10 data4series1: 40 data5series1: 50 data6series1: 60 data4series2: 40 data5series2: 50 data6series2: 60 data1series3: 100 data2series3: 50 data3series3: -25 data4series3: 75 data5series3: 125 data6series3: 150
Other Server Side Processes

The graph data can be set to call another server process and request the data. This can be a script in any language and does not necessarily have to reside on the same server. The only stipulation is that the process is accessible via a URL.
The script or process can be written to perform any processing required including connecting to any database system. For example if your data is held in MS SQL Server or Oracle then an ASP script would be written to extract the data from the database and output in the format required for the graph. At runtime the graphing software will call the script which in turn will read the data from the database and output the data back to the graphing software where it is plotted directly on the graph.
To set the graph to read the data from another server side process (ie. PHP, ASP, JSP etc) simply add the "data" parameter to the URL string of the <IMG> tag.
For example if the data script is "graphdata.php" then your <IMG> tag would become:- <img src="line-graph.php? <font color="#CC0000">data=graphdata.php</font>" width=500 height=500> Data Format The data script should be written such that it outputs the data in the following format:-

> dataNseriesM: [value]

where
N represents the position of the data item in the series and
M represents the series number.
For example for 3 series of data each containing 6 points the output of the data script would be:- data1series1: 30 data2series1: 20 data3series1: -10 data4series1: 40 data5series1: 50 data6series1: 60 data4series2: 40 data5series2: 50 data6series2: 60 data1series3: 100 data2series3: 50 data3series3: -25 data4series3: 75 data5series3: 125 data6series3: 150

Further information and examples can found in the Online Tutorials here »

### Also see:-

Configuration Options and Parameters »

Package Index

Demo Index

Documentation

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

more Documentation Online here