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