# Advanced Graphs and Charts for PHP

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

## Data from External Scripts

The graph here is produced in a similar manner to the first example except this time we tell the graphing software to load the data from and external script. This method is very powerful and allows great scope in the production of real time graphing. An external script can be used to acquire data dynamically from a wide range of sources including databases, spreadsheets etc.

Here is the IMG tag which invokes the graphing software which dynamically creates the graph image at page load time.

<img src="../../graph/vertical-cylinder-graph.php? data=../demo/examples/data/dataScript.php& config=../demo/examples/data/configFile.txt" width=700 height=400 />

Here we tell the software to load the configuration options from the file configFile.txt and the data from the file dataScript.php (code below)

/* * Create the Data Array * * We are using a prepopulated array here for simplicity. * However this method would be used to first acquire data * from databases, ORM, spreadsheets etc. * */ $dataArray = array('series1' => array(500, 750, 1250, 4300), 'series2' => array(2000, 2100, 2600, 2400), 'series3' => array(8300, 7400, 6200, 3200)); /* * write out the data in the format required for the graphing software */ foreach ($dataArray['series1'] as $dataIndex => $dataValue) { echo 'data' . ($dataIndex+1) . 'series1: ' . $dataValue . PHP_EOL; } foreach ($dataArray['series2'] as $dataIndex => $dataValue) { echo 'data' . ($dataIndex+1) . 'series2: ' . $dataValue . PHP_EOL; } foreach ($dataArray['series3'] as $dataIndex => $dataValue) { echo 'data' . ($dataIndex+1) . 'series3: ' . $dataValue . PHP_EOL; }

Note: the URLs supplied for both the configuration and data are relative URLs. The URLs are relative to the location of the graphing software and NOT this page.

If the graph does not display then see the Troubleshooting guide for details on how to resolve the problem.

Package Index

Documentation

Troubleshooting Guide

Support

#### Examples

- Graphing Data from files
- Data from external scripts
- Custom data function
- Utilising request parameters
- Plotting data from a database
- Database interface scripts
- Multiple Scales, text and images
- Graphing CSV files

#### Basic Chart Styles

- Pie Charts
- X-Y Scatter Graphs
- Bubble Charts
- Area Graphs
- Line Graphs

#### Bar Graphs

- Vertical Bar Graphs
- Stacked Vertical Bar Graphs
- Horizontal Bar Graphs
- Stacked Horizontal Bar Graphs

#### Cylinder Charts

- Vertical Cylinder Graphs
- Stacked Vertical Cylinder Graphs
- Horizontal Cylinder Graphs
- Stacked Horizontal Cylinder Graphs

#### Combination Charts

- Area and Stacked Vertical Bar Graph
- Area and Vertical Bar Graph
- Line and Stacked Vertical Bar Graph
- Line and Vertical Bar Graph