summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/axis/labeled.php133
-rw-r--r--tests/data/compare/ezcGraphLabeledAxisTest_testRenderUnregularLabeling.svg2
-rw-r--r--tests/labeled_axis_test.php146
4 files changed, 279 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ef0b6f9..24a6579 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,8 @@
- Fixed issue #10199: Use saveXML instead of save( 'php://output' ) to work
around PHP bug #40429
- Fixed issue #10246: sprintf output modification in PHP 5.2.1
+- Fixed issue #10275: Low label count on labeled axis, when having (prime
+ number > 10) + 1 labels
1.0 - Monday 18 December 2006
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/axis/labeled.php b/src/axis/labeled.php
index c8d801a..563076a 100644
--- a/src/axis/labeled.php
+++ b/src/axis/labeled.php
@@ -38,6 +38,13 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
const MAX_LABEL_COUNT = 10;
/**
+ * Precalculated steps on the axis
+ *
+ * @var array( ezcGraphAxisStep )
+ */
+ protected $steps;
+
+ /**
* Constructor
*
* @param array $options Default option array
@@ -122,18 +129,46 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
*/
public function calculateAxisBoundings()
{
+ $this->steps = array();
+
$labelCount = count( $this->labels ) - 1;
+
+ if ( $labelCount === 0 )
+ {
+ return true;
+ }
+
if ( $labelCount <= self::MAX_LABEL_COUNT )
{
+ $stepSize = 1 / $labelCount;
+
+ foreach ( $this->labels as $nr => $label )
+ {
+ $this->steps[] = new ezcGraphAxisStep(
+ $stepSize * $nr,
+ $stepSize,
+ $label,
+ array(),
+ $nr === 0,
+ $nr === $labelCount
+ );
+ }
+
+ // @TODO: This line is deprecated and only build for
+ // deprecated getLabel()
$this->displayedLabels = $this->labels;
+
return true;
}
- for ( $div = self::MAX_LABEL_COUNT; $div > 0; --$div )
+ for ( $div = self::MAX_LABEL_COUNT; $div > 1; --$div )
{
if ( ( $labelCount % $div ) === 0 )
{
+ // @TODO: This part is deprecated and only build for
+ // deprecated getLabel()
$step = $labelCount / $div;
+
foreach ( $this->labels as $nr => $label )
{
if ( ( $nr % $step ) === 0 )
@@ -141,10 +176,104 @@ class ezcGraphChartElementLabeledAxis extends ezcGraphChartElementAxis
$this->displayedLabels[] = $label;
}
}
+ // End of deprecated part
- return true;
+ break;
+ }
+ }
+
+ // Build up step array
+ if ( $div > 2 )
+ {
+ $step = $labelCount / $div;
+ $stepSize = 1 / $div;
+ $minorStepSize = $stepSize / $step;
+
+ foreach ( $this->labels as $nr => $label )
+ {
+ if ( ( $nr % $step ) === 0 )
+ {
+ $mainstep = new ezcGraphAxisStep(
+ $stepSize * ( $nr / $step ),
+ $stepSize,
+ $label,
+ array(),
+ $nr === 0,
+ $nr === $labelCount
+ );
+
+ $this->steps[] = $mainstep;
+ }
+ else
+ {
+ $mainstep->childs[] = new ezcGraphAxisStep(
+ $mainstep->position + $minorStepSize * ( $nr % $step ),
+ $minorStepSize
+ );
+ }
+ }
+ }
+ else
+ {
+ $floatStep = $labelCount / ( self::MAX_LABEL_COUNT - 1 );
+ $position = 0;
+ $minorStepSize = 1 / $labelCount;
+
+ foreach ( $this->labels as $nr => $label )
+ {
+ if ( $nr >= $position )
+ {
+ $position += $floatStep;
+
+ // Add as major step
+ $mainstep = new ezcGraphAxisStep(
+ $minorStepSize * $nr,
+ ceil( $position - $nr ) * $minorStepSize,
+ $label,
+ array(),
+ $nr === 0,
+ $nr === $labelCount
+ );
+
+ // @TODO: This line is deprecated and only build for
+ // deprecated getLabel()
+ $this->displayedLabels[] = $label;
+
+ $this->steps[] = $mainstep;
+ }
+ else
+ {
+ $mainstep->childs[] = new ezcGraphAxisStep(
+ $minorStepSize * $nr,
+ $minorStepSize
+ );
+ }
+ }
+ }
+ }
+
+ /**
+ * Return array of steps on this axis
+ *
+ * @return array( ezcGraphAxisStep )
+ */
+ public function getSteps()
+ {
+ if ( $this->steps === null )
+ {
+ foreach( debug_backtrace() as $call )
+ {
+ var_dump(
+ $call['file'],
+ $call['line'],
+ $call['function'],
+ $call['class'],
+ ''
+ );
}
+ exit;
}
+ return $this->steps;
}
/**
diff --git a/tests/data/compare/ezcGraphLabeledAxisTest_testRenderUnregularLabeling.svg b/tests/data/compare/ezcGraphLabeledAxisTest_testRenderUnregularLabeling.svg
new file mode 100644
index 0000000..6e87132
--- /dev/null
+++ b/tests/data/compare/ezcGraphLabeledAxisTest_testRenderUnregularLabeling.svg
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" width="500" height="200" version="1.0" id="ezcGraph"><defs/><g id="ezcGraphChart" color-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="optimizeLegibility"><path d=" M 0.0000,200.0000 L 0.0000,0.0000 L 500.0000,0.0000 L 500.0000,200.0000 L 0.0000,200.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_1"/><path d=" M 0.0000,200.0000 L 0.0000,0.0000 L 100.0000,0.0000 L 100.0000,200.0000 L 0.0000,200.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_2"/><path d=" M 2.0000,16.0000 L 2.0000,2.0000 L 16.0000,2.0000 L 16.0000,16.0000 L 2.0000,16.0000 z " style="fill: #3465a4; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_3"/><path d=" M 100.0000,180.0000 L 500.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_5"/><path d=" M 492.0000,184.0000 L 500.0000,180.0000 L 492.0000,176.0000 L 492.0000,184.0000 z " style="fill: #2e3436; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_6"/><path d=" M 140.0000,200.0000 L 140.0000,0.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_7"/><path d=" M 137.5000,5.0000 L 140.0000,0.0000 L 142.5000,5.0000 L 137.5000,5.0000 z " style="fill: #2e3436; fill-opacity: 1.00; stroke: none;" id="ezcGraphPolygon_8"/><path d=" M 149.6000,20.0000 L 149.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_9"/><path d=" M 150.3226,179.0000 L 150.3226,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_10"/><path d=" M 159.2000,20.0000 L 159.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_11"/><path d=" M 160.6452,179.0000 L 160.6452,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_12"/><path d=" M 172.0000,20.0000 L 172.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_13"/><path d=" M 170.9677,179.0000 L 170.9677,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_14"/><path d=" M 181.6000,20.0000 L 181.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_15"/><path d=" M 181.2903,177.0000 L 181.2903,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_16"/><path d=" M 191.2000,20.0000 L 191.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_18"/><path d=" M 191.6129,179.0000 L 191.6129,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_19"/><path d=" M 200.8000,20.0000 L 200.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_20"/><path d=" M 201.9355,179.0000 L 201.9355,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_21"/><path d=" M 213.6000,20.0000 L 213.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_22"/><path d=" M 212.2581,177.0000 L 212.2581,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_23"/><path d=" M 223.2000,20.0000 L 223.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_25"/><path d=" M 222.5806,179.0000 L 222.5806,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_26"/><path d=" M 232.8000,20.0000 L 232.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_27"/><path d=" M 232.9032,179.0000 L 232.9032,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_28"/><path d=" M 242.4000,20.0000 L 242.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_29"/><path d=" M 243.2258,179.0000 L 243.2258,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_30"/><path d=" M 252.0000,20.0000 L 252.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_31"/><path d=" M 253.5484,177.0000 L 253.5484,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_32"/><path d=" M 264.8000,20.0000 L 264.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_34"/><path d=" M 263.8710,179.0000 L 263.8710,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_35"/><path d=" M 274.4000,20.0000 L 274.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_36"/><path d=" M 274.1935,179.0000 L 274.1935,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_37"/><path d=" M 284.0000,20.0000 L 284.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_38"/><path d=" M 284.5161,177.0000 L 284.5161,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_39"/><path d=" M 293.6000,20.0000 L 293.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_41"/><path d=" M 294.8387,179.0000 L 294.8387,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_42"/><path d=" M 306.4000,20.0000 L 306.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_43"/><path d=" M 305.1613,179.0000 L 305.1613,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_44"/><path d=" M 316.0000,20.0000 L 316.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_45"/><path d=" M 315.4839,179.0000 L 315.4839,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_46"/><path d=" M 325.6000,20.0000 L 325.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_47"/><path d=" M 325.8065,177.0000 L 325.8065,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_48"/><path d=" M 335.2000,20.0000 L 335.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_50"/><path d=" M 336.1290,179.0000 L 336.1290,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_51"/><path d=" M 348.0000,20.0000 L 348.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_52"/><path d=" M 346.4516,179.0000 L 346.4516,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_53"/><path d=" M 357.6000,20.0000 L 357.6000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_54"/><path d=" M 356.7742,177.0000 L 356.7742,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_55"/><path d=" M 367.2000,20.0000 L 367.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_57"/><path d=" M 367.0968,179.0000 L 367.0968,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_58"/><path d=" M 376.8000,20.0000 L 376.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_59"/><path d=" M 377.4194,179.0000 L 377.4194,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_60"/><path d=" M 386.4000,20.0000 L 386.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_61"/><path d=" M 387.7419,179.0000 L 387.7419,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_62"/><path d=" M 399.2000,20.0000 L 399.2000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_63"/><path d=" M 398.0645,177.0000 L 398.0645,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_64"/><path d=" M 408.8000,20.0000 L 408.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_66"/><path d=" M 408.3871,179.0000 L 408.3871,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_67"/><path d=" M 418.4000,20.0000 L 418.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_68"/><path d=" M 418.7097,179.0000 L 418.7097,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_69"/><path d=" M 428.0000,20.0000 L 428.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_70"/><path d=" M 429.0323,177.0000 L 429.0323,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_71"/><path d=" M 440.8000,20.0000 L 440.8000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_73"/><path d=" M 439.3548,179.0000 L 439.3548,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_74"/><path d=" M 450.4000,20.0000 L 450.4000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_75"/><path d=" M 449.6774,179.0000 L 449.6774,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_76"/><path d=" M 460.0000,20.0000 L 460.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_77"/><path d=" M 460.0000,177.0000 L 460.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_78"/><path d=" M 140.0000,180.0000 L 460.0000,180.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_80"/><path d=" M 140.0000,180.0000 L 143.0000,180.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_81"/><path d=" M 140.0000,168.8000 L 460.0000,168.8000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_83"/><path d=" M 140.0000,169.3333 L 141.0000,169.3333" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_84"/><path d=" M 140.0000,159.2000 L 460.0000,159.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_85"/><path d=" M 140.0000,158.6667 L 141.0000,158.6667" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_86"/><path d=" M 140.0000,148.0000 L 460.0000,148.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_87"/><path d=" M 140.0000,148.0000 L 141.0000,148.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_88"/><path d=" M 140.0000,136.8000 L 460.0000,136.8000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_89"/><path d=" M 140.0000,137.3333 L 141.0000,137.3333" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_90"/><path d=" M 140.0000,127.2000 L 460.0000,127.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_91"/><path d=" M 140.0000,126.6667 L 143.0000,126.6667" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_92"/><path d=" M 140.0000,116.0000 L 460.0000,116.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_94"/><path d=" M 140.0000,116.0000 L 141.0000,116.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_95"/><path d=" M 140.0000,104.8000 L 460.0000,104.8000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_96"/><path d=" M 140.0000,105.3333 L 141.0000,105.3333" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_97"/><path d=" M 140.0000,95.2000 L 460.0000,95.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_98"/><path d=" M 140.0000,94.6667 L 141.0000,94.6667" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_99"/><path d=" M 140.0000,84.0000 L 460.0000,84.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_100"/><path d=" M 140.0000,84.0000 L 141.0000,84.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_101"/><path d=" M 140.0000,72.8000 L 460.0000,72.8000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_102"/><path d=" M 140.0000,73.3333 L 143.0000,73.3333" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_103"/><path d=" M 140.0000,63.2000 L 460.0000,63.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_105"/><path d=" M 140.0000,62.6667 L 141.0000,62.6667" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_106"/><path d=" M 140.0000,52.0000 L 460.0000,52.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_107"/><path d=" M 140.0000,52.0000 L 141.0000,52.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_108"/><path d=" M 140.0000,40.8000 L 460.0000,40.8000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_109"/><path d=" M 140.0000,41.3333 L 141.0000,41.3333" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_110"/><path d=" M 140.0000,31.2000 L 460.0000,31.2000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_111"/><path d=" M 140.0000,30.6667 L 141.0000,30.6667" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_112"/><path d=" M 140.0000,20.0000 L 460.0000,20.0000" style="fill: none; stroke: #000000; stroke-width: 1; stroke-opacity: 0.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_113"/><path d=" M 140.0000,20.0000 L 143.0000,20.0000" style="fill: none; stroke: #2e3436; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_114"/><path d=" M 140.0000,89.3333 L 140.0000,89.3333" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_116"/><path d=" M 140.0000,89.3333 L 150.3226,48.6933" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_117"/><path d=" M 150.3226,48.6933 L 160.6452,24.8000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_118"/><path d=" M 160.6452,24.8000 L 170.9677,30.8800" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_119"/><path d=" M 170.9677,30.8800 L 181.2903,92.0000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_120"/><path d=" M 181.2903,92.0000 L 191.6129,28.3200" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_121"/><path d=" M 191.6129,28.3200 L 201.9355,88.8000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_122"/><path d=" M 201.9355,88.8000 L 212.2581,98.4000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_123"/><path d=" M 212.2581,98.4000 L 222.5806,112.8000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_124"/><path d=" M 222.5806,112.8000 L 232.9032,128.6933" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_125"/><path d=" M 232.9032,128.6933 L 243.2258,73.7600" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_126"/><path d=" M 243.2258,73.7600 L 253.5484,155.3600" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_127"/><path d=" M 253.5484,155.3600 L 263.8710,147.2533" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_128"/><path d=" M 263.8710,147.2533 L 274.1935,132.2133" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_129"/><path d=" M 274.1935,132.2133 L 284.5161,119.9467" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_130"/><path d=" M 284.5161,119.9467 L 294.8387,160.8000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_131"/><path d=" M 294.8387,160.8000 L 305.1613,68.6400" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_132"/><path d=" M 305.1613,68.6400 L 315.4839,98.4000" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_133"/><path d=" M 315.4839,98.4000 L 325.8065,137.3333" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_134"/><path d=" M 325.8065,137.3333 L 336.1290,120.3733" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_135"/><path d=" M 336.1290,120.3733 L 346.4516,80.5867" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_136"/><path d=" M 346.4516,80.5867 L 356.7742,150.1333" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_137"/><path d=" M 356.7742,150.1333 L 367.0968,103.8400" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_138"/><path d=" M 367.0968,103.8400 L 377.4194,70.6667" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_139"/><path d=" M 377.4194,70.6667 L 387.7419,41.8667" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_140"/><path d=" M 387.7419,41.8667 L 398.0645,100.2133" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_141"/><path d=" M 398.0645,100.2133 L 408.3871,97.8667" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_142"/><path d=" M 408.3871,97.8667 L 418.7097,86.1333" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_143"/><path d=" M 418.7097,86.1333 L 429.0323,150.5600" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_144"/><path d=" M 429.0323,150.5600 L 439.3548,135.7333" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_145"/><path d=" M 439.3548,135.7333 L 449.6774,54.3467" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_146"/><path d=" M 449.6774,54.3467 L 460.0000,62.0267" style="fill: none; stroke: #3465a4; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;" id="ezcGraphLine_147"/><g id="ezcGraphTextBox_4"><path d=" M 16.5000,17.0000 L 16.5000,1.5000 L 62.5200,1.5000 L 62.5200,17.0000 L 16.5000,17.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_148"/><text id="ezcGraphTextBox_4_text" x="17" text-length="44.52px" y="13.9" style="font-size: 14px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">sample</text></g><g id="ezcGraphTextBox_17"><path d=" M 168.3903,193.0000 L 168.3903,181.5000 L 194.6903,181.5000 L 194.6903,193.0000 L 168.3903,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_149"/><text id="ezcGraphTextBox_17_text" x="168.8903" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2004</text></g><g id="ezcGraphTextBox_24"><path d=" M 199.3581,193.0000 L 199.3581,181.5000 L 225.6581,181.5000 L 225.6581,193.0000 L 199.3581,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_150"/><text id="ezcGraphTextBox_24_text" x="199.8581" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2007</text></g><g id="ezcGraphTextBox_33"><path d=" M 240.6484,193.0000 L 240.6484,181.5000 L 266.9484,181.5000 L 266.9484,193.0000 L 240.6484,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_151"/><text id="ezcGraphTextBox_33_text" x="241.1484" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2011</text></g><g id="ezcGraphTextBox_40"><path d=" M 271.6161,193.0000 L 271.6161,181.5000 L 297.9161,181.5000 L 297.9161,193.0000 L 271.6161,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_152"/><text id="ezcGraphTextBox_40_text" x="272.1161" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2014</text></g><g id="ezcGraphTextBox_49"><path d=" M 312.9065,193.0000 L 312.9065,181.5000 L 339.2065,181.5000 L 339.2065,193.0000 L 312.9065,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_153"/><text id="ezcGraphTextBox_49_text" x="313.4065" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2018</text></g><g id="ezcGraphTextBox_56"><path d=" M 343.8742,193.0000 L 343.8742,181.5000 L 370.1742,181.5000 L 370.1742,193.0000 L 343.8742,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_154"/><text id="ezcGraphTextBox_56_text" x="344.3742" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2021</text></g><g id="ezcGraphTextBox_65"><path d=" M 385.1645,193.0000 L 385.1645,181.5000 L 411.4645,181.5000 L 411.4645,193.0000 L 385.1645,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_155"/><text id="ezcGraphTextBox_65_text" x="385.6645" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2025</text></g><g id="ezcGraphTextBox_72"><path d=" M 416.1323,193.0000 L 416.1323,181.5000 L 442.4323,181.5000 L 442.4323,193.0000 L 416.1323,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_156"/><text id="ezcGraphTextBox_72_text" x="416.6323" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2028</text></g><g id="ezcGraphTextBox_79"><path d=" M 447.1000,193.0000 L 447.1000,181.5000 L 473.4000,181.5000 L 473.4000,193.0000 L 447.1000,193.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_157"/><text id="ezcGraphTextBox_79_text" x="447.6" text-length="24.8px" y="190.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2031</text></g><g id="ezcGraphTextBox_82"><path d=" M 118.9000,179.0000 L 118.9000,167.5000 L 139.0000,167.5000 L 139.0000,179.0000 L 118.9000,179.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_158"/><text id="ezcGraphTextBox_82_text" x="119.4" text-length="18.6px" y="176.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">500</text></g><g id="ezcGraphTextBox_93"><path d=" M 112.7000,125.6667 L 112.7000,114.1667 L 139.0000,114.1667 L 139.0000,125.6667 L 112.7000,125.6667 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_159"/><text id="ezcGraphTextBox_93_text" x="113.2" text-length="24.8px" y="123.1667" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">1000</text></g><g id="ezcGraphTextBox_104"><path d=" M 112.7000,72.3333 L 112.7000,60.8333 L 139.0000,60.8333 L 139.0000,72.3333 L 112.7000,72.3333 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_160"/><text id="ezcGraphTextBox_104_text" x="113.2" text-length="24.8px" y="69.8333" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">1500</text></g><g id="ezcGraphTextBox_115"><path d=" M 112.7000,33.0000 L 112.7000,21.5000 L 139.0000,21.5000 L 139.0000,33.0000 L 112.7000,33.0000 z " style="fill: #ffffff; fill-opacity: 0.00; stroke: none;" id="ezcGraphPolygon_161"/><text id="ezcGraphTextBox_115_text" x="113.2" text-length="24.8px" y="30.5" style="font-size: 10px; font-family: sans-serif; fill: #2e3436; fill-opacity: 1.00; stroke: none;">2000</text></g></g></svg>
diff --git a/tests/labeled_axis_test.php b/tests/labeled_axis_test.php
index 16c641f..6097eeb 100644
--- a/tests/labeled_axis_test.php
+++ b/tests/labeled_axis_test.php
@@ -9,26 +9,48 @@
* @license http://ez.no/licenses/new_bsd New BSD License
*/
+require_once dirname( __FILE__ ) . '/test_case.php';
+
/**
* Tests for ezcGraph class.
*
* @package ImageAnalysis
* @subpackage Tests
*/
-class ezcGraphLabeledAxisTest extends ezcTestCase
+class ezcGraphLabeledAxisTest extends ezcGraphTestCase
{
+ protected $basePath;
+
+ protected $tempDir;
+
public static function suite()
{
return new PHPUnit_Framework_TestSuite( "ezcGraphLabeledAxisTest" );
}
+ protected function setUp()
+ {
+ static $i = 0;
+
+ $this->tempDir = $this->createTempDir( __CLASS__ . sprintf( '_%03d_', ++$i ) ) . '/';
+ $this->basePath = dirname( __FILE__ ) . '/data/';
+ }
+
+ protected function tearDown()
+ {
+ if ( !$this->hasFailed() )
+ {
+ $this->removeTempDir();
+ }
+ }
+
public function testFactoryLabeledAxis()
{
$chart = new ezcGraphLineChart();
$this->assertTrue(
$chart->xAxis instanceof ezcGraphChartElementLabeledAxis
- );
+ );
}
public function testAutomaticLabelingSingle()
@@ -295,6 +317,101 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
);
}
+ public function testAutomaticLabelingWithLotsOfLabels2()
+ {
+ $labelCount = 31;
+
+ // Make this reproducible
+ mt_srand( 2 );
+
+ for ( $i = 0; $i < $labelCount; ++$i )
+ {
+ $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 );
+ }
+
+ $chart = new ezcGraphLineChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( $data );
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ array(
+ 2000,
+ 2003,
+ 2006,
+ 2009,
+ 2012,
+ 2015,
+ 2018,
+ 2021,
+ 2024,
+ 2027,
+ 2030,
+ ),
+ $this->getAttribute( $chart->xAxis, 'displayedLabels' )
+ );
+ }
+
+ public function testAutomaticLabelingWithLotsOfLabels3()
+ {
+ $labelCount = 32;
+
+ // Make this reproducible
+ mt_srand( 2 );
+
+ for ( $i = 0; $i < $labelCount; ++$i )
+ {
+ $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 );
+ }
+
+ $chart = new ezcGraphLineChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( $data );
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ array(
+ 2000,
+ 2004,
+ 2007,
+ 2011,
+ 2014,
+ 2018,
+ 2021,
+ 2025,
+ 2028,
+ 2031,
+ ),
+ $this->getAttribute( $chart->xAxis, 'displayedLabels' )
+ );
+ }
+
+ public function testAutomaticLabelingWithLotsOfLabels4()
+ {
+ $labelCount = 165;
+
+ // Make this reproducible
+ mt_srand( 2 );
+
+ for ( $i = 0; $i < $labelCount; ++$i )
+ {
+ $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 );
+ }
+
+ $chart = new ezcGraphLineChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( $data );
+ $chart->render( 500, 200 );
+
+ $this->assertEquals(
+ array(
+ 2000,
+ 2041,
+ 2082,
+ 2123,
+ 2164,
+ ),
+ $this->getAttribute( $chart->xAxis, 'displayedLabels' )
+ );
+ }
+
public function testGetLabel()
{
$chart = new ezcGraphLineChart();
@@ -320,6 +437,31 @@ class ezcGraphLabeledAxisTest extends ezcTestCase
'Wrong label returned for nonexisting step.'
);
}
+
+ public function testRenderUnregularLabeling()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $labelCount = 32;
+
+ // Make this reproducible
+ mt_srand( 2 );
+
+ for ( $i = 0; $i < $labelCount; ++$i )
+ {
+ $data[(string) ( 2000 + $i )] = mt_rand( 500, 2000 );
+ }
+
+ $chart = new ezcGraphLineChart();
+ $chart->data['sample'] = new ezcGraphArrayDataSet( $data );
+
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
}
?>
OpenPOWER on IntegriCloud