ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilChartLegend.php
Go to the documentation of this file.
1<?php
2
24{
25 protected string $position = "";
26 protected int $columns = 0;
27 protected int $margin_x = 0;
28 protected int $margin_y = 0;
29 protected string $background = "";
30 protected float $opacity = 0;
31 protected string $border = "";
32 protected string $container = "";
33
34 public function __construct()
35 {
36 $this->setPosition("ne");
37 $this->setColumns(1);
38 $this->setMargin(5, 5);
39 $this->setBackground("#888");
40 $this->setOpacity(0.1);
41 $this->setLabelBorder("#bbb");
42 }
43
44 public function setPosition(string $a_position): void
45 {
46 $all = array("ne", "nw", "se", "sw");
47 if (in_array($a_position, $all)) {
48 $this->position = $a_position;
49 }
50 }
51
52 public function getPosition(): string
53 {
54 return $this->position;
55 }
56
60 public function setColumns(int $a_value): void
61 {
62 $this->columns = $a_value;
63 }
64
68 public function getColumns(): int
69 {
70 return $this->columns;
71 }
72
73 public function setMargin(int $a_x, int $a_y): void
74 {
75 $this->margin_x = $a_x;
76 $this->margin_y = $a_y;
77 }
78
79 public function getMargin(): array
80 {
81 return array("x" => $this->margin_x, "y" => $this->margin_y);
82 }
83
87 public function setBackground(string $a_color): void
88 {
89 if (ilChart::isValidColor($a_color)) {
90 $this->background = $a_color;
91 }
92 }
93
97 public function getBackground(): string
98 {
99 return $this->background;
100 }
101
102 public function setOpacity(float $a_value): void
103 {
104 if ($a_value >= 0 && $a_value <= 1) {
105 $this->opacity = $a_value;
106 }
107 }
108
109 public function getOpacity(): float
110 {
111 return $this->opacity;
112 }
113
114 public function setLabelBorder(string $a_color): void
115 {
116 if (ilChart::isValidColor($a_color)) {
117 $this->border = $a_color;
118 }
119 }
120
121 public function getLabelBorder(): string
122 {
123 return $this->border;
124 }
125
129 public function setContainer(string $a_value): void
130 {
131 $this->container = trim($a_value);
132 }
133
137 public function getContainer(): string
138 {
139 return $this->container;
140 }
141
145 public function parseOptions(stdClass $a_options): void
146 {
147 $a_options->show = true;
148
149 $a_options->noColumns = $this->getColumns();
150 $a_options->position = $this->getPosition();
151
152 $margin = $this->getMargin();
153 $a_options->margin = array($margin["x"], $margin["y"]);
154
155 $a_options->backgroundColor = ilChart::renderColor($this->getBackground());
156 $a_options->backgroundOpacity = str_replace(",", ".", (string) $this->getOpacity());
157 $a_options->labelBoxBorderColor = ilChart::renderColor($this->getLabelBorder());
158
159 $container = $this->getContainer();
160 if ($container) {
161 $a_options->container = '#' . $container;
162 }
163 }
164}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setMargin(int $a_x, int $a_y)
setColumns(int $a_value)
Set number of columns.
parseOptions(stdClass $a_options)
Convert (global) properties to flot config.
setBackground(string $a_color)
Set background color.
setContainer(string $a_value)
Set container id.
setOpacity(float $a_value)
getColumns()
Get number of columns.
getBackground()
Get background color.
getContainer()
Get container id.
setLabelBorder(string $a_color)
setPosition(string $a_position)
static renderColor(string $a_value, float $a_opacity=1)
Render html color code.
static isValidColor(string $a_value)
Validate html color code.