phpLens manual: GIF Graphing
Table of Contents
GIF Graphing
The graphing interface in PHPLens 5 allows you to generate gif graphs using JPGraph. You will also need
to have the GD extension installed.
JPGraph is an open source software that you can download here.
JPGraph is not free for commercial use. You will need to purchase a license if you use it commercially.
Installation
Download and unpack the correct version of jpgraph to a directory, say c:\jpgraph\jpgraph-1.19. For PHP 5, you will need to download jpgraph 1.20 or later.
Then modify your phplens/config/phplens.config.inc.php file, adding at the bottom:
define('PHPLENS_GRAPH_DIR', 'd:/inetpub/wwwroot/jpgraph/jpgraph-1.19/src');
The next time you create an applet, click on the red "e" button, and you should see the following graph tab:
Graphing
To enable graphing, click on the Show Graph menu, and select "Show Graph and Grid" or "Show Graph, Hide Grid".
You can create the following types of graphs:
- Bar: Each row of the selected numeric column will be treated as a vertical bar. You will see N x C bars if there are N rows and C numeric columns selected.
- Horizontal Bar: Each row of the selected numeric column will be treated as a horizontal bar.
- Stacked Bar: Each selected numeric column in a row will be stacked. So you will see N bars if there are N rows.
- Line: Each selected numeric column will form one line on the graph.
- Pie: The first selected numeric column will be used.
The first non-numeric column will be used as labels for the x axis.
Options
- Data Series: Sometimes you want to transpose the data you store. For example, you have the following data:
| Category | y2001 | y2002 | y2003
| | Sales | 30000 | 50000 | 70000
| | Cost of Goods Sold | 23000 | 34000 | 47000
|
You want to graph "Sales" and "Cost of Goods Sold". Select this option to treat the columns y2001, y2002 and y2003 as the data series to be graphed.
-
Background Color: To change the background color.
-
Show Values: Will display values in the graph.
-
Title: Title to display on graph.
-
X-Axis and Y-Axis: Titles to display on X and Y axis.
-
Scale: Linear or Log. For values with large swings in range, use Log Scale.
- Image Map URL: Allows you to define a client-side mapping, with the primary key of the bar that was clicked stored in the $_GET['_key_'] variable. So if
http://localhost/drill.php was set as the Image Map URL, then clicking on the value with primary key=33 will lead the browser to the following URL:
http://localhost/drill.php?_key_=33
For this setting, allow_url_fopen must be enabled in php.ini and the property $lens->keyCol must be defined.
- Margins: Add extra margin space around the edges. In pixels.
- Axis Labels:
By default, labels are below the axis. If all the values to be graphed are negative, this might cause the labels to be obscured by negative values.
Selecting this option will move the labels above the axis.
Modifying Colors
The colors are stored in phplens-graph.inc.php:
var $colors = array('lightskyblue3','cyan4','orange','tomato3','purple',
'darkred', 'darkorange3','darkblue','chocolate4','darkmagenta');
var $lightcolors = array('lightskyblue3','lime', 'orange', 'tomato2',
'yellow','cyan','magenta','cadetblue1','gold','deeppink');
var $piecolortheme = 'earth';
If the background color is light, then $colors is used. If the background color is dark, then $lightcolors is used. To change the colors,
define the global variable $PHPLENS_GRAPH_COLORS = array($colorsArray, $lightcolorsArray) in phplens.config.inc.php, containing the colors you
want to use.
Caching
If you have JPGraph caching enabled, you might not be able to see changes you make to phpLens until the cache files are deleted.
By default, image files are cached for 10 mins (see cacheMins in phplens-graph.php) if USE_CACHE is set to true in jpg-config.inc.
This documentation system is maintained using phpLens
|