ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilChartDataPie Class Reference

Chart data pie series. More...

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

Public Member Functions

 setLineWidth ($a_value)
 Set line width. More...
 
 getLineWidth ()
 Get line width. More...
 
 setLabelRadius ($a_value)
 Sets the radius at which to place the labels. More...
 
 getLabelRadius ()
 
 addPoint ($a_value, $a_caption=null)
 
 parseData (array &$a_data)
 
 parseGlobalOptions (stdClass $a_options, ilChart $a_chart)
 
- Public Member Functions inherited from ilChartData
 setHidden ($a_value)
 Set hidden. More...
 
 isHidden ()
 Is hidden? More...
 
 setLabel ($a_value)
 Set label. More...
 
 getLabel ()
 Get label. More...
 
 addPoint ($a_x, $a_y=null)
 Set data. More...
 
 getData ()
 Get data. More...
 
 setFill ($a_value, $a_color=null)
 Set fill. More...
 
 getFill ()
 Get fill. More...
 
 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 ()
 Get series type. More...
 
 parseDataOptions (array &$a_options)
 Convert data options to flot config. More...
 

Protected Attributes

 $line_width
 
 $label_radius
 
- Protected Attributes inherited from ilChartData
 $type
 
 $label
 
 $data
 
 $fill
 
 $fill_color
 
 $hidden
 

Detailed Description

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
Version
$Id$

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

Member Function Documentation

◆ addPoint()

ilChartDataPie::addPoint (   $a_value,
  $a_caption = null 
)

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

References array, and data.

65  {
66  $this->data[] = array($a_value, $a_caption);
67  }
Add some data
Create styles array
The data for the language used.

◆ getLabelRadius()

ilChartDataPie::getLabelRadius ( )
Returns
mixed

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

References $label_radius.

Referenced by parseData(), and parseGlobalOptions().

60  {
61  return $this->label_radius;
62  }
+ Here is the caller graph for this function:

◆ getLineWidth()

ilChartDataPie::getLineWidth ( )

Get line width.

Returns
int

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

References $line_width.

Referenced by parseGlobalOptions().

39  {
40  return $this->line_width;
41  }
+ Here is the caller graph for this function:

◆ getTypeString()

ilChartDataPie::getTypeString ( )
protected

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

Referenced by parseData().

19  {
20  return "pie";
21  }
+ Here is the caller graph for this function:

◆ parseData()

ilChartDataPie::parseData ( array $a_data)

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

References $options, $series, array, data, getLabelRadius(), getTypeString(), and ilChartData\isHidden().

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  }
Add some data
isHidden()
Is hidden?
Create styles array
The data for the language used.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
+ Here is the call graph for this function:

◆ parseGlobalOptions()

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

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

References ilChartData\$fill, ilChartData\getFill(), getLabelRadius(), getLineWidth(), and ilChart\renderColor().

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  }
getFill()
Get fill.
static renderColor($a_value, $a_opacity=1)
Render html color code.
getLineWidth()
Get line width.
+ Here is the call graph for this function:

◆ setLabelRadius()

ilChartDataPie::setLabelRadius (   $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.

Parameters
mixed$a_value

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

52  {
53  $this->label_radius = $a_value;
54  }

◆ setLineWidth()

ilChartDataPie::setLineWidth (   $a_value)

Set line width.

Parameters
int$a_value

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

29  {
30  $this->line_width = (int) $a_value;
31  }

Field Documentation

◆ $label_radius

ilChartDataPie::$label_radius
protected

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

Referenced by getLabelRadius().

◆ $line_width

ilChartDataPie::$line_width
protected

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

Referenced by getLineWidth().


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