summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/charts/line.php41
-rw-r--r--tests/numeric_axis_test.php62
2 files changed, 103 insertions, 0 deletions
diff --git a/src/charts/line.php b/src/charts/line.php
index 77d9f13..0ad5928 100644
--- a/src/charts/line.php
+++ b/src/charts/line.php
@@ -26,6 +26,47 @@ class ezcGraphLineChart extends ezcGraphChart
$this->elements['Y_axis']->position = ezcGraph::BOTTOM;
}
+ /**
+ * Options write access
+ *
+ * @throws ezcBasePropertyNotFoundException
+ * If Option could not be found
+ * @throws ezcBaseValueException
+ * If value is out of range
+ * @param mixed $propertyName Option name
+ * @param mixed $propertyValue Option value;
+ * @return mixed
+ */
+ public function __set( $propertyName, $propertyValue )
+ {
+ switch ( $propertyName ) {
+ case 'X_Axis':
+ if ( $propertyValue instanceof ezcGraphChartElementAxis )
+ {
+ $this->addElement( 'X_axis', $propertyValue );
+ $this->elements['X_axis']->position = ezcGraph::LEFT;
+ }
+ else
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' );
+ }
+ break;
+ case 'Y_Axis':
+ if ( $propertyValue instanceof ezcGraphChartElementAxis )
+ {
+ $this->addElement( 'Y_axis', $propertyValue );
+ $this->elements['Y_axis']->position = ezcGraph::BOTTOM;
+ }
+ else
+ {
+ throw new ezcBaseValueException( $propertyName, $propertyValue, 'ezcGraphChartElementAxis' );
+ }
+ break;
+ default:
+ parent::__set( $propertyName, $propertyValue );
+ }
+ }
+
protected function renderData( $renderer, $boundings )
{
foreach ( $this->data as $data )
diff --git a/tests/numeric_axis_test.php b/tests/numeric_axis_test.php
index e5378b2..4f94bd8 100644
--- a/tests/numeric_axis_test.php
+++ b/tests/numeric_axis_test.php
@@ -725,5 +725,67 @@ class ezcGraphNumericAxisTest extends ezcTestCase
$chart->render( 500, 200 );
}
+
+ public function testRenderNumericXAndYAxisLabels()
+ {
+ $sin = array();
+ for ( $i = -200; $i < 500; $i += 2 )
+ {
+ $sin[$i] = 25 * sin( $i / 50 );
+ }
+
+ $chart = ezcGraph::create( 'Line' );
+ $chart->X_Axis = new ezcGraphChartElementNumericAxis();
+ $chart->sinus = $sin;
+
+ $mockedRenderer = $this->getMock( 'ezcGraphRenderer2D', array(
+ 'drawTextBox',
+ ) );
+
+ $mockedRenderer
+ ->expects( $this->at( 1 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 122, 102 ) ),
+ $this->equalTo( '-250' ),
+ $this->equalTo( 118 ),
+ $this->equalTo( 8 ),
+ $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 2 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 242, 102 ) ),
+ $this->equalTo( '0' ),
+ $this->equalTo( 118 ),
+ $this->equalTo( 8 ),
+ $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 3 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 363, 102 ) ),
+ $this->equalTo( '250' ),
+ $this->equalTo( 118 ),
+ $this->equalTo( 8 ),
+ $this->equalTo( ezcGraph::LEFT | ezcGraph::TOP )
+ );
+ $mockedRenderer
+ ->expects( $this->at( 4 ) )
+ ->method( 'drawTextBox' )
+ ->with(
+ $this->equalTo( new ezcGraphCoordinate( 363, 102 ) ),
+ $this->equalTo( '500' ),
+ $this->equalTo( 118 ),
+ $this->equalTo( 8 ),
+ $this->equalTo( ezcGraph::RIGHT | ezcGraph::TOP )
+ );
+
+ $chart->renderer = $mockedRenderer;
+ $chart->render( 500, 200 );
+ }
}
+
?>
OpenPOWER on IntegriCloud