ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
PHPlot_Data Class Reference
+ Inheritance diagram for PHPlot_Data:
+ Collaboration diagram for PHPlot_Data:

Public Member Functions

 PHPlot_Data ($which_width=600, $which_height=400, $which_output_file=NULL, $which_input_file=NULL)
 
 DoScaleData ($even, $show_in_legend)
 
 DoMovingAverage ($datarow, $interval, $show=TRUE, $color=NULL, $width=NULL)
 
 DoExponentialMovingAverage ($datarow, $perc, $show_in_legend)
 Computes an exponentially smoothed moving average. More...
 
 DoRemoveDataSet ($index)
 
 DoDivision ($x, $y)
 
- Public Member Functions inherited from PHPlot
 PHPlot ($which_width=600, $which_height=400, $which_output_file=NULL, $which_input_file=NULL)
 
 GetImage ($image_filename, &$width, &$height)
 
 SetInputFile ($which_input_file)
 
 SetIndexColor ($which_color)
 
 SetIndexDarkColor ($which_color)
 
 SetDefaultStyles ()
 
 SetBackgroundColor ($which_color)
 
 SetPlotBgColor ($which_color)
 
 SetTitleColor ($which_color)
 
 SetTickColor ($which_color)
 
 SetLabelColor ($which_color)
 
 SetTextColor ($which_color)
 
 SetLightGridColor ($which_color)
 
 SetGridColor ($which_color)
 
 SetImageBorderColor ($which_color)
 
 SetTransparentColor ($which_color)
 
 SetRGBArray ($which_color_array)
 
 SetRGBColor ($color_asked)
 
 SetDataColors ($which_data=NULL, $which_border=NULL)
 
 SetDataBorderColors ($which_br=NULL)
 
 SetErrorBarColors ($which_err=NULL)
 
 SetDefaultDashedStyle ($which_style)
 
 SetDashedStyle ($which_ndxcol)
 
 SetLineWidths ($which_lw=NULL)
 
 SetLineStyles ($which_ls=NULL)
 
 SetLineSpacing ($which_spc)
 
 SetUseTTF ($which_ttf)
 
 SetTTFPath ($which_path)
 
 SetDefaultTTFont ($which_font)
 
 SetDefaultFonts ()
 
 SetFont ($which_elem, $which_font, $which_size=12)
 
 ProcessTextGD ($draw_it, $font_number, $font_width, $font_height, $angle, $x, $y, $color, $text, $h_factor, $v_factor)
 
 ProcessTextTTF ($draw_it, $font_file, $font_size, $angle, $x, $y, $color, $text, $h_factor, $v_factor)
 
 ProcessText ($draw_it, $font, $angle, $x, $y, $color, $text, $halign, $valign)
 
 DrawText ($which_font, $which_angle, $which_xpos, $which_ypos, $which_color, $which_text, $which_halign='left', $which_valign='bottom')
 
 SizeText ($which_font, $which_angle, $which_text)
 
 SetFileFormat ($format)
 
 SetBgImage ($input_file, $mode='centeredtile')
 
 SetPlotAreaBgImage ($input_file, $mode='tile')
 
 SetOutputFile ($which_output_file)
 
 SetIsInline ($which_ii)
 
 PrintImage ()
 
 PrintError ($error_message)
 
 DrawError ($error_message, $where_x=NULL, $where_y=NULL)
 
 SetXDataLabelPos ($which_xdlp)
 
 SetYDataLabelPos ($which_ydlp, $which_distance_from_point=0)
 
 SetXTickLabelPos ($which_xtlp)
 
 SetYTickLabelPos ($which_ytlp)
 
 SetXLabelType ($which_xlt)
 
 SetYLabelType ($which_ylt)
 
 SetXTimeFormat ($which_xtf)
 
 SetYTimeFormat ($which_ytf)
 
 SetNumberFormat ($decimal_point, $thousands_sep)
 
 SetXLabelAngle ($which_xla)
 
 SetYLabelAngle ($which_yla)
 
 CheckOption ($which_opt, $which_acc, $which_func)
 
 SetBrowserCache ($which_browser_cache)
 
 SetPrintImage ($which_pi)
 
 SetLegend ($which_leg)
 
 SetLegendPixels ($which_x, $which_y)
 
 SetLegendWorld ($which_x, $which_y)
 
 SetLegendStyle ($text_align, $colorbox_align='', $style='')
 
 SetPlotBorderType ($pbt)
 
 SetImageBorderType ($sibt)
 
 SetDrawPlotAreaBackground ($dpab)
 
 SetDrawYGrid ($dyg)
 
 SetDrawXGrid ($dxg)
 
 SetDrawDashedGrid ($ddg)
 
 SetDrawXDataLabelLines ($dxdl)
 
 SetDrawYDataLabelLines ($dydl)
 
 SetTitle ($which_title)
 
 SetXTitle ($which_xtitle, $which_xpos='plotdown')
 
 SetYTitle ($which_ytitle, $which_ypos='plotleft')
 
 SetShading ($which_s)
 
 SetPlotType ($which_pt)
 
 SetYAxisPosition ($pos)
 
 SetXAxisPosition ($pos)
 
 SetXScaleType ($which_xst)
 
 SetYScaleType ($which_yst)
 
 SetPrecisionX ($which_prec)
 
 SetPrecisionY ($which_prec)
 
 SetErrorBarLineWidth ($which_seblw)
 
 SetLabelScalePosition ($which_blp)
 
 SetErrorBarSize ($which_ebs)
 
 SetErrorBarShape ($which_ebs)
 
 SetPointShapes ($which_pt)
 
 SetPointSizes ($which_ps)
 
 SetDrawBrokenLines ($bl)
 
 SetDataType ($which_dt)
 
 SetDataValues (&$which_dv)
 
 PadArrays ()
 
 pad_array (&$arr, $size)
 
 number_format ($number, $decimals=0)
 
 SetCallback ($reason, $function, $arg=NULL)
 
 GetCallback ($reason)
 
 RemoveCallback ($reason)
 
 DoCallback () # Note
 
 FindDataLimits ()
 
 CalcMargins ($maximize)
 
 CalcPlotAreaPixels ()
 
 SetMarginsPixels ($which_lm, $which_rm, $which_tm, $which_bm)
 
 SetPlotAreaPixels ($x1, $y1, $x2, $y2)
 
 CalcPlotAreaWorld ()
 
 SetPlotAreaWorld ($xmin=NULL, $ymin=NULL, $xmax=NULL, $ymax=NULL)
 
 CalcBarWidths ()
 
 CalcAxisPositions ()
 
 CalcTranslation ()
 
 xtr ($x_world)
 
 ytr ($y_world)
 
 CalcTicks ($which)
 
 CalcMaxTickLabelSize ($which)
 
 CalcMaxDataLabelSize ()
 
 FormatLabel ($which_pos, $which_lab)
 
 SetXTickIncrement ($which_ti='')
 
 SetYTickIncrement ($which_ti='')
 
 SetNumXTicks ($which_nt)
 
 SetNumYTicks ($which_nt)
 
 SetYTickPos ($which_tp)
 
 SetXTickPos ($which_tp)
 
 SetSkipTopTick ($skip)
 
 SetSkipBottomTick ($skip)
 
 SetSkipLeftTick ($skip)
 
 SetSkipRightTick ($skip)
 
 SetXTickLength ($which_xln)
 
 SetYTickLength ($which_yln)
 
 SetXTickCrossing ($which_xc)
 
 SetYTickCrossing ($which_yc)
 
 DrawBackground ()
 
 DrawPlotAreaBackground ()
 
 tile_img ($file, $xorig, $yorig, $width, $height, $mode)
 
 DrawImageBorder ()
 
 DrawTitle ()
 
 DrawXTitle ()
 
 DrawYTitle ()
 
 DrawYAxis ()
 
 DrawXAxis ()
 
 DrawYTick ($which_ylab, $which_ypix)
 
 DrawYTicks ()
 
 DrawXTick ($which_xlab, $which_xpix)
 
 DrawXTicks ()
 
 DrawPlotBorder ()
 
 DrawDataLabel ($which_font, $which_angle, $x_world, $y_world, $which_color, $which_text, $which_halign='center', $which_valign='bottom', $x_adjustment=0, $y_adjustment=0)
 
 DrawXDataLabel ($xlab, $xpos, $row=FALSE)
 
 DrawXDataLine ($xpos, $row)
 
 DrawLegend ()
 
 DrawAxisLegend ()
 
 DrawPieChart ()
 
 DrawDotsError ()
 
 DrawDots ()
 
 DrawThinBarLines ()
 
 DrawYErrorBar ($x_world, $y_world, $error_height, $error_bar_type, $color)
 
 DrawDot ($x_world, $y_world, $record, $color)
 
 DrawArea ()
 
 DrawLines ()
 
 DrawLinesError ()
 
 DrawSquared ()
 
 DrawBars ()
 
 DrawStackedBars ()
 
 DrawGraph ()
 
 SetDrawVertTicks ($which_dvt)
 
 SetDrawHorizTicks ($which_dht)
 
 SetNumHorizTicks ($n)
 
 SetNumVertTicks ($n)
 
 SetHorizTickIncrement ($inc)
 
 SetVertTickIncrement ($inc)
 
 SetVertTickPosition ($which_tp)
 
 SetHorizTickPosition ($which_tp)
 
 SetTitleFontSize ($which_size)
 
 SetAxisFontSize ($which_size)
 
 SetSmallFontSize ($which_size)
 
 SetXLabelFontSize ($which_size)
 
 SetYLabelFontSize ($which_size)
 
 SetXLabel ($which_xlab)
 
 SetYLabel ($which_ylab)
 
 SetTickLength ($which_tl)
 
 SetYGridLabelType ($which_yglt)
 
 SetXGridLabelType ($which_xglt)
 
 SetYGridLabelPos ($which_yglp)
 
 SetXGridLabelPos ($which_xglp)
 
 SetXTitlePos ($xpos)
 
 SetYTitlePos ($xpos)
 
 SetXDataLabelAngle ($which_xdla)
 
 SetDrawXDataLabels ($which_dxdl)
 
 SetNewPlotAreaPixels ($x1, $y1, $x2, $y2)
 
 SetColor ($which_color)
 
 SetLineWidth ($which_lw)
 
 SetPointShape ($which_pt)
 
 SetPointSize ($which_ps)
 

Additional Inherited Members

- Data Fields inherited from PHPlot
 $is_inline = FALSE
 
 $browser_cache = FALSE
 
 $safe_margin = 5
 
 $x_axis_position = ''
 
 $y_axis_position = ''
 
 $xscale_type = 'linear'
 
 $yscale_type = 'linear'
 
 $use_ttf = FALSE
 
 $ttf_path = '.'
 
 $default_ttfont = 'benjamingothic.ttf'
 
 $line_spacing = 4
 
 $x_label_angle = 0
 
 $y_label_angle = 0
 
 $file_format = 'png'
 
 $output_file = ''
 
 $data_type = 'text-data'
 
 $plot_type = 'linepoints'
 
 $label_scale_position = 0.5
 
 $group_frac_width = 0.7
 
 $bar_extra_space = 0.5
 
 $bar_width_adjust = 1
 
 $y_precision = 1
 
 $x_precision = 1
 
 $data_units_text = ''
 
 $title_txt = ''
 
 $x_title_txt = ''
 
 $x_title_pos = 'plotdown'
 
 $y_title_txt = ''
 
 $y_title_pos = 'plotleft'
 
 $x_tick_label_pos = 'plotdown'
 
 $y_tick_label_pos = 'plotleft'
 
 $x_data_label_pos = 'plotdown'
 
 $y_data_label_pos = 'plotleft'
 
 $draw_x_data_label_lines = FALSE
 
 $draw_y_data_label_lines = FALSE
 
 $x_label_type = ''
 
 $y_label_type = ''
 
 $x_time_format = '%H:%M:%S'
 
 $y_time_format = '%H:%M:%S'
 
 $legend = ''
 
 $x_tick_length = 5
 
 $y_tick_length = 5
 
 $x_tick_cross = 3
 
 $y_tick_cross = 3
 
 $x_tick_pos = 'plotdown'
 
 $y_tick_pos = 'plotleft'
 
 $num_x_ticks = ''
 
 $num_y_ticks = ''
 
 $x_tick_inc = ''
 
 $y_tick_inc = ''
 
 $skip_top_tick = FALSE
 
 $skip_bottom_tick = FALSE
 
 $skip_left_tick = FALSE
 
 $skip_right_tick = FALSE
 
 $draw_x_grid = FALSE
 
 $draw_y_grid = TRUE
 
 $dashed_grid = TRUE
 
 $grid_at_foreground = FALSE
 
 $color_array = 'small'
 
 $i_border = array(194, 194, 194)
 
 $plot_bg_color = 'white'
 
 $bg_color = 'white'
 
 $label_color = 'black'
 
 $text_color = 'black'
 
 $grid_color = 'black'
 
 $light_grid_color = 'gray'
 
 $tick_color = 'black'
 
 $title_color = 'black'
 
 $data_colors = array('SkyBlue', 'green', 'orange', 'blue', 'orange', 'red', 'violet', 'azure1')
 
 $error_bar_colors = array('SkyBlue', 'green', 'orange', 'blue', 'orange', 'red', 'violet', 'azure1')
 
 $data_border_colors = array('black')
 
 $line_widths = 1
 
 $line_styles = array('solid', 'solid', 'dashed')
 
 $dashed_style = '2-4'
 
 $point_sizes = array(5,5,3)
 
 $point_shapes = array('diamond')
 
 $error_bar_size = 5
 
 $error_bar_shape = 'tee'
 
 $error_bar_line_width = 1
 
 $plot_border_type = 'sides'
 
 $image_border_type = 'none'
 
 $shading = 5
 
 $draw_plot_area_background = FALSE
 
 $draw_broken_lines = FALSE
 
 $callbacks
 

Detailed Description

Definition at line 18 of file phplot_data.php.

Member Function Documentation

◆ DoDivision()

PHPlot_Data::DoDivision (   $x,
  $y 
)

Computes row x divided by row y, stores the result in row x and deletes row y

Definition at line 234 of file phplot_data.php.

References DoRemoveDataSet(), and PHPlot\DrawError().

235  {
236  $offset = 1;
237  if ($this->data_type == 'data-data') {
238  $offset++;
239  } elseif ($this->data_type != 'text-data') {
240  $this->DrawError('wrong data type!!');
241  return FALSE;
242  }
243 
244  $x += $offset; $y += $offset;
245  reset($this->data);
246  while (list($key, $val) = each($this->data)) {
247  if ($this->data[$key][$y] == 0) {
248  $this->data[$key][$x] = 0;
249  } else {
250  $this->data[$key][$x] /= $this->data[$key][$y];
251  }
252  }
253 
254  $this->DoRemoveDataSet($y-$offset);
255  } // function DoDivision
DoRemoveDataSet($index)
DrawError($error_message, $where_x=NULL, $where_y=NULL)
Definition: phplot.php:1541
+ Here is the call graph for this function:

◆ DoExponentialMovingAverage()

PHPlot_Data::DoExponentialMovingAverage (   $datarow,
  $perc,
  $show_in_legend 
)

Computes an exponentially smoothed moving average.

Parameters
intperc "smoothing percentage" FIXME!!! I haven't checked this.

Definition at line 178 of file phplot_data.php.

References PHPlot\DrawError().

179  {
180  if ($this->data_type == 'text-data') {
181  $datarow++;
182  } elseif ($this->data_type != 'data-data') {
183  $this->DrawError('DoWeightedMovingAverage(): wrong data type!!');
184  return FALSE;
185  }
186 
187  if ($show_in_legend) {
188  $this->legend[$datarow] .= " (MA: $interval)";
189  }
190 
191  $storage[0] = $this->data[0][$datarow];
192  for ($i=1;$i < $this->num_data_rows; $i++) {
193  $storage[$i] = @ $storage[$i-1] + $perc * ($this->data[$i][$datarow] - $storage[$i-1]);
194  $ma = array_sum($storage);
195  $ma /= count($storage);
196  $this->data[$i][$datarow] = $ma;
197  }
198  return TRUE;
199  } // function DoExponentialMovingAverage()
DrawError($error_message, $where_x=NULL, $where_y=NULL)
Definition: phplot.php:1541
+ Here is the call graph for this function:

◆ DoMovingAverage()

PHPlot_Data::DoMovingAverage (   $datarow,
  $interval,
  $show = TRUE,
  $color = NULL,
  $width = NULL 
)

Computes a moving average of strength $interval for data row number $datarow, where 0 denotes the first row of y-data.

Parameters
intdatarow Index of the row whereupon to make calculations
intinterval Number of elements to use in average ("strength")
boolshow Whether to tell about the moving average in the legend.
stringcolor Color for the line to be drawn. This color is darkened. Can be named or #RRGGBB.
intwidth Width of the line to be drawn.
Note
Original idea by Theimo Nagel

Definition at line 117 of file phplot_data.php.

References PHPlot\DrawError(), PHPlot\PadArrays(), and PHPlot\SetIndexDarkColor().

118  {
119  $off = 1; // Skip record #0 (data label)
120 
121  $this->PadArrays();
122 
123  if ($interval == 0) {
124  $this->DrawError('DoMovingAverage(): interval can\'t be 0');
125  return FALSE;
126  }
127 
128  if ($datarow >= $this->records_per_group) {
129  $this->DrawError("DoMovingAverage(): Data row out of bounds ($datarow >= $this->records_per_group)");
130  return FALSE;
131  }
132 
133  if ($this->data_type == 'text-data') {
134  // Ok. No need to set the offset to skip more records.
135  } elseif ($this->data_type == 'data-data') {
136  $off++; // first Y value at $data[][2]
137  } else {
138  $this->DrawError('DoMovingAverage(): wrong data type!!');
139  return FALSE;
140  }
141 
142  // Set color:
143  if ($color) {
144  array_push($this->ndx_data_colors, $this->SetIndexDarkColor($color));
145  } else {
146  array_push($this->ndx_data_colors, $this->SetIndexDarkColor($this->data_colors[$datarow]));
147  }
148  // Set line width:
149  if ($width) {
150  array_push($this->line_widths, $width);
151  } else {
152  array_push($this->line_widths, $this->line_widths[$datarow] * 2);
153  }
154  // Show in legend?
155  if ($show) {
156  $this->legend[$this->records_per_group-1] = "(MA[$datarow]:$interval)";
157  }
158 
159  $datarow += $off;
160  for ($i = 0; $i < $this->num_data_rows; $i++) {
161  $storage[$i % $interval] = @ $this->data[$i][$datarow];
162  $ma = array_sum($storage);
163  $ma /= count($storage);
164  array_push($this->data[$i], $ma); // Push the data onto the array
165  $this->num_recs[$i]++; // Tell the drawing functions it is there
166  }
167  $this->records_per_group++;
168 // $this->FindDataLimits();
169  return TRUE;
170  } //function DoMovingAverage()
DrawError($error_message, $where_x=NULL, $where_y=NULL)
Definition: phplot.php:1541
PadArrays()
Definition: phplot.php:2126
SetIndexDarkColor($which_color)
Definition: phplot.php:329
+ Here is the call graph for this function:

◆ DoRemoveDataSet()

PHPlot_Data::DoRemoveDataSet (   $index)

Removes the DataSet of number $index

Definition at line 205 of file phplot_data.php.

References PHPlot\DrawError().

Referenced by DoDivision().

206  {
207  $offset = 1;
208  if ($this->data_type == 'data-data') {
209  $offset++;
210  } elseif ($this->data_type != 'text-data') {
211  $this->DrawError('wrong data type!!');
212  return FALSE;
213  }
214 
215  $index += $offset;
216  foreach ($this->data as $key=>$val) {
217  foreach ($val as $key2=>$val2) {
218  if ($key2 >= $index) {
219  if (isset($this->data[$key][$key2+1])) {
220  $this->data[$key][$key2] = $this->data[$key][$key2+1];
221  } else {
222  unset($this->data[$key][$key2]);
223  }
224  }
225  }
226  }
227  } // function DoRemoveDataSet
DrawError($error_message, $where_x=NULL, $where_y=NULL)
Definition: phplot.php:1541
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoScaleData()

PHPlot_Data::DoScaleData (   $even,
  $show_in_legend 
)

Will scale all data rows Maybe later I will do a function that only scales some rows if $even is TRUE, data will be scaled with "even" factors.

Note
Original code by Thiemo Nagel

Definition at line 36 of file phplot_data.php.

References PHPlot\DrawError(), and PHPlot\SetYTickIncrement().

37  {
38  $offset = 0; // We use this not to read labels in text-data
39 
40  if ($this->data_type == 'text-data') {
41  $offset = 1;
42  } elseif ($this->data_type != 'data-data') {
43  $this->DrawError('wrong data type!!');
44  return FALSE;
45  }
46 
47  // Determine maxima for each data row in array $max
48  // Put maximum of the maxima in $maxmax
49  $maxmax = 0;
50  for($i=0; $i < $this->num_data_rows; $i++) {
51  $rowsize = count($this->data[$i]);
52  for ($j=$offset; $j < $rowsize; $j++) {
53  if ($this->data[$i][$j] > @ $max[$j])
54  $max[$j] = $this->data[$i][$j];
55  if (@ $max[$j] > $maxmax)
56  $maxmax = $max[$j];
57  }
58  }
59 
60  // determine amplification factor $amplify
61  $end = count($max) + $offset;
62  for ($i=$offset; $i < $end; $i++) {
63  if ($max[$i] == 0 || $max[$i] == $maxmax) {
64  $amplify[$i] = 1; // no divide by zero
65  } else {
66  if ($even) {
67  $amp = pow(10,round(log10($maxmax / $max[$i]))-1);
68  if ($amp * $max[$i] * 5 < $maxmax) {
69  $amp *= 5;
70  } elseif ($amp * $max[$i] * 2 < $maxmax) {
71  $amp *= 2;
72  }
73  } else {
74  $amp = $maxmax / $max[$i];
75  $digits = floor(log10($amp));
76  $amp = round($amp/pow(10,$digits-1))*pow(10,$digits-1);
77  }
78  $amplify[$i] = $amp;
79  }
80  if ($amplify[$i] != 1 && $show_in_legend)
81  @ $this->legend[$i] .= "*$amplify[$i]";
82  }
83 
84  // Amplify data
85  // On my machine, running 1000 iterations over 1000 rows of 12 elements each,
86  // the for loops were 43.2% faster (MBD)
87  for ($i = 0; $i < $this->num_data_rows; $i++) {
88  $rowsize = count($this->data[$i]);
89  for ($j=$offset; $j < $rowsize; $j++) {
90  $this->data[$i][$j] *= $amplify[$j];
91  }
92  }
93 
94  //Re-Scale Vertical Ticks if not already set
95  if ( ! $this->y_tick_increment) {
96  $this->SetYTickIncrement() ;
97  }
98 
99  return TRUE;
100  } //function DoScaleData
DrawError($error_message, $where_x=NULL, $where_y=NULL)
Definition: phplot.php:1541
SetYTickIncrement($which_ti='')
Definition: phplot.php:3128
+ Here is the call graph for this function:

◆ PHPlot_Data()

PHPlot_Data::PHPlot_Data (   $which_width = 600,
  $which_height = 400,
  $which_output_file = NULL,
  $which_input_file = NULL 
)

Constructor

Definition at line 23 of file phplot_data.php.

References PHPlot\PHPlot().

24  {
25  if (! isset($this->img)) {
26  $this->PHPlot($which_width, $which_height, $which_output_file, $which_input_file);
27  }
28  }
PHPlot($which_width=600, $which_height=400, $which_output_file=NULL, $which_input_file=NULL)
Definition: phplot.php:212
+ Here is the call graph for this function:

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