summaryrefslogtreecommitdiffstats
path: root/src/interfaces
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2009-02-03 18:23:28 +0000
committerKore Nordmann <github@kore-nordmann.de>2009-02-03 18:23:28 +0000
commit1849ff7d52b3576da2d16c0095dcfa5090fbfc72 (patch)
treeea544d5612ec48204f500bd18f687fb45c39ce2f /src/interfaces
parentaf6c8b78b44a48da82b94c0f47b248a66f54d275 (diff)
downloadzetacomponents-graph-1849ff7d52b3576da2d16c0095dcfa5090fbfc72.zip
zetacomponents-graph-1849ff7d52b3576da2d16c0095dcfa5090fbfc72.tar.gz
- Refactored axis space handling in a BC compatible way. Fixes division by zero
errors with axis space equals 0. Partly resolves #013631. - Added more tests for axis label renderers # Several SVGs changed because of slight reordering of SVG elements which # causes no visual differences.
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/axis_label_renderer.php51
1 files changed, 47 insertions, 4 deletions
diff --git a/src/interfaces/axis_label_renderer.php b/src/interfaces/axis_label_renderer.php
index fb6a644..aff92af 100644
--- a/src/interfaces/axis_label_renderer.php
+++ b/src/interfaces/axis_label_renderer.php
@@ -266,8 +266,8 @@ abstract class ezcGraphAxisLabelRenderer extends ezcBaseOptions
// Turn direction vector to left by 90 degrees and multiply
// with major step size
$stepStart = new ezcGraphCoordinate(
- $position->x - $direction->y * $size,
- $position->y + $direction->x * $size
+ $position->x + $direction->y * $size,
+ $position->y - $direction->x * $size
);
$drawStep = true;
}
@@ -285,8 +285,8 @@ abstract class ezcGraphAxisLabelRenderer extends ezcBaseOptions
// Turn direction vector to right by 90 degrees and multiply
// with major step size
$stepEnd = new ezcGraphCoordinate(
- $position->x + $direction->y * $size,
- $position->y - $direction->x * $size
+ $position->x - $direction->y * $size,
+ $position->y + $direction->x * $size
);
$drawStep = true;
}
@@ -491,6 +491,49 @@ abstract class ezcGraphAxisLabelRenderer extends ezcBaseOptions
}
/**
+ * Get axis space values
+ *
+ * Get axis space values, depending on passed parameters. If
+ * $innerBoundings is given it will be used to caclulat the axis spaces
+ * available for label rendering. If not given the legacy method will be
+ * used, which uses the xAxisSpace and yAxisSpace values calcualted by the
+ * renderer.
+ *
+ * Returns an array( $xSpace, $ySpace ), containing the irespective size in
+ * pixels. Additionally calculates the grid boundings passed by reference.
+ *
+ * @param ezcGraphRenderer $renderer
+ * @param ezcGraphBoundings $boundings
+ * @param mixed $innerBoundings
+ * @return array
+ */
+ protected function getAxisSpace( ezcGraphRenderer $renderer, ezcGraphBoundings $boundings, ezcGraphChartElementAxis $axis, $innerBoundings, &$gridBoundings )
+ {
+ if ( $innerBoundings !== null )
+ {
+ $gridBoundings = clone $innerBoundings;
+ $xSpace = abs( $axis->position === ezcGraph::LEFT ? $innerBoundings->x0 - $boundings->x0 : $boundings->x1 - $innerBoundings->x1 );
+ $ySpace = abs( $axis->position === ezcGraph::TOP ? $innerBoundings->y0 - $boundings->y0 : $boundings->y1 - $innerBoundings->y1 );
+ }
+ else
+ {
+ $gridBoundings = new ezcGraphBoundings(
+ $boundings->x0 + ( $xSpace = abs( $renderer->xAxisSpace ) ),
+ $boundings->y0 + ( $ySpace = abs( $renderer->yAxisSpace ) ),
+ $boundings->x1 - $xSpace,
+ $boundings->y1 - $ySpace
+ );
+ }
+
+ if ( $this->outerGrid )
+ {
+ $gridBoundings = $boundings;
+ }
+
+ return array( $xSpace, $ySpace );
+ }
+
+ /**
* Render Axis labels
*
* Render labels for an axis.
OpenPOWER on IntegriCloud