ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilChartDataPie Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilChartDataPie:
+ Collaboration diagram for ilChartDataPie:

Public Member Functions

 setLineWidth (int $a_value)
 
 getLineWidth ()
 
 setLabelRadius (float $a_value)
 Sets the radius at which to place the labels. More...
 
 getLabelRadius ()
 
 addPiePoint (int $a_value, ?string $a_caption=null)
 
 parseData (array &$a_data)
 Convert data to flot config. More...
 
 parseGlobalOptions (stdClass $a_options, ilChart $a_chart)
 Convert (global) properties to flot config. More...
 
- Public Member Functions inherited from ilChartData
 setHidden (bool $a_value)
 
 isHidden ()
 
 setLabel (string $a_value)
 
 getLabel ()
 
 addPoint (float $a_x, ?float $a_y=null)
 Set data. More...
 
 getData ()
 Get data. More...
 
 setFill (float $a_value, string $a_color="")
 
 getFill ()
 
 parseData (array &$a_data)
 Convert data to flot config. More...
 
 parseGlobalOptions (stdClass $a_options, ilChart $a_chart)
 Convert (global) properties to flot config. More...
 

Protected Member Functions

 getTypeString ()
 
- Protected Member Functions inherited from ilChartData
 getTypeString ()
 
 parseDataOptions (array &$a_options)
 Convert data options to flot config. More...
 

Protected Attributes

int $line_width = 0
 
float $label_radius = 0
 
- Protected Attributes inherited from ilChartData
string $type = ""
 
string $label = ""
 
array $data = []
 
float $fill = 0
 
string $fill_color = ""
 
bool $hidden = false
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Chart data pie series

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 23 of file class.ilChartDataPie.php.

Member Function Documentation

◆ addPiePoint()

ilChartDataPie::addPiePoint ( int  $a_value,
?string  $a_caption = null 
)

Definition at line 58 of file class.ilChartDataPie.php.

58 : void
59 {
60 $this->data[] = array($a_value, $a_caption);
61 }

◆ getLabelRadius()

ilChartDataPie::getLabelRadius ( )

Definition at line 53 of file class.ilChartDataPie.php.

53 : float
54 {
56 }

References $label_radius.

Referenced by parseData().

+ Here is the caller graph for this function:

◆ getLineWidth()

ilChartDataPie::getLineWidth ( )

Definition at line 38 of file class.ilChartDataPie.php.

38 : int
39 {
40 return $this->line_width;
41 }

References $line_width.

◆ getTypeString()

ilChartDataPie::getTypeString ( )
protected

Reimplemented from ilChartData.

Definition at line 28 of file class.ilChartDataPie.php.

28 : string
29 {
30 return "pie";
31 }

Referenced by parseData().

+ Here is the caller graph for this function:

◆ parseData()

ilChartDataPie::parseData ( array &  $a_data)

Convert data to flot config.

Reimplemented from ilChartData.

Definition at line 63 of file class.ilChartDataPie.php.

63 : void
64 {
65 foreach ($this->data as $slice) {
66 $series = new stdClass();
67 $series->label = str_replace("\"", "\\\"", $slice[1]);
68
69 // add percentage to legend
70 if (!$this->getLabelRadius()) {
71 $series->label .= " (" . $slice[0] . "%)";
72 }
73
74 $series->data = $slice[0];
75
76 $options = array("show" => !$this->isHidden());
77
78 $series->{$this->getTypeString()} = $options;
79
80 $a_data[] = $series;
81 }
82 }

References getLabelRadius(), getTypeString(), and ilChartData\isHidden().

+ Here is the call graph for this function:

◆ parseGlobalOptions()

ilChartDataPie::parseGlobalOptions ( stdClass  $a_options,
ilChart  $a_chart 
)

Convert (global) properties to flot config.

Reimplemented from ilChartData.

Definition at line 84 of file class.ilChartDataPie.php.

84 : void
85 {
86 $a_options->series->pie = new stdClass();
87 $a_options->series->pie->show = true;
88
89 // fill vs. stroke - trying to normalize data attributes
90
91 $fill = $this->getFill();
92 $width = $this->getLineWidth();
93 if ($fill["fill"] || $width) {
94 $a_options->series->pie->stroke = new stdClass();
95 if ($width) {
96 $a_options->series->pie->stroke->width = $width;
97 }
98 if ($fill["color"]) {
99 $a_options->series->pie->stroke->color = ilChart::renderColor($fill["color"], $fill["fill"]);
100 }
101 }
102
103 $radius = $this->getLabelRadius();
104 if ($radius) {
105 $a_options->series->pie->label = new stdClass();
106 $a_options->series->pie->label->background = new stdClass();
107 $a_options->series->pie->radius = 1;
108 $a_options->series->pie->label->radius = $radius;
109 $a_options->series->pie->label->show = true;
110 $a_options->series->pie->label->background->color = "#444";
111 $a_options->series->pie->label->background->opacity = 0.8;
112 }
113 }
static renderColor(string $a_value, float $a_opacity=1)
Render html color code.

References ilChart\renderColor().

+ Here is the call graph for this function:

◆ setLabelRadius()

ilChartDataPie::setLabelRadius ( float  $a_value)

Sets the radius at which to place the labels.

If value is between 0 and 1 (inclusive) then it will use that as a percentage of the available space (size of the container), otherwise it will use the value as a direct pixel length.

Definition at line 48 of file class.ilChartDataPie.php.

48 : void
49 {
50 $this->label_radius = $a_value;
51 }

◆ setLineWidth()

ilChartDataPie::setLineWidth ( int  $a_value)

Definition at line 33 of file class.ilChartDataPie.php.

33 : void
34 {
35 $this->line_width = $a_value;
36 }

Field Documentation

◆ $label_radius

float ilChartDataPie::$label_radius = 0
protected

Definition at line 26 of file class.ilChartDataPie.php.

Referenced by getLabelRadius().

◆ $line_width

int ilChartDataPie::$line_width = 0
protected

Definition at line 25 of file class.ilChartDataPie.php.

Referenced by getLineWidth().


The documentation for this class was generated from the following file: