4 include_once
"Services/Chart/classes/class.ilChartLegend.php";
43 $this->tpl = $DIC[
"tpl"];
45 $this->
data = array();
61 include_once
"Services/Chart/classes/class.ilChartGrid.php";
65 include_once
"Services/Chart/classes/class.ilChartPie.php";
68 case self::TYPE_SPIDER:
69 include_once
"Services/Chart/classes/class.ilChartSpider.php";
95 if (
sizeof($this->
data)) {
110 $this->height = $a_y;
123 if ($a_idx === null) {
126 $this->
data[$a_idx] = $a_series;
138 $this->legend = $a_legend;
148 foreach ($a_values as $color) {
149 if (self::isValidColor($color)) {
150 $this->colors[] = $color;
173 if (preg_match(
"/^#[0-9a-f]{3}$/i", $a_value, $match)) {
175 } elseif (preg_match(
"/^#[0-9a-f]{6}$/i", $a_value, $match)) {
189 if (self::isValidColor($a_value)) {
190 if (strlen($a_value) == 4) {
191 return "rgba(" . hexdec($a_value[1] . $a_value[1]) .
", " .
192 hexdec($a_value[2] . $a_value[2]) .
", " .
193 hexdec($a_value[3] . $a_value[3]) .
", " . $a_opacity .
")";
195 return "rgba(" . hexdec($a_value[1] . $a_value[2]) .
", " .
196 hexdec($a_value[3] . $a_value[4]) .
", " .
197 hexdec($a_value[5] . $a_value[6]) .
", " . $a_opacity .
")";
209 $this->shadow = (int) $a_value;
229 $this->auto_resize = (bool) $a_value;
239 $this->stacked = (bool) $a_value;
249 include_once
"Services/jQuery/classes/class.iljQueryUtil.php";
252 $tpl->addJavascript(
"Services/Chart/js/flot/excanvas.min.js");
253 $tpl->addJavascript(
"Services/Chart/js/flot/jquery.flot.min.js");
255 if ((
bool) $this->auto_resize) {
257 $tpl->addJavascript(
"Services/Chart/js/flot/jquery.flot.resize.min.js");
260 if ((
bool) $this->stacked) {
261 $tpl->addJavascript(
"Services/Chart/js/flot/jquery.flot.stack.min.js");
294 $chart =
new ilTemplate(
"tpl.grid.html",
true,
true,
"Services/Chart");
295 $chart->setVariable(
"ID", $this->
id);
298 if (is_numeric($this->width)) {
299 $chart->setVariable(
"WIDTH",
"width:" . $this->width .
"px;");
301 $chart->setVariable(
"WIDTH",
"width:" . $this->width .
";");
305 if (is_numeric($this->height)) {
306 $chart->setVariable(
"HEIGHT",
"height:" . $this->height .
"px;");
308 $chart->setVariable(
"HEIGHT",
"height:" . $this->height .
";");
315 $json_series = array();
316 foreach ($this->
data as $series) {
317 $series->parseData($json_series);
319 $chart->setVariable(
"SERIES", json_encode($json_series));
325 $json_options->series =
new stdClass();
326 $json_options->series->shadowSize = (int) $this->
getShadow();
327 $json_options->series->lines =
new stdClass();
328 $json_options->series->lines->show =
false;
329 $json_options->series->stack = (bool) $this->stacked;
331 foreach ($this->
data as $series) {
332 $series->parseGlobalOptions($json_options, $this);
339 $json_options->colors = array();
341 $json_options->colors[] = self::renderColor($color);
346 $json_options->legend =
new stdClass();
347 if (!$this->legend) {
348 $json_options->legend->show =
false;
350 $this->legend->parseOptions($json_options->legend);
353 $chart->setVariable(
"OPTIONS", json_encode($json_options));
355 $ret = $chart->get();
setSize($a_x, $a_y)
Set chart size.
setStacked($a_value)
Toggle stacking.
parseGlobalOptions(stdClass $a_options)
Convert (global) properties to flot config.
addCustomJS()
Add type-specific JS script.
Generator for spider charts.
__construct($a_id)
Constructor.
setShadow($a_value)
Set shadow.
isValidDataType(ilChartData $a_series)
Validate data series.
Abstract Chart generator base class.
setLegend(ilChartLegend $a_legend)
Set chart legend.
initJS()
Init JS script files.
isValid()
Basic validation.
setAutoResize($a_value)
Toggle auto-resizing on window resize/redraw.
static isValidColor($a_value)
Validate html color code.
special template class to simplify handling of ITX/PEAR
Generator for pie charts.
static renderColor($a_value, $a_opacity=1)
Render html color code.
Generator for grid-based charts.
setColors($a_values)
Set colors.
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
Abstract chart data series base class.
getDataInstance($a_type=null)
Get data series instance.
addData(ilChartData $a_series, $a_idx=null)
Add data series.
static getInstanceByType($a_type, $a_id)
Get type instance.