PTS-GRAPHER UTILITY

Pts-grapher is a graphing utility written to fill the benchmark graphing needs at Phoronix.com and will be part of the Phoronix Test Suite for rendering the results. Pts-grapher is written in PHP and currently uses the GD library for rendering the graphs to PNG. While pts-grapher is focused for use within the Phoronix Test Suite, it can be easily adapted to serve other purposes as well. Pts-Grapher is licensed under the GNU GPLv3.

Pts-grapher was created by Michael Larabel. Suggestions, patches, etc welcome to: Michael AT phoronix.com Any support or discussion should be directed to http://www.phoronix.com/forums/forumdisplay.php?f=49. The source-code is housed at Phorogit.com.

Pts-grapher supports both bar and line graphs at this time. Other graphing formats can be easily added too by just extending ptx_Graph.

RELEASES

Version 0.1 (March 06, 2008): Initial Release

TODO

- Write an SVG renderer as an alternative to the PNG-GD rendering
- Clean up some of the code
- Some of the naming conventions still need to be formalized
- Support more graph types

DEPENDENCIES

- PHP 5.x
- GD 2.x Library

USAGE

Using the scripts provided within the Phoronix Test Suite will provide seamless integration to the pts-grapher capabilities and/or using the remote capabilities (see the REMOTE/LIVE section). However, the programming interface for pts-grapher is quite simple. There are some sample scripts already provided, which are described in the SAMPLES section. Below is a basic (and brief) description of the API.

$graph = new pts_BarGraph("Title of Graph", "Sub-Title", "Vertical Axis Label");

The above code will instantiate a new bar graph. If you wish to instantiate a line graph, use pts_LineGraph instead of pts_BarGraph. The first argument is the title of the graph, the second argument is the sub-title, and the third is the Y-axis label.

$graph->loadGraphIdentifiers(array("Item 1", "Item 2", "Item 3", "Item 4"));

loadGraphIdentifiers() is used for loading the identifier labels along the X axis. Pass an array containing the identifiers to loadGraphIdentifiers() with a length of the number of itmes that will be graphed.

$graph->loadGraphValues(array(3.5, 2.2, 1.339, 4.21), "Test Set 1");

loadGraphValues() is used for loading an array containing the actual values that will be graphed. The length of this array should be the same as the array passed in loadGraphIdentifiers(). The second argument is optional and is used when calling loadGraphValues() multiple times where a key will be created along the top of the graph.

$graph->renderGraph();

This function will render the graph and return the resulting contents. The contents can then be outputted to the screen. Be sure to specify the header Content-type of image/png within your code. For customizing the graph, see the CUSTOMIZATION section.

SAMPLES

Check out the samples for learning more about how to use pts-grapher in custom environments.

sample-advanced-bar-graph.php: A bar graph using loadGraphValues() multiple times with the key shown at the top.
sample-bar-graph.php: A simple bar graph.
sample-dynamic-graph.php: Similar to sample-advanced-bar-graph.php, but with dynamic values being used.
sample-line-graph.php: A line graph version of sample-advanced-bar-graph.php.

REMOTE/LIVE

If you don't have PHP and/or GD installed, you can view the sample pts-grapher code at http://www.phoronix-test-suite.com/pts-grapher/realtime/

In addition, by using the graph-remote.php interface, you can use that for generating graphs. The Phoronix Test Suite will use this interface so that graphs can be generated remotely when the user doesn't have GD installed on the test system. http://www.phoronix-test-suite.com/pts-grapher/realtime/graph-remote.php

CUSTOMIZATION

All configuration options are contained within object_pts_Graph.php. These include font size, size of graph, colors for everything, etc. In the __construct function of this file, the path to the TTF fonts on the system must be specified. Pts-grapher defaults to the current working directory.

Pts-grapher isn't distributed with any TTF fonts. If you are looking for TTF fonts, try the DejaVu or Liberation font-sets are two good options.