summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKore Nordmann <github@kore-nordmann.de>2006-08-15 15:18:17 +0000
committerKore Nordmann <github@kore-nordmann.de>2006-08-15 15:18:17 +0000
commit875bf32ec32cb28134914294a48d101b7a4810b5 (patch)
tree4360ba0ef2f838f72c23be0652048de8bda3842a
parent440bcae05b756a4167df690a48b2b77817d6a39a (diff)
downloadzetacomponents-graph-875bf32ec32cb28134914294a48d101b7a4810b5.zip
zetacomponents-graph-875bf32ec32cb28134914294a48d101b7a4810b5.tar.gz
- Added ezcGraphBarChart which inherits from ezcGraphLineChart and changes the
defaultDisplayType and the default axisLabelRenderer for the x axis
-rw-r--r--src/charts/bar.php35
-rw-r--r--src/graph_autoload.php1
-rw-r--r--tests/renderer_3d_test.php22
3 files changed, 39 insertions, 19 deletions
diff --git a/src/charts/bar.php b/src/charts/bar.php
new file mode 100644
index 0000000..def5397
--- /dev/null
+++ b/src/charts/bar.php
@@ -0,0 +1,35 @@
+<?php
+/**
+ * File containing the abstract ezcGraphBarChart class
+ *
+ * @package Graph
+ * @version //autogentag//
+ * @copyright Copyright (C) 2005, 2006 eZ systems as. All rights reserved.
+ * @license http://ez.no/licenses/new_bsd New BSD License
+ */
+/**
+ * Class to represent a line chart.
+ *
+ * @package Graph
+ */
+class ezcGraphBarChart extends ezcGraphLineChart
+{
+
+ public function __construct( array $options = array() )
+ {
+ parent::__construct();
+
+ $this->elements['xAxis']->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
+ }
+
+ /**
+ * Returns the default display type of the current chart type.
+ *
+ * @return int Display type
+ */
+ public function getDefaultDisplayType()
+ {
+ return ezcGraph::BAR;
+ }
+}
+?>
diff --git a/src/graph_autoload.php b/src/graph_autoload.php
index f8a1693..1011c85 100644
--- a/src/graph_autoload.php
+++ b/src/graph_autoload.php
@@ -17,6 +17,7 @@ return array(
'ezcGraphChart' => 'Graph/interfaces/chart.php',
'ezcGraphPieChart' => 'Graph/charts/pie.php',
'ezcGraphLineChart' => 'Graph/charts/line.php',
+ 'ezcGraphBarChart' => 'Graph/charts/bar.php',
'ezcGraphChartOptions' => 'Graph/options/chart.php',
'ezcGraphPieChartOptions' => 'Graph/options/pie_chart.php',
'ezcGraphLineChartOptions' => 'Graph/options/line_chart.php',
diff --git a/tests/renderer_3d_test.php b/tests/renderer_3d_test.php
index c47faef..b6ec129 100644
--- a/tests/renderer_3d_test.php
+++ b/tests/renderer_3d_test.php
@@ -566,18 +566,14 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
- $chart = new ezcGraphLineChart();
+ $chart = new ezcGraphBarChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->data['Line 0'] = new ezcGraphArrayDataSet( array( 'sample 1' => 432, 'sample 2' => 43, 'sample 3' => 65, 'sample 4' => 97, 'sample 5' => 154) );
- $chart->data['Line 0']->displayType = ezcGraph::BAR;
$chart->data['Line 0']->symbol = ezcGraph::NO_SYMBOL;
$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 1']->displayType = ezcGraph::BAR;
$chart->data['Line 1']->symbol = ezcGraph::NO_SYMBOL;
- $chart->xAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
-
$chart->driver = new ezcGraphGdDriver();
$chart->renderer = new ezcGraphRenderer3d();
$chart->options->font = $this->basePath . 'font.ttf';
@@ -595,24 +591,18 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
- $chart = new ezcGraphLineChart();
+ $chart = new ezcGraphBarChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->data['Rectangle'] = new ezcGraphArrayDataSet( array( 'sample 1' => 432, 'sample 2' => 43, 'sample 3' => 65, 'sample 4' => 97, 'sample 5' => 154) );
- $chart->data['Rectangle']->displayType = ezcGraph::BAR;
$chart->data['Rectangle']->symbol = ezcGraph::NO_SYMBOL;
$chart->data['Circle'] = new ezcGraphArrayDataSet( array( 'sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1) );
- $chart->data['Circle']->displayType = ezcGraph::BAR;
$chart->data['Circle']->symbol = ezcGraph::CIRCLE;
$chart->data['Bullet'] = new ezcGraphArrayDataSet( array( 'sample 1' => 124, 'sample 2' => 245, 'sample 3' => 361, 'sample 4' => 412, 'sample 5' => 480) );
- $chart->data['Bullet']->displayType = ezcGraph::BAR;
$chart->data['Bullet']->symbol = ezcGraph::BULLET;
$chart->data['Diamond'] = new ezcGraphArrayDataSet( array( 'sample 1' => 387, 'sample 2' => 261, 'sample 3' => 24, 'sample 4' => 59, 'sample 5' => 112) );
- $chart->data['Diamond']->displayType = ezcGraph::BAR;
$chart->data['Diamond']->symbol = ezcGraph::DIAMOND;
- $chart->xAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
-
$chart->driver = new ezcGraphGdDriver();
$chart->renderer = new ezcGraphRenderer3d();
$chart->options->font = $this->basePath . 'font.ttf';
@@ -630,24 +620,18 @@ class ezcGraphRenderer3dTest extends ezcImageTestCase
{
$filename = $this->tempDir . __FUNCTION__ . '.png';
- $chart = new ezcGraphLineChart();
+ $chart = new ezcGraphBarChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->data['Rectangle'] = new ezcGraphArrayDataSet( array( 'sample -1' => -432, 'sample -2' => -43, 'sample -3' => -65, 'sample -4' => -97, 'sample -5' => -154) );
- $chart->data['Rectangle']->displayType = ezcGraph::BAR;
$chart->data['Rectangle']->symbol = ezcGraph::NO_SYMBOL;
$chart->data['Circle'] = new ezcGraphArrayDataSet( array( 'sample -1' => -234, 'sample -2' => -21, 'sample -3' => -324, 'sample -4' => -120, 'sample -5' => -1) );
- $chart->data['Circle']->displayType = ezcGraph::BAR;
$chart->data['Circle']->symbol = ezcGraph::CIRCLE;
$chart->data['Bullet'] = new ezcGraphArrayDataSet( array( 'sample -1' => -124, 'sample -2' => -245, 'sample -3' => -361, 'sample -4' => -412, 'sample -5' => -480) );
- $chart->data['Bullet']->displayType = ezcGraph::BAR;
$chart->data['Bullet']->symbol = ezcGraph::BULLET;
$chart->data['Diamond'] = new ezcGraphArrayDataSet( array( 'sample -1' => -387, 'sample -2' => -261, 'sample -3' => -24, 'sample -4' => -59, 'sample -5' => -112) );
- $chart->data['Diamond']->displayType = ezcGraph::BAR;
$chart->data['Diamond']->symbol = ezcGraph::DIAMOND;
- $chart->xAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
-
$chart->driver = new ezcGraphGdDriver();
$chart->renderer = new ezcGraphRenderer3d();
$chart->options->font = $this->basePath . 'font.ttf';
OpenPOWER on IntegriCloud