ILIAS  release_8 Revision v8.24
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 20 of file class.ilChartDataPie.php.

Member Function Documentation

◆ addPiePoint()

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

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

55 : void
56 {
57 $this->data[] = array($a_value, $a_caption);
58 }

◆ getLabelRadius()

ilChartDataPie::getLabelRadius ( )

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

50 : float
51 {
53 }

References $label_radius.

Referenced by parseData().

+ Here is the caller graph for this function:

◆ getLineWidth()

ilChartDataPie::getLineWidth ( )

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

35 : int
36 {
37 return $this->line_width;
38 }

References $line_width.

◆ getTypeString()

ilChartDataPie::getTypeString ( )
protected

Reimplemented from ilChartData.

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

25 : string
26 {
27 return "pie";
28 }

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 60 of file class.ilChartDataPie.php.

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

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 81 of file class.ilChartDataPie.php.

81 : void
82 {
83 $a_options->series->pie = new stdClass();
84 $a_options->series->pie->show = true;
85
86 // fill vs. stroke - trying to normalize data attributes
87
88 $fill = $this->getFill();
89 $width = $this->getLineWidth();
90 if ($fill["fill"] || $width) {
91 $a_options->series->pie->stroke = new stdClass();
92 if ($width) {
93 $a_options->series->pie->stroke->width = $width;
94 }
95 if ($fill["color"]) {
96 $a_options->series->pie->stroke->color = ilChart::renderColor($fill["color"], $fill["fill"]);
97 }
98 }
99
100 $radius = $this->getLabelRadius();
101 if ($radius) {
102 $a_options->series->pie->label = new stdClass();
103 $a_options->series->pie->label->background = new stdClass();
104 $a_options->series->pie->radius = 1;
105 $a_options->series->pie->label->radius = $radius;
106 $a_options->series->pie->label->show = true;
107 $a_options->series->pie->label->background->color = "#444";
108 $a_options->series->pie->label->background->opacity = 0.8;
109 }
110 }
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 45 of file class.ilChartDataPie.php.

45 : void
46 {
47 $this->label_radius = $a_value;
48 }

◆ setLineWidth()

ilChartDataPie::setLineWidth ( int  $a_value)

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

30 : void
31 {
32 $this->line_width = $a_value;
33 }

Field Documentation

◆ $label_radius

float ilChartDataPie::$label_radius = 0
protected

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

Referenced by getLabelRadius().

◆ $line_width

int ilChartDataPie::$line_width = 0
protected

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

Referenced by getLineWidth().


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