Author: Kore Nordmann
Date: 2006-06-19 17:06:09 +0200 (Mon, 19 Jun 2006)
New Revision: 3146
Log:
- Use custom minimum and maximum values on numeric axis for automatic scaling
Modified:
trunk/Graph/src/axis/numeric.php
trunk/Graph/tests/numeric_axis_test.php
Modified: trunk/Graph/src/axis/numeric.php
===================================================================
--- trunk/Graph/src/axis/numeric.php 2006-06-19 14:55:05 UTC (rev 3145)
+++ trunk/Graph/src/axis/numeric.php 2006-06-19 15:06:09 UTC (rev 3146)
@@ -224,6 +224,17 @@
}
}
+ // Use custom minimum and maximum if available
+ if ( $this->min !== false )
+ {
+ $this->minValue = $this->min;
+ }
+
+ if ( $this->max !== false )
+ {
+ $this->maxValue = $this->max;
+ }
+
// Calculate "nice" values for scaling parameters
if ( $this->majorStep === false )
{
Modified: trunk/Graph/tests/numeric_axis_test.php
===================================================================
--- trunk/Graph/tests/numeric_axis_test.php 2006-06-19 14:55:05 UTC (rev
3145)
+++ trunk/Graph/tests/numeric_axis_test.php 2006-06-19 15:06:09 UTC (rev
3146)
@@ -300,6 +300,103 @@
);
}
+ public function testMixedAutomagicAndManualScaling2()
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->yAxis->min = 0;
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ 0.,
+ $chart->yAxis->min,
+ 'As value for: min; '
+ );
+
+ $this->assertEquals(
+ 1500.,
+ $chart->yAxis->max,
+ 'As value for: max; '
+ );
+
+ $this->assertEquals(
+ 500.,
+ $chart->yAxis->majorStep,
+ 'As value for: majorStep; '
+ );
+
+ $this->assertEquals(
+ 100.,
+ $chart->yAxis->minorStep,
+ 'As value for: minorStep; '
+ );
+ }
+
+ public function testMixedAutomagicAndManualScaling3()
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->yAxis->max = 2000;
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ 1000.,
+ $chart->yAxis->min,
+ 'As value for: min; '
+ );
+
+ $this->assertEquals(
+ 2000.,
+ $chart->yAxis->max,
+ 'As value for: max; '
+ );
+
+ $this->assertEquals(
+ 250.,
+ $chart->yAxis->majorStep,
+ 'As value for: majorStep; '
+ );
+
+ $this->assertEquals(
+ 50.,
+ $chart->yAxis->minorStep,
+ 'As value for: minorStep; '
+ );
+ }
+
+ public function testMixedAutomagicAndManualScaling4()
+ {
+ $chart = ezcGraph::create( 'Line' );
+ $chart->sample = array( 2000 => 1045, 1300, 1012, 1450 );
+ $chart->yAxis->min = 0;
+ $chart->yAxis->max = 2000;
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ 0.,
+ $chart->yAxis->min,
+ 'As value for: min; '
+ );
+
+ $this->assertEquals(
+ 2000.,
+ $chart->yAxis->max,
+ 'As value for: max; '
+ );
+
+ $this->assertEquals(
+ 1000.,
+ $chart->yAxis->majorStep,
+ 'As value for: majorStep; '
+ );
+
+ $this->assertEquals(
+ 250.,
+ $chart->yAxis->minorStep,
+ 'As value for: minorStep; '
+ );
+ }
+
public function testPositionLeft()
{
$chart = ezcGraph::create( 'Line' );
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components