From 18c573a2403bf43c1ad48090b381fe26712641ec Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 17 Feb 2007 18:51:35 +0000 Subject: [PATCH] Line graphing is done! --- GraphLine.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/GraphLine.php b/GraphLine.php index ac64b57..d171c00 100644 --- a/GraphLine.php +++ b/GraphLine.php @@ -124,6 +124,12 @@ class BSGraphLine extends BSGraph $count += $yint; } + // draw the legend + $legy = $endy + self::SPACING; // "cursor" y-coord for the legend + $legx = $endx + self::PADDING; // x-coord for the legend BORDER + $legex = $this->dimensions['width'] - self::PADDING; // end x-coord for the legend BORDER + imageline($this->image, $legx, $endy, $legex, $endy, $colors['black']); // top legend border + // go through and plot each dataset foreach ($this->dataset AS $data) { @@ -140,8 +146,24 @@ class BSGraphLine extends BSGraph } $oldpoint = array($xcord, $ycord); } + + // draw the legend bit + $box = array( + $legx + 1 + self::SPACING, $legy, // top left + $legx + 1 + self::SPACING, $legy + self::PADDING, // bottom left + $legx + 11 + self::SPACING, $legy + self::PADDING, // bottom right + $legx + 11 + self::SPACING, $legy // top right + ); + imagefilledpolygon($this->image, $box, 4, $data[2]); + imagestring($this->image, 2, $legx + 11 + self::SPACING + self::SPACING, $legy - 1, $data[0], $colors['black']); + $legy += self::PADDING + self::SPACING; } + // finish the legend border + imageline($this->image, $legx, $legy, $legex, $legy, $colors['black']); // bottom + imageline($this->image, $legx, $endy, $legx, $legy, $colors['black']); // left + imageline($this->image, $legex, $endy, $legex, $legy, $colors['black']); // right + return $this->_imageFlush(); } -- 2.22.5