topical media & game development
professional-sql-09-lib-BarChart.php / php
<?php
class BarChart
{
private height; // height of chart
private black; // allocated color black
// initialize new object
public function __construct(height)
{
// create new image
width, this->width = this->height = white = imagecolorallocate(this->image, 0,0, this->black = imagecolorallocate(this->image, 20, 0, 20, this->black);
imageline(height - 20, height - 20,
filename = '')
{
if (this->image, this->image);
}
}
// graph the data using the associated colors and labels
public function graphData(colors, x = 20;
this->height - 20;
// calculate bar width
this->width - data);
data);
foreach (i => bar_height = (ymax) * (color = imagecolorallocate(colors[colors[colors[this->image, y, bar_width,
bar_height, this->image, y, bar_width,
bar_height, this->image, 2, y, i], x +=
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.