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

Generator for grid-based charts. More...

+ Inheritance diagram for ilChartGrid:
+ Collaboration diagram for ilChartGrid:

Public Member Functions

 getDataInstance ($a_type=null)
 Get data series instance. More...
 
 setTicks ($a_x, $a_y, $a_labeled=false)
 Set ticks. More...
 
 getTicks ()
 Get ticks. More...
 
 setYAxisToInteger ($a_status)
 Restrict y-axis to integer values. More...
 
 setXAxisToInteger ($a_status)
 Restrict x-axis to integer values. More...
 
 parseGlobalOptions (stdClass $a_options)
 Convert (global) properties to flot config. More...
 
- Public Member Functions inherited from ilChart
 getDataInstance ($a_type=null)
 Get data series instance. More...
 
 setSize ($a_x, $a_y)
 Set chart size. More...
 
 addData (ilChartData $a_series, $a_idx=null)
 Add data series. More...
 
 setLegend (ilChartLegend $a_legend)
 Set chart legend. More...
 
 setColors ($a_values)
 Set colors. More...
 
 getColors ()
 Get colors. More...
 
 setShadow ($a_value)
 Set shadow. More...
 
 getShadow ()
 Get shadow. More...
 
 setAutoResize ($a_value)
 Toggle auto-resizing on window resize/redraw. More...
 
 setStacked ($a_value)
 Toggle stacking. More...
 
 parseGlobalOptions (stdClass $a_options)
 Convert (global) properties to flot config. More...
 
 getHTML ()
 Render. More...
 

Data Fields

const DATA_LINES = 1
 
const DATA_BARS = 2
 
const DATA_POINTS = 3
 
- Data Fields inherited from ilChart
const TYPE_GRID = 1
 
const TYPE_PIE = 2
 
const TYPE_SPIDER = 3
 

Protected Member Functions

 __construct ($a_id)
 Constructor. More...
 
 isValidDataType (ilChartData $a_series)
 Validate data series. More...
 
- Protected Member Functions inherited from ilChart
 __construct ($a_id)
 Constructor. More...
 
 isValidDataType (ilChartData $a_series)
 Validate data series. More...
 
 isValid ()
 Basic validation. More...
 
 initJS ()
 Init JS script files. More...
 
 addCustomJS ()
 Add type-specific JS script. More...
 

Protected Attributes

 $ticks
 
 $integer_axis
 
- Protected Attributes inherited from ilChart
 $tpl
 
 $id
 
 $width
 
 $height
 
 $data
 
 $legend
 
 $shadow
 
 $colors
 
 $auto_resize
 
 $stacked
 

Additional Inherited Members

- Static Public Member Functions inherited from ilChart
static getInstanceByType ($a_type, $a_id)
 Get type instance. More...
 
static isValidColor ($a_value)
 Validate html color code. More...
 
static renderColor ($a_value, $a_opacity=1)
 Render html color code. More...
 

Detailed Description

Generator for grid-based charts.

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.ilChartGrid.php.

Constructor & Destructor Documentation

◆ __construct()

ilChartGrid::__construct (   $a_id)
protected

Constructor.

Parameters
string$a_id

Reimplemented from ilChart.

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

23 {
24 parent::__construct($a_id);
25
26 $this->setXAxisToInteger(false);
27 $this->setYAxisToInteger(false);
28 }
setYAxisToInteger($a_status)
Restrict y-axis to integer values.
setXAxisToInteger($a_status)
Restrict x-axis to integer values.

References setXAxisToInteger(), and setYAxisToInteger().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDataInstance()

ilChartGrid::getDataInstance (   $a_type = null)

Get data series instance.

Returns
ilChartData

Reimplemented from ilChart.

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

31 {
32 switch ($a_type) {
33 case self::DATA_BARS:
34 include_once "Services/Chart/classes/class.ilChartDataBars.php";
35 return new ilChartDataBars();
36
38 include_once "Services/Chart/classes/class.ilChartDataPoints.php";
39 return new ilChartDataPoints();
40
41 default:
43 include_once "Services/Chart/classes/class.ilChartDataLines.php";
44 return new ilChartDataLines();
45 }
46 }
Chart data bars series.
Chart data lines series.
Chart data points series.
$a_type
Definition: workflow.php:92

References $a_type, DATA_BARS, DATA_LINES, and DATA_POINTS.

◆ getTicks()

ilChartGrid::getTicks ( )

Get ticks.

Returns
array (x, y)

Definition at line 75 of file class.ilChartGrid.php.

76 {
77 return $this->ticks;
78 }

References $ticks.

Referenced by parseGlobalOptions().

+ Here is the caller graph for this function:

◆ isValidDataType()

ilChartGrid::isValidDataType ( ilChartData  $a_series)
protected

Validate data series.

Returns
bool

Reimplemented from ilChart.

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

49 {
50 if ($a_series instanceof ilChartDataLines
51 || $a_series instanceof ilChartDataBars
52 || $a_series instanceof ilChartDataPoints) {
53 return true;
54 }
55 return false;
56 }

◆ parseGlobalOptions()

ilChartGrid::parseGlobalOptions ( stdClass  $a_options)

Convert (global) properties to flot config.

Parameters
object$a_options

Reimplemented from ilChart.

Definition at line 100 of file class.ilChartGrid.php.

101 {
102 // axis/ticks
103 $tmp = array();
104 $ticks = $this->getTicks();
105 if ($ticks) {
106 $labeled = (bool) $ticks["labeled"];
107 unset($ticks["labeled"]);
108 foreach ($ticks as $axis => $def) {
109 if (is_numeric($def) || is_array($def)) {
110 $a_options->{$axis . "axis"} = new stdClass();
111 }
112 if (is_numeric($def)) {
113 $a_options->{$axis . "axis"}->ticks = $def;
114 } elseif (is_array($def)) {
115 $a_options->{$axis . "axis"}->ticks = array();
116 foreach ($def as $idx => $value) {
117 if ($labeled) {
118 $a_options->{$axis . "axis"}->ticks[] = array($idx, $value);
119 } else {
120 $a_options->{$axis . "axis"}->ticks[] = $value;
121 }
122 }
123 }
124 }
125 }
126
127 // optional: remove decimals
128 if ($this->integer_axis["x"] && !isset($a_options->xaxis)) {
129 $a_options->{"xaxis"} = new stdClass();
130 $a_options->{"xaxis"}->tickDecimals = 0;
131 }
132 if ($this->integer_axis["y"] && !isset($a_options->yaxis)) {
133 $a_options->{"yaxis"} = new stdClass();
134 $a_options->{"yaxis"}->tickDecimals = 0;
135 }
136 }
getTicks()
Get ticks.
$def
Definition: croninfo.php:21
$axis
Definition: showstats.php:64

References $axis, $def, $ticks, and getTicks().

+ Here is the call graph for this function:

◆ setTicks()

ilChartGrid::setTicks (   $a_x,
  $a_y,
  $a_labeled = false 
)

Set ticks.

Parameters
int | array$a_x
int | array$a_y
bool$a_labeled

Definition at line 65 of file class.ilChartGrid.php.

66 {
67 $this->ticks = array("x" => $a_x, "y" => $a_y, "labeled" => (bool) $a_labeled);
68 }

◆ setXAxisToInteger()

ilChartGrid::setXAxisToInteger (   $a_status)

Restrict x-axis to integer values.

Parameters
bool$a_status

Definition at line 95 of file class.ilChartGrid.php.

96 {
97 $this->integer_axis["x"] = (bool) $a_status;
98 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setYAxisToInteger()

ilChartGrid::setYAxisToInteger (   $a_status)

Restrict y-axis to integer values.

Parameters
bool$a_status

Definition at line 85 of file class.ilChartGrid.php.

86 {
87 $this->integer_axis["y"] = (bool) $a_status;
88 }

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $integer_axis

ilChartGrid::$integer_axis
protected

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

◆ $ticks

ilChartGrid::$ticks
protected

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

Referenced by getTicks(), and parseGlobalOptions().

◆ DATA_BARS

◆ DATA_LINES

◆ DATA_POINTS

const ilChartGrid::DATA_POINTS = 3

Definition at line 20 of file class.ilChartGrid.php.

Referenced by getDataInstance().


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