summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-02 14:07:19 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-02 14:07:19 +0000
commit97902f4d7de3482cf110950544cc4a186dd84b11 (patch)
treef2e064cc92d0f5c3645aa312b6737f556f71dfe7
parent21a3467e539669f6b8935db0668891a7507b3675 (diff)
downloadzetacomponents-graph-97902f4d7de3482cf110950544cc4a186dd84b11.zip
zetacomponents-graph-97902f4d7de3482cf110950544cc4a186dd84b11.tar.gz
- Added basic 3d renderer
# Several unresolved rendering issues - Fixed filled line charts in 2d renderer
-rw-r--r--TODO6
-rw-r--r--src/charts/line.php9
-rw-r--r--src/graph_autoload.php5
-rw-r--r--src/interfaces/chart.php2
-rw-r--r--src/interfaces/renderer.php4
-rw-r--r--src/renderer/2d.php28
-rw-r--r--src/renderer/3d.php1314
-rw-r--r--src/structs/color.php20
-rw-r--r--tests/axis_centered_renderer_test.php28
-rw-r--r--tests/axis_exact_renderer_test.php28
-rw-r--r--tests/chart_test.php2
-rw-r--r--tests/complete_rendering_test.php172
-rw-r--r--tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChart.pngbin87289 -> 0 bytes
-rw-r--r--tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartAxis.pngbin82542 -> 0 bytes
-rw-r--r--tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartReverse.pngbin87344 -> 0 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawCircularArcObtuse.pngbin2007 -> 1889 bytes
-rw-r--r--tests/data/compare/ezcGraphGdDriverTest_testDrawTransparentPolygon.pngbin0 -> 675 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChart.pngbin0 -> 87482 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChartWithAxisIntersection.pngbin0 -> 86880 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChart.pngbin0 -> 87622 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChart.png (renamed from tests/data/compare/ezcGraphCompleteRenderingTest_testRenderPieChart.png)bin82033 -> 82033 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.pngbin0 -> 93842 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.pngbin0 -> 94727 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.pngbin0 -> 94149 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.pngbin0 -> 92486 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.pngbin0 -> 94372 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.pngbin0 -> 78413 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.pngbin0 -> 78213 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.pngbin0 -> 74788 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.pngbin0 -> 77585 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.pngbin0 -> 77633 bytes
-rw-r--r--tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.pngbin0 -> 76298 bytes
-rw-r--r--tests/driver_gd_test.php31
-rw-r--r--tests/line_test.php28
-rw-r--r--tests/pie_test.php2
-rw-r--r--tests/renderer_2d_test.php156
-rw-r--r--tests/renderer_3d_test.php377
-rw-r--r--tests/suite.php4
38 files changed, 1904 insertions, 312 deletions
diff --git a/TODO b/TODO
index 4cf33b9..b4ac7a0 100644
--- a/TODO
+++ b/TODO
@@ -1,13 +1,13 @@
Alpha:
- - Fix grid on axis
- Check for undocumented functions
- Fix scaling of background image
- - Make hilight a function
- Tresh hold for pie charts
- - Find reason for offset in big charts
Next steps:
- 3D-Renderer
+ - Inaccurate rendering for line charts
+ - z-Bffer problems for pie charts
+ - Symbol priority wrong
- Enhance font configuration with magic
- Return datapoinnt positions for imagemap and / or adding additional
information with div overlays
diff --git a/src/charts/line.php b/src/charts/line.php
index 733c1f7..b0ba8c0 100644
--- a/src/charts/line.php
+++ b/src/charts/line.php
@@ -81,8 +81,12 @@ class ezcGraphLineChart extends ezcGraphChart
$boundings->y0 += $yAxisSpace;
$boundings->y1 -= $yAxisSpace;
+ $yAxisNullPosition = $this->elements['yAxis']->getCoordinate( false );
+
+ $nr = count( $this->data );
foreach ( $this->data as $data )
{
+ --$nr;
// Determine fill color for dataset
if ( $this->options->fillLines !== false )
{
@@ -108,9 +112,12 @@ class ezcGraphLineChart extends ezcGraphChart
$data->color->default,
( $lastPoint === false ? $point : $lastPoint ),
$point,
+ $nr,
+ count( $this->data ),
$data->symbol[$key],
$data->color[$key],
- $fillColor
+ $fillColor,
+ $yAxisNullPosition
);
$lastPoint = $point;
diff --git a/src/graph_autoload.php b/src/graph_autoload.php
index f1ef3a8..217f27e 100644
--- a/src/graph_autoload.php
+++ b/src/graph_autoload.php
@@ -26,9 +26,10 @@ return array(
'ezcGraphUnknownColorDefinitionException' => 'Graph/exceptions/unknown_color_definition.php',
'ezcGraphRenderer' => 'Graph/interfaces/renderer.php',
- 'ezcGraphRenderer2D' => 'Graph/renderer/2d.php',
+ 'ezcGraphRenderer2d' => 'Graph/renderer/2d.php',
'ezcGraphRenderer2dOptions' => 'Graph/options/renderer_2d.php',
- 'ezcGraphRenderer3D' => 'Graph/renderer/3d.php',
+ 'ezcGraphRenderer3d' => 'Graph/renderer/3d.php',
+ 'ezcGraphRenderer3dOptions' => 'Graph/options/renderer_3d.php',
'ezcGraphInvalidRendererException' => 'Graph/exceptions/invalid_renderer.php',
'ezcGraphAxisLabelRenderer' => 'Graph/interfaces/axis_label_renderer.php',
diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php
index ac50029..2411fad 100644
--- a/src/interfaces/chart.php
+++ b/src/interfaces/chart.php
@@ -78,7 +78,7 @@ abstract class ezcGraphChart implements ArrayAccess
// Define standard renderer and driver
$this->driver = new ezcGraphSvgDriver();
- $this->renderer = new ezcGraphRenderer2D();
+ $this->renderer = new ezcGraphRenderer2d();
$this->renderer->setDriver( $this->driver );
}
diff --git a/src/interfaces/renderer.php b/src/interfaces/renderer.php
index 01f628c..5abb86f 100644
--- a/src/interfaces/renderer.php
+++ b/src/interfaces/renderer.php
@@ -55,6 +55,8 @@ abstract class ezcGraphRenderer
* @param ezcGraphColor $color Color of line
* @param ezcGraphCoordinate $start Starting point
* @param ezcGraphCoordinate $end Ending point
+ * @param int $dataNumber Number of dataset
+ * @param int $dataCount Count of datasets in chart
* @param int $symbol Symbol to draw for line
* @param ezcGraphColor $symbolColor Color of the symbol, defaults to linecolor
* @param ezcGraphColor $fillColor Color to fill line with
@@ -67,6 +69,8 @@ abstract class ezcGraphRenderer
ezcGraphColor $color,
ezcGraphCoordinate $start,
ezcGraphCoordinate $end,
+ $dataNumber = 1,
+ $dataCount = 1,
$symbol = ezcGraph::NO_SYMBOL,
ezcGraphColor $symbolColor = null,
ezcGraphColor $fillColor = null,
diff --git a/src/renderer/2d.php b/src/renderer/2d.php
index 9880025..8e54de0 100644
--- a/src/renderer/2d.php
+++ b/src/renderer/2d.php
@@ -243,6 +243,8 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
* @param ezcGraphColor $color Color of line
* @param ezcGraphCoordinate $start Starting point
* @param ezcGraphCoordinate $end Ending point
+ * @param int $dataNumber Number of dataset
+ * @param int $dataCount Count of datasets in chart
* @param int $symbol Symbol to draw for line
* @param ezcGraphColor $symbolColor Color of the symbol, defaults to linecolor
* @param ezcGraphColor $fillColor Color to fill line with
@@ -255,11 +257,13 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
ezcGraphColor $color,
ezcGraphCoordinate $start,
ezcGraphCoordinate $end,
+ $dataNumber = 1,
+ $dataCount = 1,
$symbol = ezcGraph::NO_SYMBOL,
ezcGraphColor $symbolColor = null,
ezcGraphColor $fillColor = null,
$axisPosition = 0.,
- $thickness = 1 )
+ $thickness = 1)
{
// Perhaps fill up line
if ( $fillColor !== null &&
@@ -277,19 +281,19 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
array(
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $start->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $end->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
),
),
$fillColor,
@@ -302,7 +306,7 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
$startDiff = abs( $axisPosition - $start->y );
$endDiff = abs( $axisPosition - $end->y );
- $cuttingPosition = $startDiff / ( $endDiff / $startDiff );
+ $cuttingPosition = $startDiff / ( $endDiff + $startDiff );
$cuttingPoint = new ezcGraphCoordinate(
$start->x + ( $end->x - $start->x ) * $cuttingPosition,
$axisPosition
@@ -312,15 +316,15 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
array(
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $start->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $cuttingPoint->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
),
),
$fillColor,
@@ -331,15 +335,15 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
array(
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $end->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
),
new ezcGraphCoordinate(
$boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $cuttingPoint->x,
- $boundings->y1 - ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
),
),
$fillColor,
diff --git a/src/renderer/3d.php b/src/renderer/3d.php
index c23b0ad..9d53af4 100644
--- a/src/renderer/3d.php
+++ b/src/renderer/3d.php
@@ -1,128 +1,1320 @@
<?php
/**
- * File containing the ezcGraphRenderer2D class
+ * File containing the three dimensional renderer
*
* @package Graph
* @version //autogentag//
- * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @copyright Copyright (C) 2005,
+ 2006 eZ systems as. All rights reserved.
* @license http://ez.no/licenses/new_bsd New BSD License
*/
/**
- * Implements the two dimensional renderer for the graph component
+ * Class to transform chart primitives into image primitives
*
* @package Graph
*/
-class ezcGraphRenderer2D extends ezcGraphRenderer {
+class ezcGraphRenderer3d extends ezcGraphRenderer
+{
+
+ protected $pieSegmentLabels = array(
+ 0 => array(),
+ 1 => array(),
+ );
+
+ protected $pieSegmentBoundings = false;
+
+ protected $frontLines = array();
+
+ protected $circleSectors = array();
+
+ protected $options;
+
+ protected $depth = false;
+
+ protected $xDepthFactor = false;
+
+ protected $yDepthFactor = false;
+
+ protected $dataBoundings = false;
+
+ public function __construct( array $options = array() )
+ {
+ $this->options = new ezcGraphRenderer3dOptions( $options );
+ }
+
+ public function __get( $propertyName )
+ {
+ switch ( $propertyName )
+ {
+ case 'options':
+ return $this->options;
+ default:
+ throw new ezcBasePropertyNotFoundException( $propertyName );
+ }
+ }
/**
- * Draw a pie segment
+ * Draw pie segment
+ *
+ * Draws a single pie segment
*
- * @param ezcGraphCoordinate $position
- * @param mixed $radius
- * @param float $startAngle
- * @param float $endAngle
- * @param float $moveOut
- * @access public
+ * @param ezcGraphBoundings $boundings Chart boundings
+ * @param ezcGraphColor $color Color of pie segment
+ * @param float $startAngle Start angle
+ * @param float $endAngle End angle
+ * @param string $label Label of pie segment
+ * @param float $moveOut Move out from middle for hilighting
* @return void
*/
- public function drawPieSegment( ezcGraphCoordinate $position, $radius, $startAngle = .0, $endAngle = 360., $moveOut = .0 )
+ public function drawPieSegment(
+ ezcGraphBoundings $boundings,
+ ezcGraphColor $color,
+ $startAngle = .0,
+ $endAngle = 360.,
+ $label = false,
+ $moveOut = false )
{
-
+ // Calculate position and size of pie
+ $center = new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2 - $this->options->pieChartHeight / 2
+ );
+
+ // Limit radius to fourth of width and half of height at maximum
+ $radius = min(
+ ( $boundings->x1 - $boundings->x0 ) / 4,
+ ( $boundings->y1 - $boundings->y0 ) / 2
+ ) * ( 1 - $this->options->moveOut );
+
+ // Move pie segment out of the center
+ if ( $moveOut )
+ {
+ $direction = $startAngle + ( $endAngle - $startAngle ) / 2;
+
+ $center = new ezcGraphCoordinate(
+ $center->x + $this->options->moveOut * $radius * cos( deg2rad( $direction ) ),
+ $center->y + $this->options->moveOut * $radius * sin( deg2rad( $direction ) )
+ );
+ }
+
+ // Add circle sector to queue
+ $this->circleSectors[] = array(
+ 'center' => $center,
+ 'width' => $radius * 2,
+ 'height' => $radius * 2 * $this->options->pieChartRotation - $this->options->pieChartHeight,
+ 'start' => $startAngle,
+ 'end' => $endAngle,
+ 'color' => $color,
+ );
+
+ if ( $label )
+ {
+ // Determine position of label
+ $middle = $startAngle + ( $endAngle - $startAngle ) / 2;
+ $pieSegmentCenter = new ezcGraphCoordinate(
+ cos( deg2rad( $middle ) ) * $radius * 2 / 3 + $center->x,
+ sin( deg2rad( $middle ) ) * $radius * $this->options->pieChartRotation * 2 / 3 + $center->y
+ );
+
+ // Split labels up into left an right size and index them on their
+ // y position
+ $this->pieSegmentLabels[(int) ($pieSegmentCenter->x > $center->x)][$pieSegmentCenter->y] = array(
+ clone $pieSegmentCenter,
+ $label
+ );
+ }
+
+ if ( !$this->pieSegmentBoundings )
+ {
+ $this->pieSegmentBoundings = $boundings;
+ }
+ }
+
+ protected function finishPieSegmentLabels()
+ {
+ if ( $this->pieSegmentBoundings === false )
+ {
+ return true;
+ }
+
+ $boundings = $this->pieSegmentBoundings;
+
+ // Calculate position and size of pie
+ $center = new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2
+ );
+
+ // Limit radius to fourth of width and half of height at maximum
+ $radius = min(
+ ( $boundings->x1 - $boundings->x0 ) / 4,
+ ( $boundings->y1 - $boundings->y0 ) / 2
+ );
+
+ // Calculate maximum height of labels
+ $labelHeight = (int) round( min(
+ ( count( $this->pieSegmentLabels[0] )
+ ? ( $boundings->y1 - $boundings->y0 ) / count( $this->pieSegmentLabels[0] )
+ : ( $boundings->y1 - $boundings->y0 )
+ ),
+ ( count( $this->pieSegmentLabels[1] )
+ ? ( $boundings->y1 - $boundings->y0 ) / count( $this->pieSegmentLabels[1] )
+ : ( $boundings->y1 - $boundings->y0 )
+ ),
+ ( $boundings->y1 - $boundings->y0 ) * $this->options->maxLabelHeight
+ ) );
+
+ $symbolSize = $this->options->symbolSize;
+
+ foreach ( $this->pieSegmentLabels as $side => $labelPart )
+ {
+ $minHeight = $boundings->y0;
+ $toShare = ( $boundings->y1 - $boundings->y0 ) - count( $labelPart ) * $labelHeight;
+
+ // Sort to draw topmost label first
+ ksort( $labelPart );
+ $sign = ( $side ? -1 : 1 );
+
+ foreach ( $labelPart as $height => $label )
+ {
+ // Determine position of label
+ $minHeight += max( 0, $height - $minHeight - $labelHeight ) / ( $boundings->y1 - $boundings->y0 ) * $toShare;
+ $labelPosition = new ezcGraphCoordinate(
+ $center->x -
+ $sign * (
+ cos ( asin ( ( $center->y - $minHeight - $labelHeight / 2 ) / $radius ) ) * $radius +
+ $symbolSize * (int) $this->options->showSymbol
+ ),
+ $minHeight + $labelHeight / 2
+ );
+
+ if ( $this->options->showSymbol )
+ {
+ // Draw label
+ $this->driver->drawLine(
+ $label[0],
+ $labelPosition,
+ $this->options->font->color,
+ 1
+ );
+
+ $this->driver->drawCircle(
+ $label[0],
+ $symbolSize,
+ $symbolSize,
+ $this->options->font->color,
+ true
+ );
+ $this->driver->drawCircle(
+ $labelPosition,
+ $symbolSize,
+ $symbolSize,
+ $this->options->font->color,
+ true
+ );
+ }
+
+ $this->driver->drawTextBox(
+ $label[1],
+ new ezcGraphCoordinate(
+ ( !$side ? $boundings->x0 : $labelPosition->x + $symbolSize ),
+ $minHeight
+ ),
+ ( !$side ? $labelPosition->x - $boundings->x0 - $symbolSize : $boundings->x1 - $labelPosition->x - $symbolSize ),
+ $labelHeight,
+ ( !$side ? ezcGraph::RIGHT : ezcGraph::LEFT ) | ezcGraph::MIDDLE
+ );
+
+ // Add used space to minHeight
+ $minHeight += $labelHeight;
+ }
+ }
+ }
+
+ protected function finishCirleSectors()
+ {
+ // Draw circular arcs
+ foreach ( $this->circleSectors as $circleSector )
+ {
+ $this->driver->drawCircularArc(
+ $circleSector['center'],
+ $circleSector['width'],
+ $circleSector['height'],
+ $this->options->pieChartHeight,
+ $circleSector['start'],
+ $circleSector['end'],
+ $circleSector['color']
+ );
+ }
+
+ // Draw borders
+ foreach ( $this->circleSectors as $circleSector )
+ {
+ $darkenedColor = $circleSector['color']->darken( $this->options->dataBorder );
+
+ $this->driver->drawPolygon(
+ array(
+ $circleSector['center'],
+ new ezcGraphCoordinate(
+ $circleSector['center']->x,
+ $circleSector['center']->y + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['start'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['start'] ) ) * $circleSector['height'] / 2 + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['start'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['start'] ) ) * $circleSector['height'] / 2
+ ),
+ ),
+ $circleSector['color'],
+ true
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ $circleSector['center'],
+ new ezcGraphCoordinate(
+ $circleSector['center']->x,
+ $circleSector['center']->y + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['start'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['start'] ) ) * $circleSector['height'] / 2 + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['start'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['start'] ) ) * $circleSector['height'] / 2
+ ),
+ ),
+ $darkenedColor,
+ false
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ $circleSector['center'],
+ new ezcGraphCoordinate(
+ $circleSector['center']->x,
+ $circleSector['center']->y + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['end'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['end'] ) ) * $circleSector['height'] / 2 + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['end'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['end'] ) ) * $circleSector['height'] / 2
+ ),
+ ),
+ $circleSector['color'],
+ true
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ $circleSector['center'],
+ new ezcGraphCoordinate(
+ $circleSector['center']->x,
+ $circleSector['center']->y + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['end'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['end'] ) ) * $circleSector['height'] / 2 + $this->options->pieChartHeight
+ ),
+ new ezcGraphCoordinate(
+ $circleSector['center']->x + cos( deg2rad( $circleSector['end'] ) ) * $circleSector['width'] / 2,
+ $circleSector['center']->y + sin( deg2rad( $circleSector['end'] ) ) * $circleSector['height'] / 2
+ ),
+ ),
+ $darkenedColor,
+ false
+ );
+ }
+
+ // Draw circle sector
+ foreach ( $this->circleSectors as $circleSector )
+ {
+ $this->driver->drawCircleSector(
+ $circleSector['center'],
+ $circleSector['width'],
+ $circleSector['height'],
+ $circleSector['start'],
+ $circleSector['end'],
+ $circleSector['color'],
+ true
+ );
+
+ $darkenedColor = $circleSector['color']->darken( $this->options->dataBorder );
+ $this->driver->drawCircleSector(
+ $circleSector['center'],
+ $circleSector['width'],
+ $circleSector['height'],
+ $circleSector['start'],
+ $circleSector['end'],
+ $darkenedColor,
+ false
+ );
+ }
+ }
+
+ protected function finishFrontLines()
+ {
+ foreach ( $this->frontLines as $line )
+ {
+ $this->driver->drawLine(
+ $line[0],
+ $line[1],
+ $line[2],
+ $line[3]
+ );
+ }
}
/**
- * Draw a line
+ * Draw data line
*
- * Semantically means a line as a chart element, not a single line like
- * the ones used in axes.
+ * Draws a line as a data element in a line chart
*
- * @param ezcGraphCoordinate $position
- * @param ezcGraphCoordinate $end
- * @param mixed $filled
- * @access public
+ * @param ezcGraphBoundings $boundings Chart boundings
+ * @param ezcGraphColor $color Color of line
+ * @param ezcGraphCoordinate $start Starting point
+ * @param ezcGraphCoordinate $end Ending point
+ * @param int $dataNumber Number of dataset
+ * @param int $dataCount Count of datasets in chart
+ * @param int $symbol Symbol to draw for line
+ * @param ezcGraphColor $symbolColor Color of the symbol, defaults to linecolor
+ * @param ezcGraphColor $fillColor Color to fill line with
+ * @param float $axisPosition Position of axis for drawing filled lines
+ * @param float $thickness Line thickness
* @return void
*/
- public function drawLine( ezcGraphCoordinate $position, ezcGraphCoordinate $end, $filled = true )
+ public function drawDataLine(
+ ezcGraphBoundings $boundings,
+ ezcGraphColor $color,
+ ezcGraphCoordinate $start,
+ ezcGraphCoordinate $end,
+ $dataNumber = 1,
+ $dataCount = 1,
+ $symbol = ezcGraph::NO_SYMBOL,
+ ezcGraphColor $symbolColor = null,
+ ezcGraphColor $fillColor = null,
+ $axisPosition = 0.,
+ $thickness = 1 )
{
-
+ // Calculate line width based on options
+ if ( $this->options->seperateLines )
+ {
+ $depth = $this->depth / $dataCount;
+ $pointModifier = $depth * $dataNumber;
+ }
+ else
+ {
+ $depth = $this->depth;
+ $pointModifier = 0.;
+ }
+
+ // Apply depth factor to coords
+ $start = clone $start;
+ $start->x *= $this->xDepthFactor;
+ $start->y *= $this->yDepthFactor;
+ $end = clone $end;
+ $end->x *= $this->xDepthFactor;
+ $end->y *= $this->yDepthFactor;
+
+ // Perhaps fill up line
+ if ( $fillColor !== null &&
+ $start->x != $end->x )
+ {
+ $startValue = $axisPosition - $start->y;
+ $endValue = $axisPosition - $end->y;
+
+ if ( ( $startValue == 0 ) ||
+ ( $endValue == 0 ) ||
+ ( $startValue / abs( $startValue ) == $endValue / abs( $endValue ) ) )
+ {
+ // Values have the same sign or are on the axis
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ ),
+ $fillColor,
+ true
+ );
+ }
+ else
+ {
+ // values are on differente sides of the axis - split the filled polygon
+ $startDiff = abs( $axisPosition - $start->y );
+ $endDiff = abs( $axisPosition - $end->y );
+
+ $cuttingPosition = $startDiff / ( $endDiff + $startDiff );
+ $cuttingPoint = new ezcGraphCoordinate(
+ $start->x + ( $end->x - $start->x ) * $cuttingPosition,
+ $axisPosition
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $cuttingPoint->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
+ ),
+ ),
+ $fillColor,
+ true
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $cuttingPoint->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $cuttingPoint->y
+ ),
+ ),
+ $fillColor,
+ true
+ );
+ }
+
+ // Draw closing foo
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $depth + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier - $depth + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $depth + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier - $depth + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $axisPosition
+ ),
+ ),
+ $fillColor,
+ true
+ );
+ }
+
+ $linePolygonPoints = array(
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $depth + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $start->x,
+ -$pointModifier - $depth + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $start->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $depth + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier - $depth + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ new ezcGraphCoordinate(
+ $pointModifier + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x,
+ -$pointModifier + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y
+ ),
+ );
+
+ // Draw line
+ $this->driver->drawPolygon(
+ $linePolygonPoints,
+ $color,
+ true,
+ $thickness
+ );
+
+ // Draw polygon border
+ if ( $this->options->dataBorder > 0 )
+ {
+ $this->driver->drawPolygon(
+ $linePolygonPoints,
+ $color->darken( $this->options->dataBorder ),
+ false,
+ $thickness
+ );
+ }
+
+ // Draw line symbol
+ if ( $symbol !== ezcGraph::NO_SYMBOL )
+ {
+ if ( $symbolColor === null )
+ {
+ $symbolColor = $color;
+ }
+
+ $this->drawSymbol(
+ new ezcGraphBoundings(
+ $pointModifier + $depth / 2 + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x - $this->options->symbolSize / 2,
+ -$pointModifier - $depth / 2 + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y - $this->options->symbolSize / 2,
+ $pointModifier + $depth / 2 + $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) * $end->x + $this->options->symbolSize / 2,
+ -$pointModifier - $depth / 2 + $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) * $end->y + $this->options->symbolSize / 2
+ ),
+ $symbolColor,
+ $symbol
+ );
+ }
}
/**
- * Draws a text box
+ * Draw legend
+ *
+ * Will draw a legend in the bounding box
*
- * @param ezcGraphCoordinate $position
- * @param mixed $text
- * @param mixed $width
- * @param mixed $height
- * @access public
+ * @param ezcGraphBoundings $boundings Bounding of legend
+ * @param ezcGraphChartElementLegend $labels Legend to draw
+ * @param int $type Type of legend: Protrait or landscape
* @return void
*/
- public function drawTextBox( ezcGraphCoordinate $position, $text, $width = null, $height = null )
+ public function drawLegend(
+ ezcGraphBoundings $boundings,
+ ezcGraphChartElementLegend $legend,
+ $type = ezcGraph::VERTICAL )
{
+ $labels = $legend->labels;
+ // Calculate boundings of each label
+ if ( $type & ezcGraph::VERTICAL )
+ {
+ $labelWidth = $boundings->x1 - $boundings->x0;
+ $labelHeight = min(
+ ( $boundings->y1 - $boundings->y0 ) / count( $labels ) - $legend->spacing,
+ $legend->symbolSize + 2 * $legend->padding
+ );
+ }
+ else
+ {
+ $labelWidth = ( $boundings->x1 - $boundings->x0 ) / count( $labels ) - $legend->spacing;
+ $labelHeight = min(
+ $boundings->x1 - $boundings->x0,
+ $legend->symbolSize + 2 * $legend->padding
+ );
+ }
+
+ $symbolSize = $labelHeight - 2 * $legend->padding;
+
+ // Draw all labels
+ $labelPosition = new ezcGraphCoordinate( $boundings->x0, $boundings->y0 );
+ foreach ( $labels as $label )
+ {
+ $this->drawSymbol(
+ new ezcGraphBoundings(
+ $labelPosition->x + $legend->padding,
+ $labelPosition->y + $legend->padding,
+ $labelPosition->x + $legend->padding + $symbolSize,
+ $labelPosition->y + $legend->padding + $symbolSize
+ ),
+ $label['color'],
+ $label['symbol']
+ );
+
+ $this->driver->drawTextBox(
+ $label['label'],
+ new ezcGraphCoordinate(
+ $labelPosition->x + 2 * $legend->padding + $symbolSize,
+ $labelPosition->y + $legend->padding
+ ),
+ $labelWidth - $symbolSize - 3 * $legend->padding,
+ $labelHeight - 2 * $legend->padding,
+ ezcGraph::LEFT | ezcGraph::MIDDLE
+ );
+
+ $labelPosition->x += ( $type === ezcGraph::VERTICAL ? 0 : $labelWidth + $legend->spacing );
+ $labelPosition->y += ( $type === ezcGraph::VERTICAL ? $labelHeight + $legend->spacing : 0 );
+ }
}
/**
- * Draws a rectangle
+ * Draw box
*
- * @param ezcGraphColor $color
- * @param ezcGraphCoordinate $position
- * @param mixed $width
- * @param mixed $height
- * @param float $borderWidth
- * @access public
- * @return void
+ * Box are wrapping each major chart element and draw border, background
+ * and title to each chart element.
+ *
+ * Optionally a padding and margin for each box can be defined.
+ *
+ * @param ezcGraphBoundings $boundings Boundings of the box
+ * @param ezcGraphColor $background Background color
+ * @param ezcGraphColor $borderColor Border color
+ * @param int $borderWidth Border width
+ * @param int $margin Margin
+ * @param int $padding Padding
+ * @param string $title Title of the box
+ * @param int $titleSize Size of title in the box
+ * @return ezcGraphBoundings Remaining inner boundings
*/
- public function drawRect( ezcGraphColor $color, ezcGraphCoordinate $position = null, $width = null, $height = null, $borderWidth = 1 )
+ public function drawBox(
+ ezcGraphBoundings $boundings,
+ ezcGraphColor $background = null,
+ ezcGraphColor $borderColor = null,
+ $borderWidth = 0,
+ $margin = 0,
+ $padding = 0,
+ $title = false,
+ $titleSize = 16 )
{
+ // Apply margin
+ $boundings->x0 += $margin;
+ $boundings->y0 += $margin;
+ $boundings->x1 -= $margin;
+ $boundings->y1 -= $margin;
+
+ if ( ( $borderColor instanceof ezcGraphColor ) &&
+ ( $borderWidth > 0 ) )
+ {
+ // Draw border
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y1 ),
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y1 ),
+ ),
+ $borderColor,
+ false
+ );
+
+ // Reduce local boundings by borderWidth
+ $boundings->x0 += $borderWidth;
+ $boundings->y0 += $borderWidth;
+ $boundings->x1 -= $borderWidth;
+ $boundings->y1 -= $borderWidth;
+ }
+ if ( $background instanceof ezcGraphColor )
+ {
+ // Draw box background
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y1 ),
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y1 ),
+ ),
+ $background,
+ true
+ );
+ }
+
+ // Apply padding
+ $boundings->x0 += $padding;
+ $boundings->y0 += $padding;
+ $boundings->x1 -= $padding;
+ $boundings->y1 -= $padding;
+
+ // Add box title
+ if ( $title !== false )
+ {
+ switch ( $this->options->titlePosition )
+ {
+ case ezcGraph::TOP:
+ $this->driver->drawTextBox(
+ $title,
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ),
+ $boundings->x1 - $boundings->x0,
+ $titleSize,
+ $this->options->titleAlignement
+ );
+
+ $boundings->y0 += $titleSize + $padding;
+ $boundings->y1 -= $titleSize + $padding;
+ break;
+ case ezcGraph::BOTTOM:
+ $this->driver->drawTextBox(
+ $title,
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y1 - $titleSize ),
+ $boundings->x1 - $boundings->x0,
+ $titleSize,
+ $this->options->titleAlignement
+ );
+
+ $boundings->y1 -= $titleSize + $padding;
+ break;
+ }
+ }
+
+ return $boundings;
}
/**
- * Draw Background
+ * Draw text
+ *
+ * Draws the provided text in the boundings
+ *
+ * @param ezcGraphBoundings $boundings Boundings of text
+ * @param string $text Text
+ * @param int $align Alignement of text
+ * @return void
+ */
+ public function drawText(
+ ezcGraphBoundings $boundings,
+ $text,
+ $align = ezcGraph::LEFT )
+ {
+ $this->driver->drawTextBox(
+ $text,
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ),
+ $boundings->x1 - $boundings->x0,
+ $boundings->y1 - $boundings->y0,
+ $align
+ );
+ }
+
+ /**
+ * Draw grid line
*
- * Draws a filled rectangle, used for backgrounds
+ * Draw line for the grid in the chart background
*
- * @param ezcGraphColor $color
- * @param ezcGraphCoordinate $position
- * @param mixed $width
- * @param mixed $height
- * @access public
+ *
+ * @param ezcGraphCoordinate $start Start point
+ * @param ezcGraphCoordinate $end End point
+ * @param ezcGraphColor $color Color of the grid line
* @return void
*/
- public function drawBackground( ezcGraphColor $color, ezcGraphCoordinate $position = null, $width = null, $height = null )
+ public function drawGridLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color )
{
+ $xFactor = round( ( $end->x - $start->x ) / ( $this->dataBoundings->x1 - $this->dataBoundings->x0 ) );
+ $yFactor = round( ( $end->y - $start->y ) / ( $this->dataBoundings->y1 - $this->dataBoundings->y0 ) );
+
+ $gridPolygonCoordinates = array(
+ new ezcGraphCoordinate(
+ $start->x,
+ $start->y + ( $this->depth * $yFactor )
+ ),
+ new ezcGraphCoordinate(
+ $end->x - ( $this->depth * $xFactor ),
+ $end->y
+ ),
+ new ezcGraphCoordinate(
+ $end->x + ( $this->depth * $yFactor ),
+ $end->y - ( $this->depth * $yFactor ) - ( $this->depth * $xFactor )
+ ),
+ new ezcGraphCoordinate(
+ $start->x + ( $this->depth * $yFactor ) + ( $this->depth * $xFactor ),
+ $start->y - ( $this->depth * $xFactor )
+ ),
+ );
+
+ // Draw grid polygon
+ if ( ( $this->options->fillGrid > 0 ) &&
+ ( $this->options->fillGrid < 1 ) )
+ {
+ $this->driver->drawPolygon(
+ $gridPolygonCoordinates,
+ $color->transparent( $this->options->fillGrid ),
+ true
+ );
+ }
+ else
+ {
+ $this->driver->drawPolygon(
+ $gridPolygonCoordinates,
+ $color,
+ !(bool) $this->options->fillGrid
+ );
+ }
+ // Draw grid lines - scedule some for later to be drawn in front of
+ // the data
+ $this->frontLines[] = array(
+ $gridPolygonCoordinates[0],
+ $gridPolygonCoordinates[1],
+ $color,
+ 1
+ );
+
+ $this->frontLines[] = array(
+ $gridPolygonCoordinates[1],
+ $gridPolygonCoordinates[2],
+ $color,
+ 1
+ );
+
+ $this->driver->drawLine(
+ $gridPolygonCoordinates[2],
+ $gridPolygonCoordinates[3],
+ $color,
+ 1
+ );
+
+ $this->frontLines[] = array(
+ $gridPolygonCoordinates[3],
+ $gridPolygonCoordinates[0],
+ $color,
+ 1
+ );
+ }
+
+ /**
+ * Draw step line
+ *
+ * Draw a step (marker for label position) on a axis.
+ *
+ * @param ezcGraphCoordinate $start Start point
+ * @param ezcGraphCoordinate $end End point
+ * @param ezcGraphColor $color Color of the grid line
+ * @return void
+ */
+ public function drawStepLine( ezcGraphCoordinate $start, ezcGraphCoordinate $end, ezcGraphColor $color )
+ {
+ $stepPolygonCoordinates = array(
+ $start,
+ new ezcGraphCoordinate(
+ $start->x + $this->depth,
+ $start->y - $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $end->x + $this->depth,
+ $end->y - $this->depth
+ ),
+ $end,
+ );
+
+ // Draw step polygon
+ if ( ( $this->options->fillAxis > 0 ) &&
+ ( $this->options->fillAxis < 1 ) )
+ {
+ $this->driver->drawPolygon(
+ $stepPolygonCoordinates,
+ $color->transparent( $this->options->fillAxis ),
+ true
+ );
+
+ $this->driver->drawPolygon(
+ $stepPolygonCoordinates,
+ $color,
+ false
+ );
+ }
+ else
+ {
+ $this->driver->drawPolygon(
+ $stepPolygonCoordinates,
+ $color,
+ !(bool) $this->options->fillAxis
+ );
+ }
}
/**
- * Draws BackgrouniImage
+ * Draw axis
+ *
+ * Draws an axis form the provided start point to the end point. A specific
+ * angle of the axis is not required.
+ *
+ * For the labeleing of the axis a sorted array with major steps and an
+ * array with minor steps is expected, which are build like this:
+ * array(
+ * array(
+ * 'position' => (float),
+ * 'label' => (string),
+ * )
+ * )
+ * where the label is optional.
+ *
+ * The label renderer class defines how the labels are rendered. For more
+ * documentation on this topic have a look at the basic label renderer
+ * class.
+ *
+ * Additionally it can be specified if a major and minor grid are rendered
+ * by defining a color for them. Teh axis label is used to add a caption
+ * for the axis.
+ *
+ * @param ezcGraphBoundings $boundings Boundings of axis
+ * @param ezcGraphCoordinate $start Start point of axis
+ * @param ezcGraphCoordinate $end Endpoint of axis
+ * @param ezcGraphChartElementAxis $axis Axis to render
+ * @param ezcGraphLabelRenderer $labelClass Used label renderer
+ * @return void
+ */
+ public function drawAxis(
+ ezcGraphBoundings $boundings,
+ ezcGraphCoordinate $start,
+ ezcGraphCoordinate $end,
+ ezcGraphChartElementAxis $axis,
+ ezcGraphAxisLabelRenderer $labelClass = null )
+ {
+ // Calculate used space for three dimensional effects
+ if ( $this->depth === false )
+ {
+ $this->depth = min(
+ ( $boundings->x1 - $boundings->x0 ) * $this->options->depth,
+ ( $boundings->y1 - $boundings->y0 ) * $this->options->depth
+ );
+
+ $this->xDepthFactor = 1 - $this->depth / ( $boundings->x1 - $boundings->x0 );
+ $this->yDepthFactor = 1 - $this->depth / ( $boundings->y1 - $boundings->y0 );
+
+ $this->dataBoundings = $boundings;
+ }
+
+ // Determine normalized direction
+ $direction = new ezcGraphCoordinate(
+ $start->x - $end->x,
+ $start->y - $end->y
+ );
+ $length = sqrt( pow( $direction->x, 2) + pow( $direction->y, 2 ) );
+ $direction->x /= $length;
+ $direction->y /= $length;
+
+ $start->x *= $this->xDepthFactor;
+ $start->y *= $this->yDepthFactor;
+ $end->x *= $this->xDepthFactor;
+ $end->y *= $this->yDepthFactor;
+
+ $axisPolygonCoordinates = array(
+ new ezcGraphCoordinate(
+ $boundings->x0 + $start->x,
+ $boundings->y0 + $start->y + $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x,
+ $boundings->y0 + $end->y + $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x + $this->depth,
+ $boundings->y0 + $end->y
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $start->x + $this->depth,
+ $boundings->y0 + $start->y
+ ),
+ );
+
+ // Draw axis
+ if ( ( $this->options->fillAxis > 0 ) &&
+ ( $this->options->fillAxis < 1 ) )
+ {
+ $this->driver->drawPolygon(
+ $axisPolygonCoordinates,
+ $axis->border->transparent( $this->options->fillAxis ),
+ true
+ );
+ }
+ else
+ {
+ $this->driver->drawPolygon(
+ $axisPolygonCoordinates,
+ $axis->border,
+ ! (bool) $this->options->fillAxis
+ );
+ }
+
+ // Draw axis lines - scedule some for later to be drawn in front of
+ // the data
+ $this->frontLines[] = array(
+ $axisPolygonCoordinates[0],
+ $axisPolygonCoordinates[1],
+ $axis->border,
+ 1
+ );
+
+ $this->frontLines[] = array(
+ $axisPolygonCoordinates[1],
+ $axisPolygonCoordinates[2],
+ $axis->border,
+ 1
+ );
+
+ $this->driver->drawLine(
+ $axisPolygonCoordinates[2],
+ $axisPolygonCoordinates[3],
+ $axis->border,
+ 1
+ );
+
+ $this->frontLines[] = array(
+ $axisPolygonCoordinates[3],
+ $axisPolygonCoordinates[0],
+ $axis->border,
+ 1
+ );
+
+ // Draw small arrowhead
+ $size = min(
+ $axis->maxArrowHeadSize,
+ abs( ceil( ( ( $end->x - $start->x ) + ( $end->y - $start->y ) ) * $axis->axisSpace / 4 ) )
+ );
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x,
+ $boundings->y0 + $end->y + $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x
+ + $direction->y * $size / 2
+ + $direction->x * $size,
+ $boundings->y0 + $end->y
+ + $direction->x * $size / 2
+ + $direction->y * $size
+ + $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x
+ - $direction->y * $size / 2
+ + $direction->x * $size,
+ $boundings->y0 + $end->y
+ - $direction->x * $size / 2
+ + $direction->y * $size
+ + $this->depth
+ ),
+ ),
+ $axis->border,
+ true
+ );
+
+ $xAxisSpace = ( $end->x - $start->x ) * $axis->axisSpace;
+ $yAxisSpace = ( $end->y - $start->y ) * $axis->axisSpace;
+
+ // Apply axisSpace to start and end
+ $start->x += $xAxisSpace;
+ $start->y += $yAxisSpace;
+ $end->x -= $xAxisSpace;
+ $end->y -= $yAxisSpace;
+
+ if ( $labelClass !== null )
+ {
+ $labelClass->renderLabels(
+ $this,
+ $boundings,
+ new ezcGraphCoordinate(
+ $boundings->x0 + $start->x,
+ $boundings->y0 + $start->y + $this->depth
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + $end->x,
+ $boundings->y0 + $end->y + $this->depth
+ ),
+ $axis
+ );
+ }
+ }
+
+ /**
+ * Draw background image
+ *
+ * Draws a background image at the defined position. If repeat is set the
+ * background image will be repeated like any texture.
*
- * @param mixed $file
- * @param ezcGraphCoordinate $position
- * @param mixed $width
- * @param mixed $height
- * @access public
+ * @param ezcGraphBoundings $boundings Boundings for the background image
+ * @param string $file Filename of background image
+ * @param int $position Position of background image
+ * @param int $repeat Type of repetition
* @return void
*/
- public function drawBackgroundImage( $file, ezcGraphCoordinate $position = null, $width = null, $height = null )
+ public function drawBackgroundImage(
+ ezcGraphBoundings $boundings,
+ $file,
+ $position = 48, // ezcGraph::CENTER | ezcGraph::MIDDLE
+ $repeat = ezcGraph::NO_REPEAT )
{
+ $imageData = getimagesize( $file );
+ $imageWidth = $imageData[0];
+ $imageHeight = $imageData[1];
+
+ $imagePosition = new ezcGraphCoordinate( 0, 0 );
+
+ // Determine x position
+ switch ( true ) {
+ case ( $repeat & ezcGraph::HORIZONTAL ):
+ // If is repeated on this axis fall back to position zero
+ case ( $position & ezcGraph::LEFT ):
+ $imagePosition->x = $boundings->x0;
+ break;
+ case ( $position & ezcGraph::RIGHT ):
+ $imagePosition->x = max(
+ $boundings->x1 - $imageWidth,
+ $boundings->x0
+ );
+ break;
+ default:
+ $imagePosition->x = max(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 - $imageWidth ) / 2,
+ $boundings->x0
+ );
+ break;
+ }
+
+ // Determine y position
+ switch ( true ) {
+ case ( $repeat & ezcGraph::VERTICAL ):
+ // If is repeated on this axis fall back to position zero
+ case ( $position & ezcGraph::TOP ):
+ $imagePosition->y = $boundings->y0;
+ break;
+ case ( $position & ezcGraph::BOTTOM ):
+ $imagePosition->y = max(
+ $boundings->y1 - $imageHeight,
+ $boundings->y0
+ );
+ break;
+ default:
+ $imagePosition->y = max(
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 - $imageHeight ) / 2,
+ $boundings->y0
+ );
+ break;
+ }
+
+ $imageWidth = min( $imageWidth, $boundings->x1 - $boundings->x0 );
+ $imageHeight = min( $imageHeight, $boundings->y1 - $boundings->y0 );
+
+ // Texturize backround based on position and repetition
+ $position = new ezcGraphCoordinate(
+ $imagePosition->x,
+ $imagePosition->y
+ );
+ do
+ {
+ $position->y = $imagePosition->y;
+
+ do
+ {
+ $this->driver->drawImage(
+ $file,
+ $position,
+ $imageWidth,
+ $imageHeight
+ );
+
+ $position->y += $imageHeight;
+ }
+ while ( ( $position->y < $boundings->y1 ) &&
+ ( $repeat & ezcGraph::VERTICAL ) );
+
+ $position->x += $imageWidth;
+ }
+ while ( ( $position->x < $boundings->x1 ) &&
+ ( $repeat & ezcGraph::HORIZONTAL ) );
}
/**
- * Draws a lines symbol
+ * Draw Symbol
+ *
+ * Draws a single symbol defined by the symbol constants in ezcGraph. for
+ * NO_SYMBOL a rect will be drawn.
*
- * @param ezcGraphCoordinate $position
- * @param float $width
- * @param float $height
- * @param int $symbol
- * @access public
+ * @param ezcGraphBoundings $boundings Boundings of symbol
+ * @param ezcGraphColor $color Color of symbol
+ * @param int $symbol Type of symbol
* @return void
*/
- public function drawSymbol( ezcGraphCoordinate $position, $width, $height, $symbol = ezcGraph::NO_SYMBOL)
+ public function drawSymbol(
+ ezcGraphBoundings $boundings,
+ ezcGraphColor $color,
+ $symbol = ezcGraph::NO_SYMBOL )
{
-
+ switch ( $symbol )
+ {
+ case ezcGraph::NO_SYMBOL:
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y0 ),
+ new ezcGraphCoordinate( $boundings->x1, $boundings->y1 ),
+ new ezcGraphCoordinate( $boundings->x0, $boundings->y1 ),
+ ),
+ $color,
+ true
+ );
+ break;
+ case ezcGraph::DIAMOND:
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y0
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x1,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y1
+ ),
+ new ezcGraphCoordinate(
+ $boundings->x0,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2
+ ),
+ ),
+ $color,
+ true
+ );
+ break;
+ case ezcGraph::BULLET:
+ $this->driver->drawCircle(
+ new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2
+ ),
+ $boundings->x1 - $boundings->x0,
+ $boundings->y1 - $boundings->y0,
+ $color,
+ true
+ );
+ break;
+ case ezcGraph::CIRCLE:
+ $this->driver->drawCircle(
+ new ezcGraphCoordinate(
+ $boundings->x0 + ( $boundings->x1 - $boundings->x0 ) / 2,
+ $boundings->y0 + ( $boundings->y1 - $boundings->y0 ) / 2
+ ),
+ $boundings->x1 - $boundings->x0,
+ $boundings->y1 - $boundings->y0,
+ $color,
+ false
+ );
+ break;
+ }
+ }
+
+ protected function finish()
+ {
+ $this->finishCirleSectors();
+ $this->finishPieSegmentLabels();
+ $this->finishFrontLines();
+
+ return true;
}
}
diff --git a/src/structs/color.php b/src/structs/color.php
index a65dc31..99d9fde 100644
--- a/src/structs/color.php
+++ b/src/structs/color.php
@@ -203,10 +203,26 @@ class ezcGraphColor
}
/**
- * Darkens the color
+ * Returns a copy of the current color made more transparent by the given
+ * factor
+ *
+ * @param mixed $value Percent to make color mor transparent
+ * @return ezcGraphColor New color
+ */
+ public function transparent( $value )
+ {
+ $color = clone $this;
+
+ $color->alpha = 255 - (int) round( ( 255 - $this->alpha ) * ( 1 - $value ) );
+
+ return $color;
+ }
+
+ /**
+ * Returns a copy of the current color darkened by the given factor
*
* @param float $value Percent to darken the color
- * @return void
+ * @return ezcGraphColor New color
*/
public function darken( $value )
{
diff --git a/tests/axis_centered_renderer_test.php b/tests/axis_centered_renderer_test.php
index 94b2204..010dc4c 100644
--- a/tests/axis_centered_renderer_test.php
+++ b/tests/axis_centered_renderer_test.php
@@ -53,7 +53,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -88,7 +88,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerGrid = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -122,7 +122,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -157,7 +157,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerStep = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -193,7 +193,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerStep = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -229,7 +229,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer->innerStep = false;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -250,7 +250,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -285,7 +285,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->showZeroValue = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -328,7 +328,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::RIGHT;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -363,7 +363,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::TOP;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -398,7 +398,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -433,7 +433,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -468,7 +468,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::TOP;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -503,7 +503,7 @@ class ezcGraphAxisCenteredRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
diff --git a/tests/axis_exact_renderer_test.php b/tests/axis_exact_renderer_test.php
index 0084311..26de5aa 100644
--- a/tests/axis_exact_renderer_test.php
+++ b/tests/axis_exact_renderer_test.php
@@ -133,7 +133,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -168,7 +168,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerGrid = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -202,7 +202,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -237,7 +237,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerStep = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -273,7 +273,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->outerStep = true;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -309,7 +309,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer->innerStep = false;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawStepLine',
) );
@@ -330,7 +330,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -373,7 +373,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->xAxis->axisLabelRenderer->showLastValue = false;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -416,7 +416,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->xAxis->position = ezcGraph::RIGHT;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -451,7 +451,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::TOP;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -486,7 +486,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawGridLine',
) );
@@ -521,7 +521,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -564,7 +564,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::TOP;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
@@ -607,7 +607,7 @@ class ezcGraphAxisExactRendererTest extends ezcTestCase
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart['sampleData'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawText',
) );
diff --git a/tests/chart_test.php b/tests/chart_test.php
index 51a7795..2173b72 100644
--- a/tests/chart_test.php
+++ b/tests/chart_test.php
@@ -156,7 +156,7 @@ class ezcGraphChartTest extends ezcTestCase
public function testSetRenderer()
{
$pieChart = ezcGraph::create( 'Pie' );
- $renderer = $pieChart->renderer = new ezcGraphRenderer2D();
+ $renderer = $pieChart->renderer = new ezcGraphRenderer2d();
$this->assertSame(
$renderer,
diff --git a/tests/complete_rendering_test.php b/tests/complete_rendering_test.php
deleted file mode 100644
index 23cd22e..0000000
--- a/tests/complete_rendering_test.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-/**
- * ezcGraphCompleteRenderingTest
- *
- * @package Graph
- * @version //autogen//
- * @subpackage Tests
- * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
- * @license http://ez.no/licenses/new_bsd New BSD License
- */
-
-/**
- * Tests for ezcGraph class.
- *
- * @package ImageAnalysis
- * @subpackage Tests
- */
-class ezcGraphCompleteRenderingTest extends ezcImageTestCase
-{
-
- protected $testFiles = array(
- 'png' => 'png.png',
- );
-
- protected $basePath;
-
- protected $tempDir;
-
- public static function suite()
- {
- return new ezcTestSuite( "ezcGraphCompleteRenderingTest" );
- }
-
- /**
- * setUp
- *
- * @access public
- */
- public function setUp()
- {
- static $i = 0;
- $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
- $this->basePath = dirname( __FILE__ ) . '/data/';
- }
-
- /**
- * tearDown
- *
- * @access public
- */
- public function tearDown()
- {
- $this->removeTempDir();
- }
-
- public function testRenderLineChart()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'line' );
- $chart->palette = 'Black';
-
- $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 500, 200, $filename );
-
- $this->assertImageSimilar(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
- 'Image does not look as expected.',
- 10
- );
- }
-
- public function testRenderLineChartReverse()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'line' );
- $chart->palette = 'Black';
-
- $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
-
- $chart->xAxis->position = ezcGraph::RIGHT;
- $chart->yAxis->position = ezcGraph::TOP;
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 500, 200, $filename );
-
- $this->assertImageSimilar(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
- 'Image does not look as expected.',
- 10
- );
- }
-
- public function testRenderLineChartAxis()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $renderer = $this->getMock( 'ezcGraphRenderer2D', array(
- 'drawAxis',
- ) );
-
- $chart = ezcGraph::create( 'line' );
- $chart->palette = 'Black';
-
- $renderer
- ->expects( $this->at( 0 ) )
- ->method( 'drawAxis' )
- ->with(
- $this->equalTo( new ezcGraphBoundings( 100, 0, 500, 200 ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 0, 180 ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 400, 180 ), 1. ),
- $this->equalTo( $chart->xAxis ),
- $this->equalTo( $chart->xAxis->axisLabelRenderer )
- );
- $renderer
- ->expects( $this->at( 1 ) )
- ->method( 'drawAxis' )
- ->with(
- $this->equalTo( new ezcGraphBoundings( 100, 0, 500, 200 ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 40, 200 ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 40, 0 ), 1. ),
- $this->equalTo( $chart->yAxis ),
- $this->equalTo( $chart->yAxis->axisLabelRenderer )
- );
-
- $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
-
- $chart->renderer = $renderer;
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 500, 200, $filename );
- }
-
- public function testRenderPieChart()
- {
- $filename = $this->tempDir . __FUNCTION__ . '.png';
-
- $chart = ezcGraph::create( 'Pie' );
- $chart['sample'] = array(
- 'Mozilla' => 4375,
- 'IE' => 345,
- 'Opera' => 1204,
- 'wget' => 231,
- 'Safari' => 987,
- );
-
- $chart['sample']->highlight['Safari'] = true;
-
- $chart->driver = new ezcGraphGdDriver();
- $chart->options->font = $this->basePath . 'font.ttf';
- $chart->render( 500, 200, $filename );
-
- $this->assertImageSimilar(
- $filename,
- $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
- 'Image does not look as expected.',
- 10
- );
- }
-}
-?>
diff --git a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChart.png b/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChart.png
deleted file mode 100644
index 4fffb5d..0000000
--- a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChart.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartAxis.png b/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartAxis.png
deleted file mode 100644
index 40b8102..0000000
--- a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartAxis.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartReverse.png b/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartReverse.png
deleted file mode 100644
index 5729486..0000000
--- a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderLineChartReverse.png
+++ /dev/null
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawCircularArcObtuse.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawCircularArcObtuse.png
index a8e2147..f29aca4 100644
--- a/tests/data/compare/ezcGraphGdDriverTest_testDrawCircularArcObtuse.png
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawCircularArcObtuse.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphGdDriverTest_testDrawTransparentPolygon.png b/tests/data/compare/ezcGraphGdDriverTest_testDrawTransparentPolygon.png
new file mode 100644
index 0000000..5555bb8
--- /dev/null
+++ b/tests/data/compare/ezcGraphGdDriverTest_testDrawTransparentPolygon.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChart.png b/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChart.png
new file mode 100644
index 0000000..2134b72
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChart.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChartWithAxisIntersection.png b/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChartWithAxisIntersection.png
new file mode 100644
index 0000000..8f159f6
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderFilledLineChartWithAxisIntersection.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChart.png b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChart.png
new file mode 100644
index 0000000..d0e9ca0
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChart.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderPieChart.png b/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChart.png
index 109163d..109163d 100644
--- a/tests/data/compare/ezcGraphCompleteRenderingTest_testRenderPieChart.png
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderPieChart.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.png
new file mode 100644
index 0000000..9540f3e
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChart.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.png
new file mode 100644
index 0000000..698a63f
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledAxis.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.png
new file mode 100644
index 0000000..83273b2
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartNonFilledGrid.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.png
new file mode 100644
index 0000000..e657888
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dFilledLineChartWithoutDataBorder.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.png b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.png
new file mode 100644
index 0000000..a4bcc85
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRender3dLineChart.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.png
new file mode 100644
index 0000000..06df5a0
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegment.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.png
new file mode 100644
index 0000000..b9400ce
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomHeight.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.png
new file mode 100644
index 0000000..ccdc6bc
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithCustomRotation.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.png
new file mode 100644
index 0000000..c5cfdcf
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithIncreasedMoveOut.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.png
new file mode 100644
index 0000000..1a8b933
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutDataBorder.png
Binary files differ
diff --git a/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.png b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.png
new file mode 100644
index 0000000..53f128b
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer3dTest_testRenderLabeledPieSegmentWithoutSymbols.png
Binary files differ
diff --git a/tests/driver_gd_test.php b/tests/driver_gd_test.php
index 68d0ead..6390d83 100644
--- a/tests/driver_gd_test.php
+++ b/tests/driver_gd_test.php
@@ -117,6 +117,35 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
);
}
+ public function testDrawTransparentPolygon()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $this->driver->drawPolygon(
+ array(
+ new ezcGraphCoordinate( 45, 12 ),
+ new ezcGraphCoordinate( 122, 34 ),
+ new ezcGraphCoordinate( 12, 71 ),
+ ),
+ ezcGraphColor::fromHex( '#3465A4BB' ),
+ true
+ );
+
+ $this->driver->render( $filename );
+
+ $this->assertTrue(
+ file_exists( $filename ),
+ 'No image was generated.'
+ );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
public function testDrawPolygonThreePointsNotFilled()
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
@@ -355,7 +384,7 @@ class ezcGraphGdDriverTest extends ezcImageTestCase
$this->driver->drawCircularArc(
new ezcGraphCoordinate( 100, 50 ),
150,
- 80,
+ 70,
10,
25,
300,
diff --git a/tests/line_test.php b/tests/line_test.php
index ee34af2..0e8dd3a 100644
--- a/tests/line_test.php
+++ b/tests/line_test.php
@@ -102,7 +102,7 @@ class ezcGraphLineChartTest extends ezcTestCase
$chart['sampleData']->color = '#CC0000';
$chart['sampleData']->symbol = ezcGraph::DIAMOND;
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawDataLine',
) );
@@ -114,6 +114,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( null )
@@ -126,6 +128,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( null )
@@ -138,6 +142,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( new ezcGraphCoordinate( .25, .95 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( null )
@@ -150,6 +156,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( new ezcGraphCoordinate( .5, .2 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( null )
@@ -162,6 +170,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#CC0000' ) ),
$this->equalTo( null )
@@ -179,7 +189,7 @@ class ezcGraphLineChartTest extends ezcTestCase
$chart->palette = 'Black';
$chart->options->fillLines = 100;
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawDataLine',
) );
@@ -191,6 +201,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::NO_SYMBOL ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
@@ -203,6 +215,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( new ezcGraphCoordinate( .0, .165 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .25, .6975 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::NO_SYMBOL ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
@@ -215,6 +229,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( new ezcGraphCoordinate( .75, .45 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( 1., .5 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::NO_SYMBOL ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A4' ) ),
$this->equalTo( ezcGraphColor::fromHex( '#3465A464' ) )
@@ -233,7 +249,7 @@ class ezcGraphLineChartTest extends ezcTestCase
$chart['sampleData']->symbol = ezcGraph::DIAMOND;
$chart['sampleData']->symbol['sample 3'] = ezcGraph::CIRCLE;
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawDataLine',
) );
@@ -245,6 +261,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .0, .415 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( null )
@@ -257,6 +275,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( new ezcGraphCoordinate( .25, .9475 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( .5, .19 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::CIRCLE ),
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( null )
@@ -269,6 +289,8 @@ class ezcGraphLineChartTest extends ezcTestCase
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( new ezcGraphCoordinate( .75, .7 ), .05 ),
$this->equalTo( new ezcGraphCoordinate( 1., .9975 ), .05 ),
+ $this->equalTo( 0 ),
+ $this->equalTo( 1 ),
$this->equalTo( ezcGraph::DIAMOND ),
$this->equalTo( ezcGraphColor::fromHex( '#729FCF' ) ),
$this->equalTo( null )
diff --git a/tests/pie_test.php b/tests/pie_test.php
index 4783cde..fab8b6a 100644
--- a/tests/pie_test.php
+++ b/tests/pie_test.php
@@ -95,7 +95,7 @@ class ezcGraphPieChartTest extends ezcTestCase
$chart['sample']->highlight['wget'] = true;
- $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2d', array(
'drawPieSegment',
) );
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
index 04cd408..a72e945 100644
--- a/tests/renderer_2d_test.php
+++ b/tests/renderer_2d_test.php
@@ -15,9 +15,13 @@
* @package ImageAnalysis
* @subpackage Tests
*/
-class ezcGraphRenderer2dTest extends ezcTestCase
+class ezcGraphRenderer2dTest extends ezcImageTestCase
{
+ protected $basePath;
+
+ protected $tempDir;
+
protected $renderer;
protected $driver;
@@ -34,7 +38,11 @@ class ezcGraphRenderer2dTest extends ezcTestCase
*/
public function setUp()
{
- $this->renderer = new ezcGraphRenderer2D();
+ static $i = 0;
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+
+ $this->renderer = new ezcGraphRenderer2d();
$this->driver = $this->getMock( 'ezcGraphGdDriver', array(
'drawPolygon',
@@ -58,6 +66,7 @@ class ezcGraphRenderer2dTest extends ezcTestCase
*/
public function tearDown()
{
+ $this->removeTempDir();
}
public function testRenderLabeledPieSegment()
@@ -292,8 +301,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 280., 140. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 40., 40. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 60. ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
$this->equalTo( 1 )
);
@@ -313,10 +322,10 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->method( 'drawPolygon' )
->with(
$this->equalTo( array(
- new ezcGraphCoordinate( 40., 160. ),
- new ezcGraphCoordinate( 280., 140. ),
- new ezcGraphCoordinate( 280., 200. ),
- new ezcGraphCoordinate( 40., 200. ),
+ new ezcGraphCoordinate( 40., 40. ),
+ new ezcGraphCoordinate( 280., 60. ),
+ new ezcGraphCoordinate( 280., 0. ),
+ new ezcGraphCoordinate( 40., 0. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -325,8 +334,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->expects( $this->at( 1 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 40., 160. ), 1. ),
- $this->equalTo( new ezcGraphCoordinate( 280., 140. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 40., 40. ), 1. ),
+ $this->equalTo( new ezcGraphCoordinate( 280., 60. ), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
$this->equalTo( 1 )
);
@@ -336,6 +345,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
ezcGraphColor::fromHex( '#FF0000' ),
new ezcGraphCoordinate( .1, .2 ),
new ezcGraphCoordinate( .7, .3 ),
+ 0,
+ 1,
ezcGraph::NO_SYMBOL,
null,
ezcGraphColor::fromHex( '#FF0000DD' ),
@@ -351,8 +362,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 40., 100. ),
- new ezcGraphCoordinate( 40., 160. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 40., 40. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -363,8 +374,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 280., 100. ),
- new ezcGraphCoordinate( 280., 60. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 280., 140. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -384,6 +395,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
ezcGraphColor::fromHex( '#FF0000' ),
new ezcGraphCoordinate( .1, .2 ),
new ezcGraphCoordinate( .7, .7 ),
+ 0,
+ 1,
ezcGraph::NO_SYMBOL,
null,
ezcGraphColor::fromHex( '#FF0000DD' ),
@@ -484,8 +497,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 40., 100. ),
- new ezcGraphCoordinate( 40., 160. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 40., 40. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -496,8 +509,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 280., 100. ),
- new ezcGraphCoordinate( 280., 60. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 280., 140. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -527,6 +540,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
ezcGraphColor::fromHex( '#FF0000' ),
new ezcGraphCoordinate( .1, .2 ),
new ezcGraphCoordinate( .7, .7 ),
+ 0,
+ 1,
ezcGraph::CIRCLE,
null,
ezcGraphColor::fromHex( '#FF0000DD' ),
@@ -542,8 +557,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 40., 100. ),
- new ezcGraphCoordinate( 40., 160. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 40., 40. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -554,8 +569,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
->with(
$this->equalTo( array(
new ezcGraphCoordinate( 280., 100. ),
- new ezcGraphCoordinate( 280., 60. ),
- new ezcGraphCoordinate( 148., 100. ),
+ new ezcGraphCoordinate( 280., 140. ),
+ new ezcGraphCoordinate( 184., 100. ),
), 1. ),
$this->equalTo( ezcGraphColor::fromHex( '#FF0000DD' ) ),
$this->equalTo( true )
@@ -587,6 +602,8 @@ class ezcGraphRenderer2dTest extends ezcTestCase
ezcGraphColor::fromHex( '#FF0000' ),
new ezcGraphCoordinate( .1, .2 ),
new ezcGraphCoordinate( .7, .7 ),
+ 0,
+ 1,
ezcGraph::BULLET,
ezcGraphColor::fromHex( '#00FF00' ),
ezcGraphColor::fromHex( '#FF0000DD' ),
@@ -1458,6 +1475,101 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$chart->yAxis
);
}
+
+ public function testRenderLineChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderFilledLineChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+ $chart->options->fillLines = 200;
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderFilledLineChartWithAxisIntersection()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+ $chart->options->fillLines = 200;
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => -151, 'sample 3' => 324, 'sample 4' => -120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => -5, 'sample 5' => -124);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderPieChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
}
?>
diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php
new file mode 100644
index 0000000..48d8510
--- /dev/null
+++ b/tests/renderer_3d_test.php
@@ -0,0 +1,377 @@
+<?php
+/**
+ * ezcGraphRenderer3dTest
+ *
+ * @package Graph
+ * @version //autogen//
+ * @subpackage Tests
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+
+/**
+ * Tests for ezcGraph class.
+ *
+ * @package ImageAnalysis
+ * @subpackage Tests
+ */
+class ezcGraphRenderer3dTest extends ezcImageTestCase
+{
+
+ protected $basePath;
+
+ protected $tempDir;
+
+ public static function suite()
+ {
+ return new ezcTestSuite( "ezcGraphRenderer3dTest" );
+ }
+
+ /**
+ * setUp
+ *
+ * @access public
+ */
+ public function setUp()
+ {
+ static $i = 0;
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+ }
+
+ /**
+ * tearDown
+ *
+ * @access public
+ */
+ public function tearDown()
+ {
+ //$this->removeTempDir();
+ }
+
+ public function testRenderLabeledPieSegment()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderLabeledPieSegmentWithoutSymbols()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->showSymbol = false;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderLabeledPieSegmentWithIncreasedMoveOut()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->moveOut = .2;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderLabeledPieSegmentWithoutDataBorder()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->dataBorder = 0;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderLabeledPieSegmentWithCustomHeight()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->pieChartHeight = 5;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRenderLabeledPieSegmentWithCustomRotation()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'Pie' );
+ $chart['sample'] = array(
+ 'Mozilla' => 4375,
+ 'IE' => 345,
+ 'Opera' => 1204,
+ 'wget' => 231,
+ 'Safari' => 987,
+ );
+
+ $chart['sample']->highlight['Safari'] = true;
+
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->pieChartRotation = .3;
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dLineChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dFilledLineChart()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+ $chart->options->fillLines = 200;
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dFilledLineChartWithAxisIntersection()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+ $chart->options->fillLines = 200;
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => -151, 'sample 3' => 324, 'sample 4' => -120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => -5, 'sample 5' => -124);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dFilledLineChartWithoutDataBorder()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->dataBorder = 0;
+
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dFilledLineChartNonFilledGrid()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->fillGrid = 1;
+
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+
+ public function testRender3dFilledLineChartNonFilledAxis()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.png';
+
+ $chart = ezcGraph::create( 'line' );
+ $chart->palette = 'Black';
+
+ $chart['Line 1'] = array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
+ $chart['Line 2'] = array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613);
+
+ $chart->driver = new ezcGraphGdDriver();
+ $chart->renderer = new ezcGraphRenderer3d();
+ $chart->renderer->options->fillAxis = 1;
+
+ $chart->options->font = $this->basePath . 'font.ttf';
+ $chart->render( 500, 200, $filename );
+
+ $this->assertImageSimilar(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.png',
+ 'Image does not look as expected.',
+ 10
+ );
+ }
+}
+
+?>
diff --git a/tests/suite.php b/tests/suite.php
index a7b7527..cb4f433 100644
--- a/tests/suite.php
+++ b/tests/suite.php
@@ -27,13 +27,13 @@ require_once 'text_test.php';
require_once 'numeric_axis_test.php';
require_once 'labeled_axis_test.php';
require_once 'renderer_2d_test.php';
+require_once 'renderer_3d_test.php';
require_once 'axis_exact_renderer_test.php';
require_once 'axis_centered_renderer_test.php';
require_once 'driver_gd_test.php';
require_once 'driver_svg_test.php';
require_once 'font_test.php';
require_once 'palette_test.php';
-require_once 'complete_rendering_test.php';
/**
* Test suite for ImageAnalysis package.
@@ -58,6 +58,7 @@ class ezcGraphSuite extends ezcTestSuite
$this->addTest( ezcGraphNumericAxisTest::suite() );
$this->addTest( ezcGraphLabeledAxisTest::suite() );
$this->addTest( ezcGraphRenderer2dTest::suite() );
+ $this->addTest( ezcGraphRenderer3dTest::suite() );
$this->addTest( ezcGraphAxisExactRendererTest::suite() );
$this->addTest( ezcGraphAxisCenteredRendererTest::suite() );
$this->addTest( ezcGraphGdDriverTest::suite() );
@@ -65,7 +66,6 @@ class ezcGraphSuite extends ezcTestSuite
$this->addTest( ezcGraphFontTest::suite() );
$this->addTest( ezcGraphTextTest::suite() );
$this->addTest( ezcGraphPaletteTest::suite() );
- $this->addTest( ezcGraphCompleteRenderingTest::suite() );
}
public static function suite()
OpenPOWER on IntegriCloud