summaryrefslogtreecommitdiffstats
path: root/src/charts/line.php
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2009-07-14 14:13:45 +0000
committerKore Nordmann <github@kore-nordmann.de>2009-07-14 14:13:45 +0000
commit11e6744455cadf222f828a437e095205da53da7a (patch)
treed85b763feeb930ebc2f29394475241bab0931561 /src/charts/line.php
parent8262fb03d006afdc4ea1ea6c21be991178510137 (diff)
downloadzetacomponents-graph-11e6744455cadf222f828a437e095205da53da7a.zip
zetacomponents-graph-11e6744455cadf222f828a437e095205da53da7a.tar.gz
- Implemented: #13341: Vertical Bar Charts
Diffstat (limited to 'src/charts/line.php')
-rw-r--r--src/charts/line.php74
1 files changed, 42 insertions, 32 deletions
diff --git a/src/charts/line.php b/src/charts/line.php
index 3348920..4c0ba14 100644
--- a/src/charts/line.php
+++ b/src/charts/line.php
@@ -174,6 +174,47 @@ class ezcGraphLineChart extends ezcGraphChart
}
/**
+ * Calculate bar chart step width
+ *
+ * @return void
+ */
+ protected function calculateStepWidth( ezcGraphChartElementAxis $mainAxis, ezcGraphChartElementAxis $secondAxis, $width )
+ {
+ $steps = $mainAxis->getSteps();
+
+ $stepWidth = null;
+ foreach ( $steps as $step )
+ {
+ if ( $stepWidth === null )
+ {
+ $stepWidth = $step->width;
+ }
+ elseif ( $step->width !== $stepWidth )
+ {
+ throw new ezcGraphUnregularStepsException();
+ }
+ }
+
+ $step = reset( $steps );
+ if ( count( $step->childs ) )
+ {
+ // Keep this for BC reasons
+ $barCount = ( $mainAxis->getMajorStepCount() + 1 ) * ( $mainAxis->getMinorStepCount() - 1 );
+ $stepWidth = 1 / $barCount;
+ }
+
+ $checkedRegularSteps = true;
+ return $mainAxis->axisLabelRenderer->modifyChartDataPosition(
+ $secondAxis->axisLabelRenderer->modifyChartDataPosition(
+ new ezcGraphCoordinate(
+ $width * $stepWidth,
+ $width * $stepWidth
+ )
+ )
+ );
+ }
+
+ /**
* Render the assigned data
*
* Will renderer all charts data in the remaining boundings after drawing
@@ -236,38 +277,7 @@ class ezcGraphLineChart extends ezcGraphChart
if ( ( $checkedRegularSteps === false ) &&
( $data->displayType->default === ezcGraph::BAR ) )
{
- $steps = $xAxis->getSteps();
-
- $stepWidth = null;
- foreach ( $steps as $step )
- {
- if ( $stepWidth === null )
- {
- $stepWidth = $step->width;
- }
- elseif ( $step->width !== $stepWidth )
- {
- throw new ezcGraphUnregularStepsException();
- }
- }
-
- $step = reset( $steps );
- if ( count( $step->childs ) )
- {
- // Keep this for BC reasons
- $barCount = ( $xAxis->getMajorStepCount() + 1 ) * ( $xAxis->getMinorStepCount() - 1 );
- $stepWidth = 1 / $barCount;
- }
-
- $checkedRegularSteps = true;
- $width = $xAxis->axisLabelRenderer->modifyChartDataPosition(
- $yAxis->axisLabelRenderer->modifyChartDataPosition(
- new ezcGraphCoordinate(
- ( $boundings->x1 - $boundings->x0 ) * $stepWidth,
- 0
- )
- )
- )->x;
+ $width = $this->calculateStepWidth( $xAxis, $yAxis, $boundings->width )->x;
}
// Draw lines for dataset
OpenPOWER on IntegriCloud