summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-09-07 12:07:09 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-09-07 12:07:09 +0000
commitf42dfe88ec4fc900c8e30cf3cbeb9ea34af67e5b (patch)
treeec56bb738428f6c7063c873eb6d41962b271d7bb
parentac204a38b0f2927bd3b0d3d67fd34fb60f9c928c (diff)
downloadzetacomponents-graph-f42dfe88ec4fc900c8e30cf3cbeb9ea34af67e5b.zip
zetacomponents-graph-f42dfe88ec4fc900c8e30cf3cbeb9ea34af67e5b.tar.gz
- Added axis label rendering to 2d renderer
-rw-r--r--src/renderer/2d.php57
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabels.svg2
-rw-r--r--tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabelsReversedAxis.svg2
-rw-r--r--tests/renderer_2d_test.php48
4 files changed, 109 insertions, 0 deletions
diff --git a/src/renderer/2d.php b/src/renderer/2d.php
index 5233013..2400a1e 100644
--- a/src/renderer/2d.php
+++ b/src/renderer/2d.php
@@ -820,6 +820,63 @@ class ezcGraphRenderer2d extends ezcGraphRenderer
true
);
+ // Draw axis label
+ if ( $axis->label !== false )
+ {
+ $width = $boundings->x1 - $boundings->x0;
+ switch ( $axis->position )
+ {
+ case ezcGraph::TOP:
+ $this->driver->drawTextBox(
+ $axis->label,
+ new ezcGraphCoordinate(
+ $end->x + $axis->labelMargin - $width * ( 1 - $axis->axisSpace * 2 ),
+ $end->y - $axis->labelMargin - $axis->labelSize
+ ),
+ $width * ( 1 - $axis->axisSpace * 2 ) - $axis->labelMargin,
+ $axis->labelSize,
+ ezcGraph::TOP | ezcGraph::RIGHT
+ );
+ break;
+ case ezcGraph::BOTTOM:
+ $this->driver->drawTextBox(
+ $axis->label,
+ new ezcGraphCoordinate(
+ $end->x + $axis->labelMargin,
+ $end->y + $axis->labelMargin
+ ),
+ $width * ( 1 - $axis->axisSpace * 2 ) - $axis->labelMargin,
+ $axis->labelSize,
+ ezcGraph::TOP | ezcGraph::LEFT
+ );
+ break;
+ case ezcGraph::LEFT:
+ $this->driver->drawTextBox(
+ $axis->label,
+ new ezcGraphCoordinate(
+ $end->x - $width,
+ $end->y - $axis->labelSize - $axis->labelMargin
+ ),
+ $width - $axis->labelMargin,
+ $axis->labelSize,
+ ezcGraph::BOTTOM | ezcGraph::RIGHT
+ );
+ break;
+ case ezcGraph::RIGHT:
+ $this->driver->drawTextBox(
+ $axis->label,
+ new ezcGraphCoordinate(
+ $end->x,
+ $end->y - $axis->labelSize - $axis->labelMargin
+ ),
+ $width - $axis->labelMargin,
+ $axis->labelSize,
+ ezcGraph::BOTTOM | ezcGraph::LEFT
+ );
+ break;
+ }
+ }
+
$xAxisSpace = ( $end->x - $start->x ) * $axis->axisSpace;
$yAxisSpace = ( $end->y - $start->y ) * $axis->axisSpace;
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabels.svg b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabels.svg
new file mode 100644
index 0000000..90e9f75
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabels.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="chart" 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: #2e3436; fill-opacity: 1.00; stroke: none;"/><path d=" M 1.0000,199.0000 L 1.0000,1.0000 L 99.0000,1.0000 L 99.0000,199.0000 L 1.0000,199.0000 z " style="fill: none; stroke: #555753; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 2.0000,198.0000 L 2.0000,2.0000 L 98.0000,2.0000 L 98.0000,198.0000 L 2.0000,198.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;"/><ellipse cx="11" cy="11" rx="7" ry="7" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="11" cy="29" rx="7" ry="7" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><path d=" M 100.0000,180.0000 L 500.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><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: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 220.0000,20.0000 L 220.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,177.0000 L 220.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,20.0000 L 300.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,177.0000 L 300.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,20.0000 L 380.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,177.0000 L 380.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,20.0000 L 460.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,177.0000 L 460.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,200.0000 L 140.0000,0.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><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: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 140.0000,127.2000 L 460.0000,127.2000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,126.6667 L 143.0000,126.6667" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,72.8000 L 460.0000,72.8000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,73.3333 L 143.0000,73.3333" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,20.0000 L 460.0000,20.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,20.0000 L 143.0000,20.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,130.0800 L 140.0000,130.0800" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,130.0800 L 220.0000,175.5200" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,175.5200 L 300.0000,110.8800" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,110.8800 L 380.0000,154.4000" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,154.4000 L 460.0000,179.7867" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,64.1600 L 140.0000,64.1600" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,64.1600 L 220.0000,130.0800" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,130.0800 L 300.0000,116.4267" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,116.4267 L 380.0000,178.9333" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,178.9333 L 460.0000,49.2267" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><ellipse cx="140" cy="130.08" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="220" cy="175.52" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="300" cy="110.88" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="380" cy="154.4" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="460" cy="179.78666666667" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="140" cy="64.16" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="220" cy="130.08" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="300" cy="116.42666666667" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="380" cy="178.93333333333" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="460" cy="49.226666666667" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><text x="19" text-length="46.2px" y="18" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Line 1</text><text x="19" text-length="46.2px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Line 2</text><text x="444.1" text-length="53.9px" y="178" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Samples</text><text x="189.2" text-length="61.6px" y="196" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 2</text><text x="269.2" text-length="61.6px" y="196" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 3</text><text x="349.2" text-length="61.6px" y="196" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 4</text><text x="429.2" text-length="61.6px" y="196" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 5</text><text x="142" text-length="53.9px" y="16" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Numbers</text><text x="130.3" text-length="7.7px" y="178" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">0</text><text x="114.9" text-length="23.1px" y="124.66666666667" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">250</text><text x="114.9" text-length="23.1px" y="71.333333333333" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">500</text><text x="114.9" text-length="23.1px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">750</text></g></svg>
diff --git a/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabelsReversedAxis.svg b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabelsReversedAxis.svg
new file mode 100644
index 0000000..5b97204
--- /dev/null
+++ b/tests/data/compare/ezcGraphRenderer2dTest_testRenderLineChartWithAxisLabelsReversedAxis.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="chart" 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: #2e3436; fill-opacity: 1.00; stroke: none;"/><path d=" M 1.0000,199.0000 L 1.0000,1.0000 L 99.0000,1.0000 L 99.0000,199.0000 L 1.0000,199.0000 z " style="fill: none; stroke: #555753; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 2.0000,198.0000 L 2.0000,2.0000 L 98.0000,2.0000 L 98.0000,198.0000 L 2.0000,198.0000 z " style="fill: #000000; fill-opacity: 0.00; stroke: none;"/><ellipse cx="11" cy="11" rx="7" ry="7" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="11" cy="29" rx="7" ry="7" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><path d=" M 500.0000,20.0000 L 100.0000,20.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 108.0000,16.0000 L 100.0000,20.0000 L 108.0000,24.0000 L 108.0000,16.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 380.0000,20.0000 L 380.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,20.0000 L 380.0000,17.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,20.0000 L 300.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,20.0000 L 300.0000,17.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,20.0000 L 220.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,20.0000 L 220.0000,17.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,20.0000 L 140.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,20.0000 L 140.0000,17.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,0.0000 L 460.0000,200.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 462.5000,195.0000 L 460.0000,200.0000 L 457.5000,195.0000 L 462.5000,195.0000 z " style="fill: #eeeeec; fill-opacity: 1.00; stroke: none;"/><path d=" M 140.0000,72.8000 L 460.0000,72.8000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 463.0000,73.3333 L 460.0000,73.3333" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,127.2000 L 460.0000,127.2000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 463.0000,126.6667 L 460.0000,126.6667" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 140.0000,180.0000 L 460.0000,180.0000" style="fill: none; stroke: #888a85; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 463.0000,180.0000 L 460.0000,180.0000" style="fill: none; stroke: #eeeeec; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,69.9200 L 460.0000,69.9200" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,69.9200 L 380.0000,24.4800" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,24.4800 L 300.0000,89.1200" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,89.1200 L 220.0000,45.6000" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,45.6000 L 140.0000,20.2133" style="fill: none; stroke: #729fcf; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,135.8400 L 460.0000,135.8400" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 460.0000,135.8400 L 380.0000,69.9200" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 380.0000,69.9200 L 300.0000,83.5733" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 300.0000,83.5733 L 220.0000,21.0667" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><path d=" M 220.0000,21.0667 L 140.0000,150.7733" style="fill: none; stroke: #ef2929; stroke-width: 1; stroke-opacity: 1.00; stroke-linecap: round; stroke-linejoin: round;"/><ellipse cx="460" cy="69.92" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="380" cy="24.48" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="300" cy="89.12" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="220" cy="45.6" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="140" cy="20.213333333333" rx="3" ry="3" style="fill: #729fcf; fill-opacity: 1.00; stroke: none;"/><ellipse cx="460" cy="135.84" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="380" cy="69.92" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="300" cy="83.573333333333" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="220" cy="21.066666666667" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><ellipse cx="140" cy="150.77333333333" rx="3" ry="3" style="fill: #ef2929; fill-opacity: 1.00; stroke: none;"/><text x="19" text-length="46.2px" y="18" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Line 1</text><text x="19" text-length="46.2px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Line 2</text><text x="100" text-length="53.9px" y="18" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Samples</text><text x="349.2" text-length="61.6px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 2</text><text x="269.2" text-length="61.6px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 3</text><text x="189.2" text-length="61.6px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 4</text><text x="109.2" text-length="61.6px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">sample 5</text><text x="406.1" text-length="53.9px" y="198" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">Numbers</text><text x="450.3" text-length="7.7px" y="36" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">0</text><text x="434.9" text-length="23.1px" y="89.333333333333" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">250</text><text x="434.9" text-length="23.1px" y="142.66666666667" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">500</text><text x="434.9" text-length="23.1px" y="178" style="font-size: 14px; font-family: sans-serif; fill: #d3d7cf; fill-opacity: 1.00; stroke: none;">750</text></g></svg>
diff --git a/tests/renderer_2d_test.php b/tests/renderer_2d_test.php
index 961302d..5b316cc 100644
--- a/tests/renderer_2d_test.php
+++ b/tests/renderer_2d_test.php
@@ -1761,6 +1761,54 @@ class ezcGraphRenderer2dTest extends ezcTestCase
$this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
);
}
+
+ public function testRenderLineChartWithAxisLabels()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+
+ $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) );
+ $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613) );
+
+ $chart->xAxis->label = 'Samples';
+ $chart->yAxis->label = 'Numbers';
+
+ $chart->driver = new ezcGraphSvgDriver();
+
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
+
+ public function testRenderLineChartWithAxisLabelsReversedAxis()
+ {
+ $filename = $this->tempDir . __FUNCTION__ . '.svg';
+
+ $chart = new ezcGraphLineChart();
+ $chart->palette = new ezcGraphPaletteBlack();
+
+ $chart->data['Line 1'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) );
+ $chart->data['Line 2'] = new ezcGraphArrayDataSet( array( 'sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613) );
+
+ $chart->xAxis->label = 'Samples';
+ $chart->xAxis->position = ezcGraph::RIGHT;
+ $chart->yAxis->label = 'Numbers';
+ $chart->yAxis->position = ezcGraph::TOP;
+
+ $chart->driver = new ezcGraphSvgDriver();
+
+ $chart->render( 500, 200, $filename );
+
+ $this->compare(
+ $filename,
+ $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'
+ );
+ }
}
?>
OpenPOWER on IntegriCloud