Initial repo created
[timetracker.git] / WEB-INF / lib / libchart / classes / view / chart / Chart.php
1 <?php
2         /* Libchart - PHP chart library
3          * Copyright (C) 2005-2008 Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
4          * 
5          * This program is free software: you can redistribute it and/or modify
6          * it under the terms of the GNU General Public License as published by
7          * the Free Software Foundation, either version 3 of the License, or
8          * (at your option) any later version.
9          * 
10          * This program is distributed in the hope that it will be useful,
11          * but WITHOUT ANY WARRANTY; without even the implied warranty of
12          * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13          * GNU General Public License for more details.
14          *
15          * You should have received a copy of the GNU General Public License
16          * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17          * 
18          */
19         
20         /*! \mainpage Libchart
21          *
22          * This is the reference API, automatically compiled by <a href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a>.
23          * You can find here information that is not covered by the <a href="../samplecode/">tutorial</a>.
24          *
25          */
26
27         /**
28          * Base chart class.
29          *
30          * @author Jean-Marc Trémeaux (jm.tremeaux at gmail.com)
31          */
32         abstract class Chart {
33                 /**
34                  * The data set.
35                  */
36                 protected $dataSet;
37         
38                 /**
39                  * Plot (holds graphical attributes).
40                  */
41                 protected $plot;
42
43                 /**
44                  * Abstract constructor of Chart.
45                  *
46                  * @param integer width of the image
47                  * @param integer height of the image
48                  */
49                 protected function Chart($width, $height) {
50                         // Creates the plot
51                         $this->plot = new Plot($width, $height);
52                         $this->plot->setTitle("Untitled chart");
53                         $this->plot->setLogoFileName(dirname(__FILE__) . "/../../../images/PoweredBy.png");
54                 }
55
56                 /**
57                  * Checks the data model before rendering the graph.
58                  */
59                 protected function checkDataModel() {
60                         // Check if a dataset was defined
61                         if (!$this->dataSet) {
62                                 die("Error: No dataset defined.");
63                         }
64                         
65                         // Maybe no points are defined, but that's ok. This will yield and empty graph with default boundaries.
66                 }
67                 
68                 /**
69                  * Create the image.
70                  */
71                 protected function createImage() {
72                         $this->plot->createImage();
73                 }
74
75                 /**
76                  * Sets the data set.
77                  *
78                  * @param dataSet The data set
79                  */
80                 public function setDataSet($dataSet) {
81                         $this->dataSet = $dataSet;
82                 }
83                 
84                 /**
85                  * Return the plot.
86                  *
87                  * @return plot
88                  */
89                 public function getPlot() {
90                         return $this->plot;
91                 }
92                 
93                 /**
94                  * Sets the title.
95                  *
96                  * @param string New title
97                  */
98                 public function setTitle($title) {
99                         $this->plot->setTitle($title);
100                 }
101         }
102 ?>