ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChartData.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11abstract class ilChartData
12{
13 protected $type; // [string]
14 protected $label; // [string]
15 protected $data; // [array]
16 protected $fill; // [float]
17 protected $fill_color; // [color/gradient]
18 protected $hidden; // [bool]
19
25 abstract protected function getTypeString();
26
32 public function setHidden($a_value)
33 {
34 $this->hidden = (bool)$a_value;
35 }
36
42 public function isHidden()
43 {
44 return $this->hidden;
45 }
46
52 public function setLabel($a_value)
53 {
54 $this->label = (string)$a_value;
55 }
56
62 public function getLabel()
63 {
64 return $this->label;
65 }
66
73 public function addPoint($a_x, $a_y = null)
74 {
75 if($a_y !== null)
76 {
77 $this->data[] = array($a_x, $a_y);
78 }
79 else
80 {
81 $this->data[] = $a_x;
82 }
83 }
84
90 public function getData()
91 {
92 return $this->data;
93 }
94
101 public function setFill($a_value, $a_color = null)
102 {
103 $this->fill = $a_value;
104 if(ilChart::isValidColor($a_color))
105 {
106 $this->fill_color = $a_color;
107 }
108 }
109
115 public function getFill()
116 {
117 return array("fill"=>$this->fill, "color"=>$this->fill_color);
118 }
119
126 protected function parseDataOptions(array &$a_options)
127 {
128
129 }
130
137 public function parseData(array &$a_data)
138 {
139 $series = new stdClass();
140 $series->label = str_replace("\"", "\\\"", $this->getLabel());
141
142 $series->data = array();
143 foreach($this->getData() as $point)
144 {
145 $series->data[] = array($point[0], $point[1]);
146 }
147
148 $options = array("show"=>($this->isHidden() ? false : true));
149
150 $fill = $this->getFill();
151 if($fill["fill"])
152 {
153 $options["fill"] = $fill["fill"];
154 if($fill["color"])
155 {
156 $options["fillColor"] = ilChart::renderColor($fill["color"], $fill["fill"]);
157 }
158 }
159
161
162 $series->{$this->getTypeString()} = $options;
163
164 $a_data[] = $series;
165 }
166
173 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
174 {
175
176 }
177}
178
179?>
Abstract chart data series base class.
parseData(array &$a_data)
Convert data to flot config.
getTypeString()
Get series type.
getFill()
Get fill.
setFill($a_value, $a_color=null)
Set fill.
setHidden($a_value)
Set hidden.
parseDataOptions(array &$a_options)
Convert data options to flot config.
parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
Convert (global) properties to flot config.
setLabel($a_value)
Set label.
getData()
Get data.
getLabel()
Get label.
isHidden()
Is hidden?
addPoint($a_x, $a_y=null)
Set data.
Abstract Chart generator base class.
static renderColor($a_value, $a_opacity=1)
Render html color code.
static isValidColor($a_value)
Validate html color code.
if(!is_array($argv)) $options