summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/axis/labeled.php28
-rw-r--r--src/axis/numeric.php28
-rw-r--r--src/charts/line.php5
-rw-r--r--src/datasets/base.php7
-rw-r--r--src/element/axis.php40
-rw-r--r--src/element/legend.php30
-rw-r--r--src/element/text.php7
-rw-r--r--src/graph.php6
-rw-r--r--src/interfaces/chart.php44
-rw-r--r--src/interfaces/element.php49
-rw-r--r--src/interfaces/palette.php36
-rw-r--r--src/palette/black.php23
-rw-r--r--src/palette/tango.php29
-rw-r--r--src/structs/color.php6
-rw-r--r--tests/labeled_axis_test.php12
-rw-r--r--tests/legend_test.php66
-rw-r--r--tests/line_test.php11
-rw-r--r--tests/numeric_axis_test.php20
-rw-r--r--tests/palette_test.php158
-rw-r--r--tests/text_test.php12
20 files changed, 455 insertions, 162 deletions
diff --git a/src/axis/labeled.php b/src/axis/labeled.php
index 8525460..341e36b 100644
--- a/src/axis/labeled.php
+++ b/src/axis/labeled.php
@@ -96,16 +96,16 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
{
case ezcGraph::TOP:
return $boundings->y0 +
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 );
case ezcGraph::BOTTOM:
return $boundings->y1 -
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 );
case ezcGraph::LEFT:
return $boundings->x0 +
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 );
case ezcGraph::RIGHT:
return $boundings->x1 -
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 );
}
}
else
@@ -114,20 +114,20 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
{
case ezcGraph::TOP:
return $boundings->y0 +
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) +
- ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) +
+ ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->axisSpace ) / ( count ( $this->labels ) - 1 ) * $key;
case ezcGraph::BOTTOM:
return $boundings->y1 -
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) -
- ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) -
+ ( $boundings->y1 - $boundings->y0 ) * ( 1 - $this->axisSpace ) / ( count ( $this->labels ) - 1 ) * $key;
case ezcGraph::LEFT:
return $boundings->x0 +
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) +
- ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) +
+ ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->axisSpace ) / ( count ( $this->labels ) - 1 ) * $key;
case ezcGraph::RIGHT:
return $boundings->x1 -
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) -
- ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->padding ) / ( count ( $this->labels ) - 1 ) * $key;
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) -
+ ( $boundings->x1 - $boundings->x0 ) * ( 1 - $this->axisSpace ) / ( count ( $this->labels ) - 1 ) * $key;
}
}
}
@@ -171,8 +171,8 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
$yStepsize = ( $end->y - $start->y ) / $steps;
// Caluclate datafree chart border
- $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) );
- $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) );
+ $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) );
+ $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) );
for ( $i = 0; $i <= $steps; ++$i )
{
diff --git a/src/axis/numeric.php b/src/axis/numeric.php
index 161130c..2640eb5 100644
--- a/src/axis/numeric.php
+++ b/src/axis/numeric.php
@@ -234,16 +234,16 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
{
case ezcGraph::TOP:
return $boundings->y0 +
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 );
case ezcGraph::BOTTOM:
return $boundings->y1 -
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 );
case ezcGraph::LEFT:
return $boundings->x0 +
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 );
case ezcGraph::RIGHT:
return $boundings->x1 -
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 );
}
}
else
@@ -252,20 +252,20 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
{
case ezcGraph::TOP:
return $boundings->y0 +
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) +
- ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->y1 - $boundings-> y0 ) * ( 1 - $this->padding );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) +
+ ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->y1 - $boundings-> y0 ) * ( 1 - $this->axisSpace );
case ezcGraph::BOTTOM:
return $boundings->y1 -
- ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) -
- ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->y1 - $boundings-> y0 ) * ( 1 - $this->padding );
+ ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) -
+ ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->y1 - $boundings-> y0 ) * ( 1 - $this->axisSpace );
case ezcGraph::LEFT:
return $boundings->x0 +
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) +
- ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->x1 - $boundings-> x0 ) * ( 1 - $this->padding );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) +
+ ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->x1 - $boundings-> x0 ) * ( 1 - $this->axisSpace );
case ezcGraph::RIGHT:
return $boundings->x1 -
- ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) -
- ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->x1 - $boundings-> x0 ) * ( 1 - $this->padding );
+ ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) -
+ ( $value - $this->min ) / ( $this->max - $this->min ) * ( $boundings->x1 - $boundings-> x0 ) * ( 1 - $this->axisSpace );
}
}
}
@@ -309,8 +309,8 @@ class ezcGraphChartElementNumericAxis extends ezcGraphChartElementAxis
$yStepsize = ( $end->y - $start->y ) / $steps;
// Caluclate datafree chart border
- $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) );
- $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) );
+ $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) );
+ $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) );
for ( $i = 0; $i <= $steps; ++$i )
{
diff --git a/src/charts/line.php b/src/charts/line.php
index b27e28f..2278994 100644
--- a/src/charts/line.php
+++ b/src/charts/line.php
@@ -19,9 +19,10 @@ class ezcGraphLineChart extends ezcGraphChart
{
parent::__construct();
- $this->elements['X_axis'] = new ezcGraphChartElementLabeledAxis();
+ $this->addElement( 'X_axis', new ezcGraphChartElementLabeledAxis() );
$this->elements['X_axis']->position = ezcGraph::LEFT;
- $this->elements['Y_axis'] = new ezcGraphChartElementNumericAxis();
+
+ $this->addElement( 'Y_axis', new ezcGraphChartElementNumericAxis() );
$this->elements['Y_axis']->position = ezcGraph::BOTTOM;
}
diff --git a/src/datasets/base.php b/src/datasets/base.php
index 7cda08d..6bd8cf3 100644
--- a/src/datasets/base.php
+++ b/src/datasets/base.php
@@ -25,6 +25,8 @@ class ezcGraphDataset implements ArrayAccess, Iterator
protected $current;
+ protected $pallet;
+
public function __construct()
{
$this->label = new ezcGraphDatasetStringProperty( $this );
@@ -63,6 +65,11 @@ class ezcGraphDataset implements ArrayAccess, Iterator
case 'symbol':
$this->symbol->default = $propertyValue;
break;
+ case 'palette':
+ $this->palette = $propertyValue;
+ $this->color->default = $this->palette->dataSetColor;
+ $this->symbol->default = $this->palette->dataSetSymbol;
+ break;
}
}
diff --git a/src/element/axis.php b/src/element/axis.php
index c6e269d..0dead4e 100644
--- a/src/element/axis.php
+++ b/src/element/axis.php
@@ -23,11 +23,12 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
protected $nullPosition;
/**
- * Percent of the chart space not used to display values
+ * Percent of the chart space used to display axis labels and arrowheads
+ * instead of data values
*
* @var float
*/
- protected $padding = .1;
+ protected $axisSpace = .1;
/**
* Padding between labels and axis in pixel
@@ -81,12 +82,23 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
public function __construct( array $options = array() )
{
- $this->border = ezcGraphColor::fromHex( '#000000' );
-
parent::__construct( $options );
}
/**
+ * Set colors and border fro this element
+ *
+ * @param ezcGraphPalette $palette Palette
+ * @return void
+ */
+ public function setFromPalette( ezcGraphPalette $palette )
+ {
+ $this->border = $palette->axisColor;
+ $this->padding = $palette->padding;
+ $this->margin = $palette->margin;
+ }
+
+ /**
* __set
*
* @param mixed $propertyName
@@ -104,8 +116,8 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
case 'nullPosition':
$this->nullPosition = (float) $propertyValue;
break;
- case 'padding':
- $this->padding = min( 1, max( 0, (float) $propertyValue ) );
+ case 'axisSpace':
+ $this->axisSpace = min( 1, max( 0, (float) $propertyValue ) );
break;
case 'labelPadding':
$this->labelPadding = min( 0, max( 0, (float) $propertyValue ) );
@@ -198,8 +210,8 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
$yStepsize = ( $end->y - $start->y ) / $steps;
// Caluclate datafree chart border
- $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->padding / 2 ) );
- $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->padding / 2 ) );
+ $xBorder = abs ( ( $boundings->x1 - $boundings->x0 ) * ( $this->axisSpace / 2 ) );
+ $yBorder = abs ( ( $boundings->y1 - $boundings->y0 ) * ( $this->axisSpace / 2 ) );
for ( $i = 0; $i <= $steps; ++$i )
{
@@ -294,7 +306,7 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
);
// Draw small arrowhead
- $size = abs( ceil( ( ( $end->x - $start->x ) + ( $end->y - $start->y ) ) * $this->padding / 4 ) );
+ $size = abs( ceil( ( ( $end->x - $start->x ) + ( $end->y - $start->y ) ) * $this->axisSpace / 4 ) );
$renderer->drawPolygon(
array(
@@ -323,11 +335,11 @@ abstract class ezcGraphChartElementAxis extends ezcGraphChartElement
true
);
- // Apply padding to start and end
- $start->x += ( $end->x - $start->x ) * ( $this->padding / 2 );
- $start->y += ( $end->y - $start->y ) * ( $this->padding / 2 );
- $end->x -= ( $end->x - $start->x ) * ( $this->padding / 2 );
- $end->y -= ( $end->y - $start->y ) * ( $this->padding / 2 );
+ // Apply axisSpace to start and end
+ $start->x += ( $end->x - $start->x ) * ( $this->axisSpace / 2 );
+ $start->y += ( $end->y - $start->y ) * ( $this->axisSpace / 2 );
+ $end->x -= ( $end->x - $start->x ) * ( $this->axisSpace / 2 );
+ $end->y -= ( $end->y - $start->y ) * ( $this->axisSpace / 2 );
// Draw major steps
$steps = $this->getMajorStepCount();
diff --git a/src/element/legend.php b/src/element/legend.php
index 8c2a21d..ae2aa07 100644
--- a/src/element/legend.php
+++ b/src/element/legend.php
@@ -150,26 +150,30 @@ class ezcGraphChartElementLegend extends ezcGraphChartElement
case ezcGraph::TOP:
$this->boundings = clone $boundings;
- $this->boundings->y1 = $boundings->y0 + ($boundings->y1 - $boundings->y0) * $this->landscapeSize;
- $boundings->y0 = $boundings->y0 + ($boundings->y1 - $boundings->y0) * $this->landscapeSize;
+ $size = (int) round( $boundings->y0 + ( $boundings->y1 - $boundings->y0) * $this->landscapeSize );
+ $this->boundings->y1 = $size;
+ $boundings->y0 = $size;
break;
case ezcGraph::LEFT:
$this->boundings = clone $boundings;
- $this->boundings->x1 = $boundings->x0 + ($boundings->x1 - $boundings->x0) * $this->portraitSize;
- $boundings->x0 = $boundings->x0 + ($boundings->x1 - $boundings->x0) * $this->portraitSize;
+ $size = (int) round( $boundings->x0 + ( $boundings->x1 - $boundings->x0) * $this->portraitSize );
+ $this->boundings->x1 = $size;
+ $boundings->x0 = $size;
break;
case ezcGraph::RIGHT:
$this->boundings = clone $boundings;
- $this->boundings->x0 = $boundings->x1 - ($boundings->x1 - $boundings->x0) * $this->portraitSize;
- $boundings->x1 = $boundings->x1 - ($boundings->x1 - $boundings->x0) * $this->portraitSize;
+ $size = (int) round( $boundings->x1 - ( $boundings->x1 - $boundings->x0) * $this->portraitSize );
+ $this->boundings->x0 = $size;
+ $boundings->x1 = $size;
break;
case ezcGraph::BOTTOM:
$this->boundings = clone $boundings;
- $this->boundings->y0 = $boundings->y1 - ($boundings->y1 - $boundings->y0) * $this->landscapeSize;
- $boundings->y1 = $boundings->y1 - ($boundings->y1 - $boundings->y0) * $this->landscapeSize;
+ $size = (int) round( $boundings->y1 - ( $boundings->y1 - $boundings->y0) * $this->landscapeSize );
+ $this->boundings->y0 = $size;
+ $boundings->y1 = $size;
break;
}
@@ -182,13 +186,13 @@ class ezcGraphChartElementLegend extends ezcGraphChartElement
{
case ezcGraph::LEFT:
case ezcGraph::RIGHT:
- $symbolSize = min(
+ $symbolSize = (int) round( min(
max(
$this->symbolSize,
( $this->boundings->y1 - $this->boundings->y0 ) * $this->minimumSymbolSize
),
( $this->boundings->y1 - $this->boundings->y0 ) / count( $this->labels )
- );
+ ) );
foreach ( $this->labels as $labelNr => $label )
{
@@ -216,11 +220,11 @@ class ezcGraphChartElementLegend extends ezcGraphChartElement
break;
case ezcGraph::TOP:
case ezcGraph::BOTTOM:
- $symbolSize = min(
+ $symbolSize = (int) round( min(
$this->symbolSize,
( $this->boundings->y1 - $this->boundings->y0 )
- );
- $width = ( $this->boundings->x1 - $this->boundings->x0 ) / count( $this->labels );
+ ) );
+ $width = (int) round( ( $this->boundings->x1 - $this->boundings->x0 ) / count( $this->labels ) );
foreach ( $this->labels as $labelNr => $label )
{
diff --git a/src/element/text.php b/src/element/text.php
index bab5f3b..fdcb250 100644
--- a/src/element/text.php
+++ b/src/element/text.php
@@ -23,13 +23,6 @@ class ezcGraphChartElementText extends ezcGraphChartElement
protected $maxHeight = .1;
/**
- * Padding between border an text in pixel
- *
- * @var integer
- */
- protected $padding = 2;
-
- /**
* Render a legend
*
* @param ezcGraphRenderer $renderer
diff --git a/src/graph.php b/src/graph.php
index dd868cd..244dd5f 100644
--- a/src/graph.php
+++ b/src/graph.php
@@ -54,6 +54,12 @@ class ezcGraph
}
}
+ /**
+ * Creates a palette from given name
+ *
+ * @param string $name Name of the palette
+ * @return ezcGraphPalette Created palette
+ */
static public function createPalette( $name )
{
$className = 'ezcGraphPalette' . $name;
diff --git a/src/interfaces/chart.php b/src/interfaces/chart.php
index 980ab8c..de0aed4 100644
--- a/src/interfaces/chart.php
+++ b/src/interfaces/chart.php
@@ -27,14 +27,14 @@ abstract class ezcGraphChart
*
* @var array( ezcGraphChartElement )
*/
- protected $elements;
+ protected $elements = array();
/**
* Contains the data of the chart
*
* @var array( ezcGraphDataset )
*/
- protected $data;
+ protected $data = array();
/**
* Renderer for the chart
@@ -61,15 +61,13 @@ abstract class ezcGraphChart
{
$this->options = new ezcGraphChartOptions( $options );
- $this->palette = ezcGraph::createPalette( 'Tango' );
+ $this->__set( 'palette', 'Tango' );
// Add standard elements
- $this->elements['title'] = new ezcGraphChartElementText();
- $this->elements['title']->font = $this->options->font;
+ $this->addElement( 'title', new ezcGraphChartElementText() );
$this->elements['title']->position = ezcGraph::TOP;
- $this->elements['legend'] = new ezcGraphChartElementLegend();
- $this->elements['legend']->font = $this->options->font;
+ $this->addElement( 'legend', new ezcGraphChartElementLegend() );
$this->elements['legend']->position = ezcGraph::LEFT;
// Define standard renderer and driver
@@ -78,6 +76,13 @@ abstract class ezcGraphChart
$this->renderer->setDriver( $this->driver );
}
+ protected function addElement( $name, ezcGraphChartElement $element )
+ {
+ $this->elements[$name] = $element;
+ $this->elements[$name]->font = $this->options->font;
+ $this->elements[$name]->setFromPalette( $this->palette );
+ }
+
/**
* Options write access
*
@@ -128,6 +133,9 @@ abstract class ezcGraphChart
{
$this->palette = ezcGraph::createPalette( $propertyValue );
}
+
+ $this->setFromPalette( $this->palette );
+
break;
case 'options':
if ( $propertyValue instanceof ezcGraphChartOptions )
@@ -145,6 +153,26 @@ abstract class ezcGraphChart
}
/**
+ * Set colors and border fro this element
+ *
+ * @param ezcGraphPalette $palette Palette
+ * @return void
+ */
+ public function setFromPalette( ezcGraphPalette $palette )
+ {
+ $this->options->font->font = $palette->fontFace;
+ $this->options->font->color = $palette->fontColor;
+ $this->options->background = $palette->background;
+ $this->options->border = $palette->chartBorderColor;
+ $this->options->borderWidth = $palette->chartBorderWidth;
+
+ foreach ( $this->elements as $element )
+ {
+ $element->setFromPalette( $palette );
+ }
+ }
+
+ /**
* Adds a dataset to the charts data
*
* @param string $name Name of dataset
@@ -161,11 +189,13 @@ abstract class ezcGraphChart
{
$this->data[$name]->createFromArray( $values );
$this->data[$name]->label = $name;
+ $this->data[$name]->palette = $this->palette;
}
elseif ( $values instanceof PDOStatement )
{
$this->data[$name]->createFromStatement( $values );
$this->data[$name]->label = $name;
+ $this->data[$name]->palette = $this->palette;
}
else
{
diff --git a/src/interfaces/element.php b/src/interfaces/element.php
index b59d4cf..d42e124 100644
--- a/src/interfaces/element.php
+++ b/src/interfaces/element.php
@@ -44,6 +44,20 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
protected $border;
/**
+ * Distance between border and content of element
+ *
+ * @var integer
+ */
+ protected $padding;
+
+ /**
+ * Distance between outer boundings and border of an element
+ *
+ * @var integer
+ */
+ protected $margin;
+
+ /**
* Border width
*
* @var integer
@@ -105,6 +119,20 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
}
/**
+ * Set colors and border fro this element
+ *
+ * @param ezcGraphPalette $palette Palette
+ * @return void
+ */
+ public function setFromPalette( ezcGraphPalette $palette )
+ {
+ $this->border = $palette->elementBorderColor;
+ $this->borderWidth = $palette->elementBorderWidth;
+ $this->padding = $palette->padding;
+ $this->margin = $palette->margin;
+ }
+
+ /**
* __set
*
* @param mixed $propertyName
@@ -128,6 +156,12 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
case 'border':
$this->border = ezcGraphColor::create( $propertyValue );
break;
+ case 'padding':
+ $this->padding = max( 0, (int) $propertyValue );
+ break;
+ case 'margin':
+ $this->margin = max( 0, (int) $propertyValue );
+ break;
case 'borderWidth':
$this->borderWidth = max( 0, (int) $propertyValue);
break;
@@ -202,7 +236,14 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
protected function renderBorder( ezcGraphRenderer $renderer )
{
- if ( $this->border instanceof ezcGraphColor )
+ // Apply margin
+ $this->boundings->x0 += $this->margin;
+ $this->boundings->y0 += $this->margin;
+ $this->boundings->x1 -= $this->margin;
+ $this->boundings->y1 -= $this->margin;
+
+ if ( ( $this->border instanceof ezcGraphColor ) &&
+ ( $this->borderWidth > 0 ) )
{
// Default bordervalue to 1
$this->borderWidth = max( 1, $this->borderWidth );
@@ -222,6 +263,12 @@ abstract class ezcGraphChartElement extends ezcBaseOptions
$this->boundings->x1 -= $this->borderWidth;
$this->boundings->y1 -= $this->borderWidth;
}
+
+ // Apply padding
+ $this->boundings->x0 += $this->padding;
+ $this->boundings->y0 += $this->padding;
+ $this->boundings->x1 -= $this->padding;
+ $this->boundings->y1 -= $this->padding;
}
protected function renderBackground( ezcGraphRenderer $renderer )
diff --git a/src/interfaces/palette.php b/src/interfaces/palette.php
index a93bd65..e1b07fe 100644
--- a/src/interfaces/palette.php
+++ b/src/interfaces/palette.php
@@ -71,19 +71,34 @@ abstract class ezcGraphPalette
protected $fontColor;
/**
- * Bordercolor
+ * Bordercolor the chart
*
* @var ezcGraphColor
*/
- protected $borderColor;
+ protected $chartBorderColor;
/**
- * Borderwidth
+ * Borderwidth for the chart
*
* @var integer
* @access protected
*/
- protected $borderWidth = 0;
+ protected $chartBorderWidth = 1;
+
+ /**
+ * Bordercolor for elements
+ *
+ * @var ezcGraphColor
+ */
+ protected $elementBorderColor;
+
+ /**
+ * Borderwidth for elements
+ *
+ * @var integer
+ * @access protected
+ */
+ protected $elementBorderWidth = 0;
/**
* Padding in elements
@@ -143,10 +158,15 @@ abstract class ezcGraphPalette
case 'fontFace':
return $this->fontFace;
- case 'borderColor':
- return $this->checkColor( $this->borderColor );
- case 'borderWidth':
- return $this->borderWidth;
+ case 'chartBorderColor':
+ return $this->checkColor( $this->chartBorderColor );
+ case 'chartBorderWidth':
+ return $this->chartBorderWidth;
+
+ case 'elementBorderColor':
+ return $this->checkColor( $this->elementBorderColor );
+ case 'elementBorderWidth':
+ return $this->elementBorderWidth;
case 'padding':
return $this->padding;
diff --git a/src/palette/black.php b/src/palette/black.php
index 3c97294..d53edbe 100644
--- a/src/palette/black.php
+++ b/src/palette/black.php
@@ -68,19 +68,34 @@ class ezcGraphPaletteBlack extends ezcGraphPalette
protected $fontColor = '#D3D7CF';
/**
- * Bordercolor
+ * Bordercolor the chart
*
* @var ezcGraphColor
*/
- protected $borderColor = '#555753';
+ protected $chartBorderColor = '#555753';
/**
- * Borderwidth
+ * Borderwidth for the chart
*
* @var integer
* @access protected
*/
- protected $borderWidth = 0;
+ protected $chartBorderWidth = 1;
+
+ /**
+ * Bordercolor for elements
+ *
+ * @var ezcGraphColor
+ */
+ protected $elementBorderColor = '#555753';
+
+ /**
+ * Borderwidth for elements
+ *
+ * @var integer
+ * @access protected
+ */
+ protected $elementBorderWidth = 0;
/**
* Padding in elements
diff --git a/src/palette/tango.php b/src/palette/tango.php
index 08f6746..2e3d1ce 100644
--- a/src/palette/tango.php
+++ b/src/palette/tango.php
@@ -51,7 +51,7 @@ class ezcGraphPaletteTango extends ezcGraphPalette
* @var array
*/
protected $dataSetSymbol = array(
- ezcGraph::BULLET,
+ ezcGraph::NO_SYMBOL,
);
/**
@@ -66,22 +66,37 @@ class ezcGraphPaletteTango extends ezcGraphPalette
*
* @var ezcGraphColor
*/
- protected $fontColor = '#888A85';
+ protected $fontColor = '#555753';
/**
- * Bordercolor
+ * Bordercolor the chart
*
* @var ezcGraphColor
*/
- protected $borderColor = '#BABDB6';
+ protected $chartBorderColor = '#BABDB6';
/**
- * Borderwidth
+ * Borderwidth for the chart
*
* @var integer
* @access protected
*/
- protected $borderWidth = 0;
+ protected $chartBorderWidth = 1;
+
+ /**
+ * Bordercolor for elements
+ *
+ * @var ezcGraphColor
+ */
+ protected $elementBorderColor = '#BABDB6';
+
+ /**
+ * Borderwidth for elements
+ *
+ * @var integer
+ * @access protected
+ */
+ protected $elementBorderWidth = 0;
/**
* Padding in elements
@@ -95,7 +110,7 @@ class ezcGraphPaletteTango extends ezcGraphPalette
*
* @var integer
*/
- protected $margin = 1;
+ protected $margin = 0;
}
?>
diff --git a/src/structs/color.php b/src/structs/color.php
index c95ce6c..38dbbeb 100644
--- a/src/structs/color.php
+++ b/src/structs/color.php
@@ -176,7 +176,11 @@ class ezcGraphColor
*/
static public function create( $color )
{
- if ( is_string( $color ) )
+ if ( $color instanceof ezcGraphColor )
+ {
+ return $color;
+ }
+ elseif ( is_string( $color ) )
{
return ezcGraphColor::fromHex( $color );
}
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php
index c9b632f..6e95f5f 100644
--- a/tests/labeled_axis_test.php
+++ b/tests/labeled_axis_test.php
@@ -361,7 +361,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 100, 190 ) ),
$this->equalTo( new ezcGraphCoordinate( 500, 190 ) ),
$this->equalTo( false )
@@ -401,7 +401,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
new ezcGraphCoordinate( 490, 185 ),
new ezcGraphCoordinate( 490, 195 ),
) ),
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( true )
);
@@ -434,7 +434,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
->expects( $this->at( 1 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 120, 194 ) ),
$this->equalTo( new ezcGraphCoordinate( 120, 186 ) ),
$this->equalTo( false )
@@ -443,7 +443,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
->expects( $this->at( 2 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 240, 194 ) ),
$this->equalTo( new ezcGraphCoordinate( 240, 186 ) ),
$this->equalTo( false )
@@ -452,7 +452,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
->expects( $this->at( 3 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 361, 194 ) ),
$this->equalTo( new ezcGraphCoordinate( 361, 186 ) ),
$this->equalTo( false )
@@ -461,7 +461,7 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
->expects( $this->at( 4 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 481, 194 ) ),
$this->equalTo( new ezcGraphCoordinate( 481, 186 ) ),
$this->equalTo( false )
diff --git a/tests/legend_test.php b/tests/legend_test.php
index 0ae724e..f3f4ef5 100644
--- a/tests/legend_test.php
+++ b/tests/legend_test.php
@@ -171,9 +171,9 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawBackground' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 0, 0 ) ),
- $this->equalTo( 100 ),
- $this->equalTo( 200 )
+ $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
+ $this->equalTo( 98 ),
+ $this->equalTo( 198 )
);
$chart->renderer = $mockedRenderer;
@@ -202,7 +202,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 2, 2 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::DIAMOND
@@ -212,7 +212,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 1, 15 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 2, 16 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -222,7 +222,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 1, 29 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 2, 30 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -254,9 +254,9 @@ class ezcGraphLegendTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 14, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 15, 2 ) ),
'sampleData',
- $this->equalTo( 85 ),
+ $this->equalTo( 83 ),
$this->equalTo( 12 ),
$this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
);
@@ -264,9 +264,9 @@ class ezcGraphLegendTest extends ezcTestCase
->expects( $this->at( 1 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 14, 15 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 15, 16 ) ),
'moreData',
- $this->equalTo( 85 ),
+ $this->equalTo( 83 ),
$this->equalTo( 12 ),
$this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
@@ -275,9 +275,9 @@ class ezcGraphLegendTest extends ezcTestCase
->expects( $this->at( 2 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 14, 29 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 15, 30 ) ),
'Even more data',
- $this->equalTo( 85 ),
+ $this->equalTo( 83 ),
$this->equalTo( 12 ),
$this->equalTo( ezcGraph::LEFT | ezcGraph::MIDDLE )
@@ -313,9 +313,9 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawBackground' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 400, 0 ) ),
- $this->equalTo( 100 ),
- $this->equalTo( 200 )
+ $this->equalTo( new ezcGraphCoordinate( 401, 1 ) ),
+ $this->equalTo( 98 ),
+ $this->equalTo( 198 )
);
$chart->renderer = $mockedRenderer;
@@ -345,7 +345,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 401, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 402, 2 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::DIAMOND
@@ -355,7 +355,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 401, 15 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 402, 16 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -365,7 +365,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 401, 29 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 402, 30 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -398,9 +398,9 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawBackground' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 0, 180 ) ),
- $this->equalTo( 500 ),
- $this->equalTo( 20 )
+ $this->equalTo( new ezcGraphCoordinate( 1, 181 ) ),
+ $this->equalTo( 498 ),
+ $this->equalTo( 18 )
);
$chart->renderer = $mockedRenderer;
@@ -430,7 +430,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 1, 181 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 2, 182 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::DIAMOND
@@ -440,7 +440,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 101, 181 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 101, 182 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -450,7 +450,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 201, 181 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 200, 182 ) ),
$this->equalTo( 12 ),
$this->equalTo( 12 ),
ezcGraph::NO_SYMBOL
@@ -483,27 +483,27 @@ class ezcGraphLegendTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 15, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 16, 2 ) ),
'sampleData',
- $this->equalTo( 185 ),
+ $this->equalTo( 184 ),
$this->equalTo( 12 )
);
$mockedRenderer
->expects( $this->at( 1 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 215, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 215, 2 ) ),
'moreData',
- $this->equalTo( 185 ),
+ $this->equalTo( 184 ),
$this->equalTo( 12 )
);
$mockedRenderer
->expects( $this->at( 2 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 415, 1 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 414, 2 ) ),
'Even more data',
- $this->equalTo( 185 ),
+ $this->equalTo( 184 ),
$this->equalTo( 12 )
);
@@ -536,7 +536,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#0000FF' ) ),
- $this->equalTo( new ezcGraphCoordinate( 3, 3 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 6, 6 ) ),
$this->equalTo( 14 ),
$this->equalTo( 14 ),
ezcGraph::DIAMOND
@@ -546,7 +546,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 3, 23 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 6, 26 ) ),
$this->equalTo( 14 ),
$this->equalTo( 14 ),
ezcGraph::NO_SYMBOL
@@ -556,7 +556,7 @@ class ezcGraphLegendTest extends ezcTestCase
->method( 'drawSymbol' )
->with(
$this->equalTo( ezcGraphColor::fromHex( '#FF0000' ) ),
- $this->equalTo( new ezcGraphCoordinate( 3, 43 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 6, 46 ) ),
$this->equalTo( 14 ),
$this->equalTo( 14 ),
ezcGraph::NO_SYMBOL
diff --git a/tests/line_test.php b/tests/line_test.php
index 2b498b0..adf7a09 100644
--- a/tests/line_test.php
+++ b/tests/line_test.php
@@ -47,13 +47,8 @@ class ezcGraphLineChartTest extends ezcTestCase
protected function addSampleData( ezcGraphChart $chart )
{
$chart->sampleData = array( 'sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1);
- $chart->sampleData->color = '#CC0000';
- $chart->sampleData->symbol = ezcGraph::DIAMOND;
$chart->moreData = array( 'sample 1' => 112, 'sample 2' => 54, 'sample 3' => 12, 'sample 4' => -167, 'sample 5' => 329);
- $chart->moreData->color = '#3465A4';
$chart->evenMoreData = array( 'sample 1' => 300, 'sample 2' => -30, 'sample 3' => 220, 'sample 4' => 67, 'sample 5' => 450);
- $chart->evenMoreData->color = '#73D216';
- $chart->evenMoreData->symbol = ezcGraph::BULLET;
$chart->evenMoreData->label = 'Even more data';
}
@@ -91,13 +86,13 @@ class ezcGraphLineChartTest extends ezcTestCase
);
$this->assertEquals(
- ezcGraphColor::fromHex( '#CC0000' ),
+ ezcGraphColor::fromHex( '#3465A4' ),
$legend[0]['color'],
'Color for first label is wrong.'
);
$this->assertEquals(
- ezcGraphColor::fromHex( '#3465A4' ),
+ ezcGraphColor::fromHex( '#4E9A06' ),
$legend[1]['color'],
'Color for second label is wrong.'
);
@@ -243,8 +238,10 @@ class ezcGraphLineChartTest extends ezcTestCase
{
$chart = ezcGraph::create( 'Line' );
$chart->title = 'Test graph';
+
$this->addSampleData( $chart );
$chart->driver = new ezcGraphGdDriver();
+
$chart->options->font = $this->basePath . 'font.ttf';
$chart->legend->font = $this->basePath . 'font2.ttf';
$chart->render( 500, 200, 'test.png' );
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index 22ce83e..6dd396a 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -645,7 +645,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 5 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 120, 200 ) ),
$this->equalTo( new ezcGraphCoordinate( 120, 0 ) ),
$this->equalTo( false )
@@ -685,7 +685,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
new ezcGraphCoordinate( 123, 5 ),
new ezcGraphCoordinate( 118, 5 ),
) ),
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( true )
);
@@ -719,7 +719,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 6 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 124, 190 ) ),
$this->equalTo( new ezcGraphCoordinate( 116, 190 ) ),
$this->equalTo( false )
@@ -728,7 +728,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 7 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 124, 130 ) ),
$this->equalTo( new ezcGraphCoordinate( 116, 130 ) ),
$this->equalTo( false )
@@ -737,7 +737,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 8 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 124, 70 ) ),
$this->equalTo( new ezcGraphCoordinate( 116, 70 ) ),
$this->equalTo( false )
@@ -746,7 +746,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 9 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 124, 10 ) ),
$this->equalTo( new ezcGraphCoordinate( 116, 10 ) ),
$this->equalTo( false )
@@ -783,7 +783,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 10 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 122, 190 ) ),
$this->equalTo( new ezcGraphCoordinate( 118, 190 ) ),
$this->equalTo( false )
@@ -792,7 +792,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 11 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 122, 178 ) ),
$this->equalTo( new ezcGraphCoordinate( 118, 178 ) ),
$this->equalTo( false )
@@ -801,7 +801,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 12 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 122, 166 ) ),
$this->equalTo( new ezcGraphCoordinate( 118, 166 ) ),
$this->equalTo( false )
@@ -812,7 +812,7 @@ class ezcGraphNumericAxisTest extends ezcTestCase
->expects( $this->at( 24 ) )
->method( 'drawLine' )
->with(
- $this->equalTo( ezcGraphColor::fromHex( '#000000' ) ),
+ $this->equalTo( ezcGraphColor::fromHex( '#2E3436' ) ),
$this->equalTo( new ezcGraphCoordinate( 122, 22 ) ),
$this->equalTo( new ezcGraphCoordinate( 118, 22 ) ),
$this->equalTo( false )
diff --git a/tests/palette_test.php b/tests/palette_test.php
index 71970b3..44d255b 100644
--- a/tests/palette_test.php
+++ b/tests/palette_test.php
@@ -219,13 +219,13 @@ class ezcGraphPaletteTest extends ezcTestCase
}
$this->assertEquals(
- ezcGraph::BULLET,
+ ezcGraph::NO_SYMBOL,
$chart->palette->dataSetSymbol,
'Symbol for datasets not properly set.'
);
$this->assertEquals(
- ezcGraph::BULLET,
+ ezcGraph::NO_SYMBOL,
$chart->palette->dataSetSymbol,
'Symbol for datasets not properly set.'
);
@@ -261,13 +261,13 @@ class ezcGraphPaletteTest extends ezcTestCase
}
$this->assertEquals(
- ezcGraphColor::fromHex( '#888A85' ),
+ ezcGraphColor::fromHex( '#555753' ),
$chart->palette->fontColor,
'Font color not properly set.'
);
}
- public function testBorderColor()
+ public function testChartBorderColor()
{
try
{
@@ -280,12 +280,48 @@ class ezcGraphPaletteTest extends ezcTestCase
$this->assertEquals(
ezcGraphColor::fromHex( '#BABDB6' ),
- $chart->palette->borderColor,
+ $chart->palette->chartBorderColor,
'Border color not properly set.'
);
}
- public function testBorderWidth()
+ public function testChartBorderWidth()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ 1,
+ $chart->palette->chartBorderWidth,
+ 'Border width not properly set.'
+ );
+ }
+
+ public function testElementBorderColor()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#BABDB6' ),
+ $chart->palette->elementBorderColor,
+ 'Border color not properly set.'
+ );
+ }
+
+ public function testElementBorderWidth()
{
try
{
@@ -298,7 +334,7 @@ class ezcGraphPaletteTest extends ezcTestCase
$this->assertEquals(
0,
- $chart->palette->borderWidth,
+ $chart->palette->elementBorderWidth,
'Border width not properly set.'
);
}
@@ -333,11 +369,117 @@ class ezcGraphPaletteTest extends ezcTestCase
}
$this->assertEquals(
- 1,
+ 0,
$chart->palette->margin,
'Margin not properly set.'
);
}
+
+ public function testDatasetAutomaticColorization()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+ $chart->spending = array( 2000 => 2347.2, 2458.3, 2569.4 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#3465A4' ),
+ $chart->income->color->default,
+ 'Wrong automatic color set.'
+ );
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#4E9A06' ),
+ $chart->spending->color->default,
+ 'Wrong automatic color set.'
+ );
+ }
+
+ public function testChartBackground()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+ $chart->spending = array( 2000 => 2347.2, 2458.3, 2569.4 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#EEEEEC' ),
+ $chart->options->background,
+ 'Chart background not set from pallet.'
+ );
+ }
+
+ public function testChartElementBorder()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+ $chart->spending = array( 2000 => 2347.2, 2458.3, 2569.4 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#BABDB6' ),
+ $chart->legend->border,
+ 'Chart background not set from pallet.'
+ );
+ }
+
+ public function testChartElementBorderWidth()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+ $chart->spending = array( 2000 => 2347.2, 2458.3, 2569.4 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ 0,
+ $chart->legend->borderWidth,
+ 'Chart background not set from pallet.'
+ );
+ }
+
+ public function testChartElementAxisColor()
+ {
+ try
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->income = array( 2000 => 2345.2, 2456.3, 2567.4 );
+ $chart->spending = array( 2000 => 2347.2, 2458.3, 2569.4 );
+ }
+ catch ( Exception $e )
+ {
+ $this->fail( $e->getMessage() );
+ }
+
+ $this->assertEquals(
+ ezcGraphColor::fromHex( '#2E3436' ),
+ $chart->X_axis->border,
+ 'Chart background not set from pallet.'
+ );
+ }
}
?>
diff --git a/tests/text_test.php b/tests/text_test.php
index 08bad2a..22e7986 100644
--- a/tests/text_test.php
+++ b/tests/text_test.php
@@ -60,10 +60,10 @@ class ezcGraphTextTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 2, 2 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 1, 1 ) ),
$this->equalTo( 'Title of a chart' ),
- $this->equalTo( 496 ),
- $this->equalTo( 16 ),
+ $this->equalTo( 498 ),
+ $this->equalTo( 18 ),
$this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
);
@@ -97,10 +97,10 @@ class ezcGraphTextTest extends ezcTestCase
->expects( $this->at( 0 ) )
->method( 'drawTextBox' )
->with(
- $this->equalTo( new ezcGraphCoordinate( 2, 182 ) ),
+ $this->equalTo( new ezcGraphCoordinate( 1, 181 ) ),
$this->equalTo( 'Title of a chart' ),
- $this->equalTo( 496 ),
- $this->equalTo( 16 ),
+ $this->equalTo( 498 ),
+ $this->equalTo( 18 ),
$this->equalTo( ezcGraph::CENTER | ezcGraph::MIDDLE )
);
OpenPOWER on IntegriCloud