ILIAS  release_8 Revision v8.24
class.ilChartLegend.php
Go to the documentation of this file.
1<?php
2
21{
22 protected string $position = "";
23 protected int $columns = 0;
24 protected int $margin_x = 0;
25 protected int $margin_y = 0;
26 protected string $background = "";
27 protected float $opacity = 0;
28 protected string $border = "";
29 protected string $container = "";
30
31 public function __construct()
32 {
33 $this->setPosition("ne");
34 $this->setColumns(1);
35 $this->setMargin(5, 5);
36 $this->setBackground("#888");
37 $this->setOpacity(0.1);
38 $this->setLabelBorder("#bbb");
39 }
40
41 public function setPosition(string $a_position): void
42 {
43 $all = array("ne", "nw", "se", "sw");
44 if (in_array($a_position, $all)) {
45 $this->position = $a_position;
46 }
47 }
48
49 public function getPosition(): string
50 {
51 return $this->position;
52 }
53
57 public function setColumns(int $a_value): void
58 {
59 $this->columns = $a_value;
60 }
61
65 public function getColumns(): int
66 {
67 return $this->columns;
68 }
69
70 public function setMargin(int $a_x, int $a_y): void
71 {
72 $this->margin_x = $a_x;
73 $this->margin_y = $a_y;
74 }
75
76 public function getMargin(): array
77 {
78 return array("x" => $this->margin_x, "y" => $this->margin_y);
79 }
80
84 public function setBackground(string $a_color): void
85 {
86 if (ilChart::isValidColor($a_color)) {
87 $this->background = $a_color;
88 }
89 }
90
94 public function getBackground(): string
95 {
96 return $this->background;
97 }
98
99 public function setOpacity(float $a_value): void
100 {
101 if ($a_value >= 0 && $a_value <= 1) {
102 $this->opacity = $a_value;
103 }
104 }
105
106 public function getOpacity(): float
107 {
108 return $this->opacity;
109 }
110
111 public function setLabelBorder(string $a_color): void
112 {
113 if (ilChart::isValidColor($a_color)) {
114 $this->border = $a_color;
115 }
116 }
117
118 public function getLabelBorder(): string
119 {
120 return $this->border;
121 }
122
126 public function setContainer(string $a_value): void
127 {
128 $this->container = trim($a_value);
129 }
130
134 public function getContainer(): string
135 {
136 return $this->container;
137 }
138
142 public function parseOptions(stdClass $a_options): void
143 {
144 $a_options->show = true;
145
146 $a_options->noColumns = $this->getColumns();
147 $a_options->position = $this->getPosition();
148
149 $margin = $this->getMargin();
150 $a_options->margin = array($margin["x"], $margin["y"]);
151
152 $a_options->backgroundColor = ilChart::renderColor($this->getBackground());
153 $a_options->backgroundOpacity = str_replace(",", ".", (string) $this->getOpacity());
154 $a_options->labelBoxBorderColor = ilChart::renderColor($this->getLabelBorder());
155
156 $container = $this->getContainer();
157 if ($container) {
158 $a_options->container = '#' . $container;
159 }
160 }
161}
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.