Re: Using PHP + GD to make bar graphs?

From: Date: Thu, 05 Jul 2001 17:54:32 +0000
Subject: Re: Using PHP + GD to make bar graphs?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56351@lists.php.net to get a copy of this message
"Robert L. Yelvington" <robert@sciresearch.com> writes: > on 7/5/01 10:15 AM, Arcady Genkin at a.genkin@utoronto.ca wrote: > > > While taking a university course I needed to ``squash the competition'' by > > hacking together quick bar-charts with PHP. These are not very > > sophisticated, but I liked my approach because they generate very > > little graphics (read: fast downloads), and when you roll a mouse over > > a bar, you get numeric value for it. Have a look at: > > http://www.thpoon.com/408/barchart.php > > Input is taken from a text file. If anyone is interested in the > > source code, let me know and I'll release it. The code is rather > > trivial, though. > > They look very nice and usable...just the way i like 'em. > > I'd be interested in seeing the source code...you can reply directly to my > email account if you like! are you using a graphic package like GD? or are > you using the 'poor mans bar graph' method using tables and percentage > widths? Each individual bar is generated with GD, and arranged in a table. The images are stored in subdirectory "bars" (should be writeable to Apache). Each bar is given a name like bar_NNN.png, where NNN is its height in pixels. If a bar of a given name already exists, it is not re-generated. I never intended to release the code, so it has some stuff hard-coded, like the number of columns and the colors, and not commented. Shouldn't be hard to change, though. Ideally the whole thing would be organised in a class. If anyone takes the time to rearrange the code, or improve it otherwise, I'd like to see the results (although you don't really have to). All functions are in a file "barchart.inc": http://www.thpoon.com/408/barchart.inc.phps Example of using the functions are in this file: http://www.thpoon.com/408/barchart.phps Example input file is here: http://www.thpoon.com/408/sqattl.txt Have fun, -- Arcady Genkin i=1; while 1, hilb(i); i=i+1; end

« previous php.general (#56351) next »