JPowered.com

Graph and Chart Software Documentation

Custom Data Function

This feature allows you to create your own custom PHP Data Script function. The function will be included at run time and used by the graph to acquire the data.

This method provides enormous flexibility for the data acquisition process. All PHP Global variables ($_REQUEST, $_GET, $_POST, $_SESSION etc) are available to be used within the data function.

A custom data script is specified via the parameter "datascript". For example if your data script is in a file datascript.php then your <IMG> tag would be:-


The [path_to_datascript_file] should be a filesystem file path to the data function file. If a relative file path then keep in mind that this will be relative to the location of the graph software and NOT the page which contains the IMG tag.

The data script must be valid PHP code and should contain at least the following function:-

where $lines is a string array containing the data parameters and values.

The contents of the string array should be the 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 string array should contain:-

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

 

Note: The data script should under no circumstances write out any information via the print or echo functions. This would cause the production of the graph image to fail.

The full function would look like this:-

This is a trivial example but as you can see it is now possible to create a function which will construct the data array based upon any parameter held in $_SESSION or other Global. This method can also be used to pull data from a database.

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

« 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