3.8. Extra Data Processing

Abstract

This section describes some additional data processing functions which are not part of main PHPlot module but can be used with PHPlot to perform additional operations on your application data.

To use the functions described in this section, instead of including the main phplot.php source file, you instead include the phplot_data.php file. In addition, when creating your PHPlot object, use the extended class PHPlot_data.

require_once 'phplot_data.php';
$plot = new PHPlot_Data(...);

Note

These functions should be considered experimental and subject to change. For that reason, they are documented here instead of in the Reference chapter.

3.8.1. DoScaleData()

$plot->DoScaleData($even, $show_in_legend)

This function scales values in the data array so that multiple data sets with different maximum values can be plotted together. A separate scale factor is calculated for each data set to make the maximum value less than the maximum for all data sets.

If $even is True, the scale factors chosen will be a multiple of 1, 2, or 5 times a power of 10. Otherwise, the scale factors will be not be constrained.

If $show_in_legend is True, the scale factor chosen for each data set will be appended to the legend for that data set. This lets you see what scale factor was used for the data. To use this, you must set the legend before calling DoScaleData.

This function only works with 'text-data' data type.

3.8.2. DoMovingAverage()

$plot->DoMovingAverage($datarow, $interval, [$show], [$color], [$width])

This function computes a moving average over a data set, and adds a new data set to the plot data for the moving average.

Parameter $datarow selects the data set over which to compute the moving average. For example, if the data array is of type 'data-data' and contains records with ('label', X, Y0, Y1, Y2), then $datarow=1 computes the moving average over the Y1 data set.

Parameter $interval selects the number of points involved in the moving average. For example, if $interval=3 then a moving average of 3 values will be computed.

If $show is True, information about the moving average will be appended to the legend. The default is True.

Parameter $color gives the color of the new line drawn for the moving average. The actual color used is a darker shade of the color selected. If this parameter is omitted or NULL, a darker shade of the line being averaged is used.

Parameter $width is the width of the moving average line to be plotted, in pixels. The default value is the width of the line being averaged.