ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChartSpider.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once "Services/Chart/classes/class.ilChart.php";
5
14{
15 protected $leg_labels = array(); // [array]
16 protected $y_max = 0; // [float]
17
18 public function getDataInstance($a_type = null)
19 {
20 include_once "Services/Chart/classes/class.ilChartDataSpider.php";
21 return new ilChartDataSpider();
22 }
23
24 protected function isValidDataType(ilChartData $a_series)
25 {
26 return ($a_series instanceof ilChartDataSpider);
27 }
28
34 public function setLegLabels($a_val)
35 {
36 $this->leg_labels = $a_val;
37 }
38
44 public function getLegLabels()
45 {
46 return $this->leg_labels;
47 }
48
49
55 public function setYAxisMax($a_val)
56 {
57 $this->y_max = $a_val;
58 }
59
65 public function getYAxisMax()
66 {
67 return $this->y_max;
68 }
69
70 protected function addCustomJS()
71 {
72 global $tpl;
73
74 $tpl->addJavascript("Services/Chart/js/flot/jquery.flot.highlighter.js");
75 $tpl->addJavascript("Services/Chart/js/flot/jquery.flot.spider.js");
76 }
77
78 public function parseGlobalOptions(stdClass $a_options)
79 {
80 $a_options->grid = new stdClass();
81 $a_options->grid->hoverable = false;
82 $a_options->grid->clickable = false;
83 $a_options->grid->ticks = $this->getYAxisMax();
84 $a_options->grid->tickColor = ilChart::renderColor("#000", "0.1");
85 $a_options->grid->mode = "spider";
86 }
87
88 /* Optes:
89
90 series: {
91 shadowSize: {SHADOW},
92 lines: { show: false },
93 pie: { show: {IS_PIE} }
94 <!-- BEGIN spider -->
95 ,spider:{
96 active: true
97 ,highlight: {mode: "line"}
98 ,legs: {
99 data: [{LEG_LABELS}]
100 ,font: "{FONT_SIZE}px Arial"
101 ,fillStyle: "rgba(0,0,0,0.7)"
102 ,legStartAngle: {LEG_START_ANGLE}
103 }
104 ,spiderSize: 0.7
105 ,lineWidth: 1
106 ,pointSize: 0
107 ,connection: { width: 2 }
108 ,legMin: 0.0000001
109 ,legMax: {LEG_MAX}
110 }
111 <!-- END spider -->
112
113
114 $chart->setCurrentBlock("spider");
115 $lab_strings = array();
116 $max_str_len = 0;
117 foreach ($this->getLegLabels() as $l)
118 {
119 $l = ilUtil::shortenText ($l, 80, true);
120 $lab_strings[] = "{label: \"".$l."\"}";
121 $max_str_len = max($max_str_len, strlen($l));
122 }
123 $chart->setVariable("LEG_LABELS", implode($lab_strings, ","));
124 $chart->setVariable("LEG_MAX", $this->getYAxisMax());
125 switch (count($this->getLegLabels()))
126 {
127 case 4:
128 case 6:
129 $chart->setVariable("LEG_START_ANGLE", "10");
130 break;
131
132 default:
133 $chart->setVariable("LEG_START_ANGLE", "0");
134 break;
135 }
136 if ($max_str_len > 60)
137 {
138 $chart->setVariable("FONT_SIZE", "10");
139 }
140 else if ($max_str_len > 30)
141 {
142 $chart->setVariable("FONT_SIZE", "12");
143 }
144 else
145 {
146 $chart->setVariable("FONT_SIZE", "15");
147 }
148 $chart->parseCurrentBlock();
149
150 $chart->setCurrentBlock("spider_grid_options");
151 $chart->setVariable("NR_TICKS", $this->getYAxisMax());
152 $chart->parseCurrentBlock();
153
154
155 */
156
157}
158
159?>
global $tpl
Definition: ilias.php:8
Chart data spider series.
Abstract chart data series base class.
Generator for spider charts.
addCustomJS()
Add type-specific JS script.
setLegLabels($a_val)
Set leg labels.
parseGlobalOptions(stdClass $a_options)
Convert (global) properties to flot config.
getLegLabels()
Get leg labels.
getYAxisMax()
Get y axis max value.
isValidDataType(ilChartData $a_series)
Validate data series.
getDataInstance($a_type=null)
Get data series instance.
setYAxisMax($a_val)
Set y axis max value.
Abstract Chart generator base class.
static renderColor($a_value, $a_opacity=1)
Render html color code.