ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChartLegend.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
13 protected $position; // [string]
14 protected $columns; // [int]
15 protected $margin_x; // [int]
16 protected $margin_y; // [int]
17 protected $background; // [color]
18 protected $opacity; // [float] 0-1
19 protected $border; // [color]
20 protected $container; // [string]
21
25 public function __construct()
26 {
27 $this->setPosition("ne");
28 $this->setColumns(1);
29 $this->setMargin(5, 5);
30 $this->setBackground("#888");
31 $this->setOpacity(0.1);
32 $this->setLabelBorder("#bbb");
33 }
34
40 public function setPosition($a_position)
41 {
42 $all = array("ne", "nw", "se", "sw");
43 if(in_array((string)$a_position, $all))
44 {
45 $this->position = (string)$a_position;
46 }
47 }
48
54 public function getPosition()
55 {
56 return $this->position;
57 }
58
64 public function setColumns($a_value)
65 {
66 $this->columns = (int)$a_value;
67 }
68
74 public function getColumns()
75 {
76 return $this->columns;
77 }
78
85 public function setMargin($a_x, $a_y)
86 {
87 $this->margin_x = (int)$a_x;
88 $this->margin_y = (int)$a_y;
89 }
90
96 public function getMargin()
97 {
98 return array("x"=>$this->margin_x, "y"=>$this->margin_y);
99 }
100
106 public function setBackground($a_color)
107 {
108 if(ilChart::isValidColor($a_color))
109 {
110 $this->background = $a_color;
111 }
112 }
113
119 public function getBackground()
120 {
121 return $this->background;
122 }
123
129 public function setOpacity($a_value)
130 {
131 $a_value = (float)$a_value;
132 if($a_value >= 0 && $a_value <= 1)
133 {
134 $this->opacity = $a_value;
135 }
136 }
137
143 public function getOpacity()
144 {
145 return $this->opacity;
146 }
147
153 public function setLabelBorder($a_color)
154 {
155 if(ilChart::isValidColor($a_color))
156 {
157 $this->border = $a_color;
158 }
159 }
160
166 public function getLabelBorder()
167 {
168 return $this->border;
169 }
170
176 public function setContainer($a_value)
177 {
178 $this->container = trim($a_value);
179 }
180
186 public function getContainer()
187 {
188 return $this->container;
189 }
190
196 public function parseOptions(stdClass $a_options)
197 {
198 $a_options->show = true;
199
200 $a_options->noColumns = $this->getColumns();
201 $a_options->position = $this->getPosition();
202
203 $margin = $this->getMargin();
204 $a_options->margin = array($margin["x"], $margin["y"]);
205
206 $a_options->backgroundColor = ilChart::renderColor($this->getBackground());
207 $a_options->backgroundOpacity = str_replace(",",".",$this->getOpacity());
208 $a_options->labelBoxBorderColor = ilChart::renderColor($this->getLabelBorder());
209
210 $container = $this->getContainer();
211 if($container)
212 {
213 $a_options->container = '#'.$container;
214 }
215 }
216}
217
218?>
setColumns($a_value)
Set number of columns.
setMargin($a_x, $a_y)
Set margins.
setLabelBorder($a_color)
Set label border.
getPosition()
Get Position.
setContainer($a_value)
Set container id.
setOpacity($a_value)
Set Opacity.
parseOptions(stdClass $a_options)
Convert (global) properties to flot config.
getLabelBorder()
Get label border.
setPosition($a_position)
Set Position.
getColumns()
Get number of columns.
getBackground()
Get background color.
getContainer()
Get container id.
getOpacity()
Get opacity.
getMargin()
Get margins.
setBackground($a_color)
Set background color.
__construct()
Constructor.
static renderColor($a_value, $a_opacity=1)
Render html color code.
static isValidColor($a_value)
Validate html color code.