|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JPGraph v4.0.3 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Plot; |
|
8
|
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Util; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* File: JPGRAPH_ERROR.PHP |
|
13
|
|
|
* // Description: Error plot extension for JpGraph |
|
14
|
|
|
* // Created: 2001-01-08 |
|
15
|
|
|
* // Ver: $Id: jpgraph_error.php 1106 2009-02-22 20:16:35Z ljp $ |
|
16
|
|
|
* // |
|
17
|
|
|
* // Copyright (c) Asial Corporation. All rights reserved. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @class ErrorPlot |
|
22
|
|
|
* // Description: Error plot with min/max value for |
|
23
|
|
|
* // each datapoint |
|
24
|
|
|
*/ |
|
25
|
|
|
class ErrorPlot extends Plot |
|
26
|
|
|
{ |
|
27
|
|
|
private $errwidth = 2; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* CONSTRUCTOR. |
|
31
|
|
|
* |
|
32
|
|
|
* @param mixed $datay |
|
33
|
|
|
* @param mixed $datax |
|
34
|
|
|
*/ |
|
35
|
2 |
|
public function __construct($datay, $datax = false) |
|
36
|
|
|
{ |
|
37
|
2 |
|
parent::__construct($datay, $datax); |
|
38
|
2 |
|
$this->numpoints /= 2; |
|
39
|
2 |
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* PUBLIC METHODS. |
|
43
|
|
|
* |
|
44
|
|
|
* @param mixed $graph |
|
45
|
|
|
*/ |
|
46
|
|
|
// Gets called before any axis are stroked |
|
47
|
2 |
|
public function PreStrokeAdjust($graph) |
|
48
|
|
|
{ |
|
49
|
2 |
|
if ($this->center) { |
|
50
|
1 |
|
$a = 0.5; |
|
51
|
1 |
|
$b = 0.5; |
|
52
|
1 |
|
++$this->numpoints; |
|
53
|
|
|
} else { |
|
54
|
2 |
|
$a = 0; |
|
55
|
2 |
|
$b = 0; |
|
56
|
|
|
} |
|
57
|
2 |
|
$graph->xaxis->scale->ticks->SetXLabelOffset($a); |
|
58
|
2 |
|
$graph->SetTextScaleOff($b); |
|
59
|
|
|
//$graph->xaxis->scale->ticks->SupressMinorTickMarks(); |
|
60
|
2 |
|
} |
|
61
|
|
|
|
|
62
|
|
|
// Method description |
|
63
|
2 |
|
public function Stroke($img, $xscale, $yscale) |
|
64
|
|
|
{ |
|
65
|
2 |
|
$numpoints = safe_count($this->coords[0]) / 2; |
|
66
|
2 |
|
$img->SetColor($this->color); |
|
67
|
2 |
|
$img->SetLineWeight($this->weight); |
|
68
|
|
|
|
|
69
|
2 |
|
if (isset($this->coords[1])) { |
|
70
|
1 |
|
if (safe_count($this->coords[1]) != $numpoints) { |
|
71
|
|
|
Util\JpGraphError::RaiseL(2003, safe_count($this->coords[1]), $numpoints); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
//("Number of X and Y points are not equal. Number of X-points:". safe_count($this->coords[1])." Number of Y-points:$numpoints"); |
|
75
|
|
|
else { |
|
76
|
1 |
|
$exist_x = true; |
|
77
|
|
|
} |
|
78
|
|
|
} else { |
|
79
|
1 |
|
$exist_x = false; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
2 |
|
for ($i = 0; $i < $numpoints; ++$i) { |
|
83
|
2 |
|
if ($exist_x) { |
|
|
|
|
|
|
84
|
1 |
|
$x = $this->coords[1][$i]; |
|
85
|
|
|
} else { |
|
86
|
1 |
|
$x = $i; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
2 |
|
if (!is_numeric($x) || |
|
90
|
2 |
|
!is_numeric($this->coords[0][$i * 2]) || !is_numeric($this->coords[0][$i * 2 + 1])) { |
|
91
|
|
|
continue; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
2 |
|
$xt = $xscale->Translate($x); |
|
95
|
2 |
|
$yt1 = $yscale->Translate($this->coords[0][$i * 2]); |
|
96
|
2 |
|
$yt2 = $yscale->Translate($this->coords[0][$i * 2 + 1]); |
|
97
|
2 |
|
$img->Line($xt, $yt1, $xt, $yt2); |
|
98
|
2 |
|
$img->Line($xt - $this->errwidth, $yt1, $xt + $this->errwidth, $yt1); |
|
99
|
2 |
|
$img->Line($xt - $this->errwidth, $yt2, $xt + $this->errwidth, $yt2); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
2 |
|
return true; |
|
103
|
|
|
} |
|
104
|
|
|
} // @class |
|
105
|
|
|
|