ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $series = new stdClass();
73 $series->label = str_replace("\"", "\\\"", $slice[1]);
74
75 // add percentage to legend
76 if (!$this->getLabelRadius()) {
77 $series->label .= " (" . $slice[0] . "%)";
78 }
79
80 $series->data = $slice[0];
81
82 $options = array("show" => ($this->isHidden() ? false : true));
83
84 $series->{$this->getTypeString()} = $options;
85
86 $a_data[] = $series;
87 }
88 }
89
90 public function parseGlobalOptions(stdClass $a_options, ilChart $a_chart)
91 {
92 $a_options->series->pie = new stdClass();
93 $a_options->series->pie->show = true;
94
95 // fill vs. stroke - trying to normalize data attributes
96
97 $fill = $this->getFill();
98 $width = $this->getLineWidth();
99 if ($fill["fill"] || $width) {
100 $a_options->series->pie->stroke = new stdClass;
101 if ($width) {
102 $a_options->series->pie->stroke->width = $width;
103 }
104 if ($fill["color"]) {
105 $a_options->series->pie->stroke->color = ilChart::renderColor($fill["color"], $fill["fill"]);
106 }
107 }
108
109 $radius = $this->getLabelRadius();
110 if ($radius) {
111 $a_options->series->pie->label = new stdClass;
112 $a_options->series->pie->label->background = new stdClass;
113 $a_options->series->pie->radius = 1;
114 $a_options->series->pie->label->radius = $radius;
115 $a_options->series->pie->label->show = true;
116 $a_options->series->pie->label->background->color = "#444";
117 $a_options->series->pie->label->background->opacity = 0.8;
118 }
119 }
120}
An exception for terminatinating execution or to throw for unit testing.
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.
$this data['403_header']