ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups 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.
 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

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().

{
$offset = 1;
if ($this->data_type == 'data-data') {
$offset++;
} elseif ($this->data_type != 'text-data') {
$this->DrawError('wrong data type!!');
return FALSE;
}
$x += $offset; $y += $offset;
reset($this->data);
while (list($key, $val) = each($this->data)) {
if ($this->data[$key][$y] == 0) {
$this->data[$key][$x] = 0;
} else {
$this->data[$key][$x] /= $this->data[$key][$y];
}
}
$this->DoRemoveDataSet($y-$offset);
} // function DoDivision

+ Here is the call graph for this function:

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().

{
if ($this->data_type == 'text-data') {
$datarow++;
} elseif ($this->data_type != 'data-data') {
$this->DrawError('DoWeightedMovingAverage(): wrong data type!!');
return FALSE;
}
if ($show_in_legend) {
$this->legend[$datarow] .= " (MA: $interval)";
}
$storage[0] = $this->data[0][$datarow];
for ($i=1;$i < $this->num_data_rows; $i++) {
$storage[$i] = @ $storage[$i-1] + $perc * ($this->data[$i][$datarow] - $storage[$i-1]);
$ma = array_sum($storage);
$ma /= count($storage);
$this->data[$i][$datarow] = $ma;
}
return TRUE;
} // function DoExponentialMovingAverage()

+ Here is the call graph for this function:

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().

{
$off = 1; // Skip record #0 (data label)
$this->PadArrays();
if ($interval == 0) {
$this->DrawError('DoMovingAverage(): interval can\'t be 0');
return FALSE;
}
if ($datarow >= $this->records_per_group) {
$this->DrawError("DoMovingAverage(): Data row out of bounds ($datarow >= $this->records_per_group)");
return FALSE;
}
if ($this->data_type == 'text-data') {
// Ok. No need to set the offset to skip more records.
} elseif ($this->data_type == 'data-data') {
$off++; // first Y value at $data[][2]
} else {
$this->DrawError('DoMovingAverage(): wrong data type!!');
return FALSE;
}
// Set color:
if ($color) {
array_push($this->ndx_data_colors, $this->SetIndexDarkColor($color));
} else {
array_push($this->ndx_data_colors, $this->SetIndexDarkColor($this->data_colors[$datarow]));
}
// Set line width:
if ($width) {
array_push($this->line_widths, $width);
} else {
array_push($this->line_widths, $this->line_widths[$datarow] * 2);
}
// Show in legend?
if ($show) {
$this->legend[$this->records_per_group-1] = "(MA[$datarow]:$interval)";
}
$datarow += $off;
for ($i = 0; $i < $this->num_data_rows; $i++) {
$storage[$i % $interval] = @ $this->data[$i][$datarow];
$ma = array_sum($storage);
$ma /= count($storage);
array_push($this->data[$i], $ma); // Push the data onto the array
$this->num_recs[$i]++; // Tell the drawing functions it is there
}
$this->records_per_group++;
// $this->FindDataLimits();
return TRUE;
} //function DoMovingAverage()

+ Here is the call graph for this function:

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().

{
$offset = 1;
if ($this->data_type == 'data-data') {
$offset++;
} elseif ($this->data_type != 'text-data') {
$this->DrawError('wrong data type!!');
return FALSE;
}
$index += $offset;
foreach ($this->data as $key=>$val) {
foreach ($val as $key2=>$val2) {
if ($key2 >= $index) {
if (isset($this->data[$key][$key2+1])) {
$this->data[$key][$key2] = $this->data[$key][$key2+1];
} else {
unset($this->data[$key][$key2]);
}
}
}
}
} // function DoRemoveDataSet

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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().

{
$offset = 0; // We use this not to read labels in text-data
if ($this->data_type == 'text-data') {
$offset = 1;
} elseif ($this->data_type != 'data-data') {
$this->DrawError('wrong data type!!');
return FALSE;
}
// Determine maxima for each data row in array $max
// Put maximum of the maxima in $maxmax
$maxmax = 0;
for($i=0; $i < $this->num_data_rows; $i++) {
$rowsize = count($this->data[$i]);
for ($j=$offset; $j < $rowsize; $j++) {
if ($this->data[$i][$j] > @ $max[$j])
$max[$j] = $this->data[$i][$j];
if (@ $max[$j] > $maxmax)
$maxmax = $max[$j];
}
}
// determine amplification factor $amplify
$end = count($max) + $offset;
for ($i=$offset; $i < $end; $i++) {
if ($max[$i] == 0 || $max[$i] == $maxmax) {
$amplify[$i] = 1; // no divide by zero
} else {
if ($even) {
$amp = pow(10,round(log10($maxmax / $max[$i]))-1);
if ($amp * $max[$i] * 5 < $maxmax) {
$amp *= 5;
} elseif ($amp * $max[$i] * 2 < $maxmax) {
$amp *= 2;
}
} else {
$amp = $maxmax / $max[$i];
$digits = floor(log10($amp));
$amp = round($amp/pow(10,$digits-1))*pow(10,$digits-1);
}
$amplify[$i] = $amp;
}
if ($amplify[$i] != 1 && $show_in_legend)
@ $this->legend[$i] .= "*$amplify[$i]";
}
// Amplify data
// On my machine, running 1000 iterations over 1000 rows of 12 elements each,
// the for loops were 43.2% faster (MBD)
for ($i = 0; $i < $this->num_data_rows; $i++) {
$rowsize = count($this->data[$i]);
for ($j=$offset; $j < $rowsize; $j++) {
$this->data[$i][$j] *= $amplify[$j];
}
}
//Re-Scale Vertical Ticks if not already set
if ( ! $this->y_tick_increment) {
$this->SetYTickIncrement() ;
}
return TRUE;
} //function DoScaleData

+ Here is the call graph for this function:

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().

{
if (! isset($this->img)) {
$this->PHPlot($which_width, $which_height, $which_output_file, $which_input_file);
}
}

+ Here is the call graph for this function:


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