ILIAS  release_8 Revision v8.24
class.ilChartDataSpider.php
Go to the documentation of this file.
1<?php
2
21{
22 protected function getTypeString(): string
23 {
24 return "spider";
25 }
26
27 public function parseData(array &$a_data): void
28 {
29 parent::parseData($a_data);
30
31 $fill = $this->getFill();
32 if ($fill["color"] != "") {
33 $a_data[count($a_data) - 1]->color = ilChart::renderColor($fill["color"], 0.5);
34 }
35 }
36
37 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart): void
38 {
39 $spider = new stdClass();
40 $spider->active = true;
41
42 $spider->highlight = new stdClass();
43 $spider->highlight->mode = "line";
44
45
46 $spider->legs = new stdClass();
47 $spider->legs->fillStyle = ilChart::renderColor("#000", 0.7);
48 switch (count($a_chart->getLegLabels())) {
49 case 4:
50 case 6:
51 $spider->legs->legStartAngle = 10;
52 break;
53
54 default:
55 $spider->legs->legStartAngle = 0;
56 break;
57 }
58
59 $spider->legs->data = array();
60
61 $max_str_len = 0;
62 foreach ($a_chart->getLegLabels() as $l) {
63 $l = ilStr::shortenTextExtended($l, 80, true);
64
65 $label = new stdClass();
66 $label->label = $l;
67 $spider->legs->data[] = $label;
68
69 $max_str_len = max($max_str_len, strlen($l));
70 }
71
72 // depending on caption length
73 if ($max_str_len > 60) {
74 $font_size = 10;
75 } elseif ($max_str_len > 30) {
76 $font_size = 12;
77 } else {
78 $font_size = 15;
79 }
80 $spider->legs->font = $font_size . "px Arial";
81
82 $spider->spiderSize = 0.7;
83 $spider->lineWidth = 1;
84 $spider->pointSize = 0;
85
86 $spider->connection = new stdClass();
87 $spider->connection->width = 2;
88
89 $spider->legMin = 0.0000001;
90 $spider->legMax = $a_chart->getYAxisMax();
91
92 $a_options->series->spider = $spider;
93 }
94}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
Convert (global) properties to flot config.
parseData(array &$a_data)
Convert data to flot config.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static renderColor(string $a_value, float $a_opacity=1)
Render html color code.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)