ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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)
 Set data. 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...
 
- 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 ()
 Get series type. More...
 
- 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_x,
  $a_y = null 
)

Set data.

Parameters
float$a_x
float$a_y

Reimplemented from ilChartData.

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

65 {
66 $this->data[] = array($a_value, $a_caption);
67 }

◆ getLabelRadius()

ilChartDataPie::getLabelRadius ( )
Returns
mixed

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

References $label_radius.

Referenced by parseData().

+ 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.

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

References $line_width.

◆ getTypeString()

ilChartDataPie::getTypeString ( )
protected

Get series type.

Returns
string

Reimplemented from ilChartData.

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

19 {
20 return "pie";
21 }

Referenced by parseData().

+ Here is the caller graph for this function:

◆ parseData()

ilChartDataPie::parseData ( array &  $a_data)

Convert data to flot config.

Parameters
array$a_data
Returns
object

Reimplemented from ilChartData.

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

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 }
getTypeString()
Get series type.
isHidden()
Is hidden?
if(!is_array($argv)) $options

References $options, 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.

Parameters
object$a_options
ilChart$a_chart

Reimplemented from ilChartData.

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

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 }
getLineWidth()
Get line width.
getFill()
Get fill.
static renderColor($a_value, $a_opacity=1)
Render html color code.

References ilChart\renderColor().

+ 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: