The PHP Text Graph Script

History

Well, the title pretty much sums it up - a little PHP script that will draw a bar graph in text.
"Why ?" some people may ask. The answer is quite simple. I have a little statistics page for my web site that I wanted to add some sexy graphs to. However with PHP you need to compile in the GD library to draw gif images. I have the old version of the library but for some reason PHP just would not compile it in. Such is life. Anyway, since the graphs were not going to be all that complicated I thought "Why not draw them with text ?", and so the script came to be born.

Releases

Well, so far there has only been the one release which can be obtained below.
As I think of more ideas the script will progress.
Likewise, feel free to mail me and tell me all about them.

Downloads

So far only version 0.1.1 has been released.
Get it here

Usage

Firstly, the textgraph.class file must be included :

include('textgraph.class');

Next, the class must be initialised :

$textgraph = New TextGraph;

The height (in lines of text) can be set at any time before the graph is displayed :

$textgraph->SetHeight(10);

The values of the columns (as integers) must be set before the column names are. This saves having to manually set how many columns the graph will have :

$textgraph->SetColValues(array('123','244','223','114','50'));

Now the column names must be set after the column values are :

$textgraph->SetColNames(array('one','two','three','four','five'));

Finally we draw the graph :

$textgraph->Draw();

The results of the above code can be seen below : SetHeight(10); $textgraph->SetColValues(array('123','244','223','114','50')); $textgraph->SetColNames(array('one','two','three','four','five')); $textgraph->Draw(); ?>

To see a live version of the graph you can check out a horribly tacky stats page I have done for my website at http://wwww.atari.co.uk/newstats.html

License

This little script comes under the terms of the my license which consists of this :
This script is copyright (c) Tom Buck 1999.
It may be distributed freely as long as no fees are exchanged and this documentation is included.
The script may not be sold commercially, but may be freely used.
You may alter this script as you see fit but any derivatives of it must be referenced to me and may not be sold.

Have fun !

All scripts and web pages (c) Tom Buck 1999.