diff options
author | Kore Nordmann <github@kore-nordmann.de> | 2007-04-10 15:55:11 +0000 |
---|---|---|
committer | Kore Nordmann <github@kore-nordmann.de> | 2007-04-10 15:55:11 +0000 |
commit | 4a8c988ef8c41d2989497792dec16886e85ab687 (patch) | |
tree | 029c76e6015ad1b7794463efb43dfaba57f12bca /src/charts | |
parent | cd7bb19d7881216a0faf754da1446073bbf57ffa (diff) | |
download | zetacomponents-graph-4a8c988ef8c41d2989497792dec16886e85ab687.zip zetacomponents-graph-4a8c988ef8c41d2989497792dec16886e85ab687.tar.gz |
- Implemented @TODO: Throw exception when axis with unregular steps is used
with bar charts
Diffstat (limited to 'src/charts')
-rw-r--r-- | src/charts/line.php | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/src/charts/line.php b/src/charts/line.php index f58d1c6..4ba9c52 100644 --- a/src/charts/line.php +++ b/src/charts/line.php @@ -162,6 +162,8 @@ class ezcGraphLineChart extends ezcGraphChart $count[$data->displayType->default]++; } + $checkedRegularSteps = false; + // Display data foreach ( $this->data as $datasetName => $data ) { @@ -227,23 +229,41 @@ class ezcGraphLineChart extends ezcGraphChart } break; case ezcGraph::BAR: - // @TODO: - // - Use getSteps() to determine bar width - // - throw Exception on unregular step width on x axis - $barCount = ( - ( count ( $data ) - 1 ) > $this->elements['xAxis']->getMajorStepCount() ? - ( $this->elements['xAxis']->getMajorStepCount() + 1 ) * ( $this->elements['xAxis']->getMinorStepCount() - 1 ) : - $this->elements['xAxis']->getMajorStepCount() - ); - - $width = $this->elements['xAxis']->axisLabelRenderer->modifyChartDataPosition( - $this->elements['yAxis']->axisLabelRenderer->modifyChartDataPosition( - new ezcGraphCoordinate( - ( $boundings->x1 - $boundings->x0 ) / $barCount, - 0 + if ( $checkedRegularSteps === false ) + { + $steps = $this->elements['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 = ( $this->elements['xAxis']->getMajorStepCount() + 1 ) * ( $this->elements['xAxis']->getMinorStepCount() - 1 ); + $stepWidth = 1 / $barCount; + } + + $checkedRegularSteps = true; + $width = $this->elements['xAxis']->axisLabelRenderer->modifyChartDataPosition( + $this->elements['yAxis']->axisLabelRenderer->modifyChartDataPosition( + new ezcGraphCoordinate( + ( $boundings->x1 - $boundings->x0 ) * $stepWidth, + 0 + ) ) - ) - )->x; + )->x; + } foreach ( $data as $key => $value ) { |