16 require_once(
"phplot.php");
23 function PHPlot_Data($which_width=600, $which_height=400, $which_output_file=NULL, $which_input_file=NULL)
25 if (! isset($this->img)) {
26 $this->
PHPlot($which_width, $which_height, $which_output_file, $which_input_file);
40 if ($this->data_type ==
'text-data') {
42 }
elseif ($this->data_type !=
'data-data') {
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)
61 $end = count($max) + $offset;
62 for ($i=$offset; $i < $end; $i++) {
63 if ($max[$i] == 0 || $max[$i] == $maxmax) {
67 $amp = pow(10,round(log10($maxmax / $max[$i]))-1);
68 if ($amp * $max[$i] * 5 < $maxmax) {
70 }
elseif ($amp * $max[$i] * 2 < $maxmax) {
74 $amp = $maxmax / $max[$i];
75 $digits = floor(log10($amp));
76 $amp = round($amp/pow(10,$digits-1))*pow(10,$digits-1);
80 if ($amplify[$i] != 1 && $show_in_legend)
81 @ $this->legend[$i] .=
"*$amplify[$i]";
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];
95 if ( ! $this->y_tick_increment) {
123 if ($interval == 0) {
124 $this->
DrawError(
'DoMovingAverage(): interval can\'t be 0');
128 if ($datarow >= $this->records_per_group) {
129 $this->
DrawError(
"DoMovingAverage(): Data row out of bounds ($datarow >= $this->records_per_group)");
133 if ($this->data_type ==
'text-data') {
135 }
elseif ($this->data_type ==
'data-data') {
138 $this->
DrawError(
'DoMovingAverage(): wrong data type!!');
146 array_push($this->ndx_data_colors, $this->
SetIndexDarkColor($this->data_colors[$datarow]));
150 array_push($this->line_widths, $width);
152 array_push($this->line_widths, $this->line_widths[$datarow] * 2);
156 $this->legend[$this->records_per_group-1] =
"(MA[$datarow]:$interval)";
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);
165 $this->num_recs[$i]++;
167 $this->records_per_group++;
180 if ($this->data_type ==
'text-data') {
182 }
elseif ($this->data_type !=
'data-data') {
183 $this->
DrawError(
'DoWeightedMovingAverage(): wrong data type!!');
187 if ($show_in_legend) {
188 $this->legend[$datarow] .=
" (MA: $interval)";
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;
208 if ($this->data_type ==
'data-data') {
210 }
elseif ($this->data_type !=
'text-data') {
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];
222 unset($this->data[
$key][$key2]);
237 if ($this->data_type ==
'data-data') {
239 }
elseif ($this->data_type !=
'text-data') {
244 $x += $offset;
$y += $offset;
246 while (list(
$key, $val) = each($this->data)) {
247 if ($this->data[
$key][
$y] == 0) {
248 $this->data[
$key][
$x] = 0;