summaryrefslogtreecommitdiffstats
path: root/src/driver
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-06-12 11:09:21 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-06-12 11:09:21 +0000
commitcbb748d7d430f2244839ed37ada0647a020ce7cd (patch)
tree94ae4cfed98646420e00fdb11abe9bed1920259c /src/driver
parente70916dae91a1ca09f7464090d1739e7acedc1c7 (diff)
downloadzetacomponents-graph-cbb748d7d430f2244839ed37ada0647a020ce7cd.zip
zetacomponents-graph-cbb748d7d430f2244839ed37ada0647a020ce7cd.tar.gz
- Added tests and basic implementation for pie charts
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/gd.php55
-rw-r--r--src/driver/svg.php6
2 files changed, 42 insertions, 19 deletions
diff --git a/src/driver/gd.php b/src/driver/gd.php
index e112507..19064c2 100644
--- a/src/driver/gd.php
+++ b/src/driver/gd.php
@@ -43,8 +43,8 @@ class ezcGraphGdDriver extends ezcGraphDriver
if ( !isset( $this->image ) )
{
$this->image = imagecreatetruecolor(
- $this->options->width * $this->options->supersampling,
- $this->options->height * $this->options->supersampling
+ $this->supersample( $this->options->width ),
+ $this->supersample( $this->options->height )
);
$bgColor = imagecolorallocate( $this->image, 255, 255, 255 );
// Default to a white background
@@ -108,7 +108,7 @@ class ezcGraphGdDriver extends ezcGraphDriver
'image' => imagecreatefrompng( $file )
);
default:
- throw new ezcGraphGdDriverUnsupportedImageTypeException( $data[2] );
+ throw new ezcGraphGdDriverUnsupportedImageFormatException( $data[2] );
}
}
@@ -126,7 +126,7 @@ class ezcGraphGdDriver extends ezcGraphDriver
* @param mixed $filled
* @return void
*/
- public function drawPolygon( array $points, ezcGraphColor $color, $filled = true )
+ public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1 )
{
$image = $this->getImage();
@@ -229,6 +229,12 @@ class ezcGraphGdDriver extends ezcGraphDriver
}
}
+ // Check width of last line
+ $boundings = imagettfbbox( $size, 0, $this->options->font->font, implode( ' ', $lines[$line] ) );
+ if ( $boundings[2] > $width ) {
+ return false;
+ }
+
// It seems to fit - return line array
return $lines;
}
@@ -373,7 +379,7 @@ class ezcGraphGdDriver extends ezcGraphDriver
* @param ezcGraphColor $color
* @return void
*/
- public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color )
+ public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true )
{
$image = $this->getImage();
$drawColor = $this->allocate( $color );
@@ -386,17 +392,34 @@ class ezcGraphGdDriver extends ezcGraphDriver
$endAngle = $tmp;
}
- imagefilledarc(
- $image,
- $this->supersample( $center->x ),
- $this->supersample( $center->y ),
- $this->supersample( $width ),
- $this->supersample( $height ),
- $startAngle,
- $endAngle,
- $drawColor,
- IMG_ARC_PIE
- );
+ if ( $filled )
+ {
+ imagefilledarc(
+ $image,
+ $this->supersample( $center->x ),
+ $this->supersample( $center->y ),
+ $this->supersample( $width ),
+ $this->supersample( $height ),
+ $startAngle,
+ $endAngle,
+ $drawColor,
+ IMG_ARC_PIE
+ );
+ }
+ else
+ {
+ imagefilledarc(
+ $image,
+ $this->supersample( $center->x ),
+ $this->supersample( $center->y ),
+ $this->supersample( $width ),
+ $this->supersample( $height ),
+ $startAngle,
+ $endAngle,
+ $drawColor,
+ IMG_ARC_PIE | IMG_ARC_NOFILL | IMG_ARC_EDGED
+ );
+ }
}
/**
diff --git a/src/driver/svg.php b/src/driver/svg.php
index 446818c..90574a5 100644
--- a/src/driver/svg.php
+++ b/src/driver/svg.php
@@ -29,7 +29,7 @@ class ezcGraphSVGDriver extends ezcGraphDriver
* @param mixed $filled
* @return void
*/
- public function drawPolygon( array $points, ezcGraphColor $color, $filled = true )
+ public function drawPolygon( array $points, ezcGraphColor $color, $filled = true, $thickness = 1 )
{
}
@@ -42,7 +42,7 @@ class ezcGraphSVGDriver extends ezcGraphDriver
* @param ezcGraphColor $color
* @return void
*/
- public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color )
+ public function drawLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color, $thickness = 1 )
{
}
@@ -73,7 +73,7 @@ class ezcGraphSVGDriver extends ezcGraphDriver
* @param ezcGraphColor $color
* @return void
*/
- public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color )
+ public function drawCircleSector( ezcGraphCoordinate $center, $width, $height, $startAngle, $endAngle, ezcGraphColor $color, $filled = true )
{
}
OpenPOWER on IntegriCloud