ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilChartDataPie.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.ilChartData.php";
5
14{
15 protected $line_width; // [int]
16 protected $label_radius; //mixed
17
18 protected function getTypeString()
19 {
20 return "pie";
21 }
22
28 public function setLineWidth($a_value)
29 {
30 $this->line_width = (int)$a_value;
31 }
32
38 public function getLineWidth()
39 {
40 return $this->line_width;
41 }
42
51 public function setLabelRadius($a_value)
52 {
53 $this->label_radius = $a_value;
54 }
55
59 public function getLabelRadius()
60 {
62 }
63
64 public function addPoint($a_value, $a_caption = null)
65 {
66 $this->data[] = array($a_value, $a_caption);
67 }
68
69 public function parseData(array &$a_data)
70 {
71 foreach($this->data as $slice)
72 {
73 $series = new stdClass();
74 $series->label = str_replace("\"", "\\\"", $slice[1]);
75
76 // add percentage to legend
77 if(!$this->getLabelRadius())
78 {
79 $series->label .= " (".$slice[0]."%)";
80 }
81
82 $series->data = $slice[0];
83
84 $options = array("show"=>($this->isHidden() ? false : true));
85
86 $series->{$this->getTypeString()} = $options;
87
88 $a_data[] = $series;
89 }
90 }
91
92 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
93 {
94 $a_options->series->pie = new stdClass();
95 $a_options->series->pie->show = true;
96
97 // fill vs. stroke - trying to normalize data attributes
98
99 $fill = $this->getFill();
100 $width = $this->getLineWidth();
101 if($fill["fill"] || $width)
102 {
103 $a_options->series->pie->stroke = new stdClass;
104 if($width)
105 {
106 $a_options->series->pie->stroke->width = $width;
107 }
108 if($fill["color"])
109 {
110 $a_options->series->pie->stroke->color = ilChart::renderColor($fill["color"], $fill["fill"]);
111 }
112 }
113
114 $radius = $this->getLabelRadius();
115 if ($radius)
116 {
117 $a_options->series->pie->label = new stdClass;
118 $a_options->series->pie->label->background = new stdClass;
119 $a_options->series->pie->radius = 1;
120 $a_options->series->pie->label->radius = $radius;
121 $a_options->series->pie->label->show = true;
122 $a_options->series->pie->label->background->color = "#444";
123 $a_options->series->pie->label->background->opacity = 0.8;
124 }
125 }
126}
127
128?>
Chart data pie series.
getTypeString()
Get series type.
parseData(array &$a_data)
Convert data to flot config.
parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
Convert (global) properties to flot config.
setLabelRadius($a_value)
Sets the radius at which to place the labels.
getLineWidth()
Get line width.
setLineWidth($a_value)
Set line width.
addPoint($a_value, $a_caption=null)
Set data.
Abstract chart data series base class.
isHidden()
Is hidden?
Abstract Chart generator base class.
static renderColor($a_value, $a_opacity=1)
Render html color code.
if(!is_array($argv)) $options