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
|
|
|
public function __construct($datay, $datax = false) |
36
|
|
|
{ |
37
|
|
|
parent::__construct($datay, $datax); |
38
|
|
|
$this->numpoints /= 2; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* PUBLIC METHODS. |
43
|
|
|
* |
44
|
|
|
* @param mixed $graph |
45
|
|
|
*/ |
46
|
|
|
// Gets called before any axis are stroked |
47
|
|
|
public function PreStrokeAdjust($graph) |
48
|
|
|
{ |
49
|
|
|
if ($this->center) { |
50
|
|
|
$a = 0.5; |
51
|
|
|
$b = 0.5; |
52
|
|
|
++$this->numpoints; |
53
|
|
|
} else { |
54
|
|
|
$a = 0; |
55
|
|
|
$b = 0; |
56
|
|
|
} |
57
|
|
|
$graph->xaxis->scale->ticks->SetXLabelOffset($a); |
58
|
|
|
$graph->SetTextScaleOff($b); |
59
|
|
|
//$graph->xaxis->scale->ticks->SupressMinorTickMarks(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
// Method description |
63
|
|
|
public function Stroke($img, $xscale, $yscale) |
64
|
|
|
{ |
65
|
|
|
$numpoints = safe_count($this->coords[0]) / 2; |
66
|
|
|
$img->SetColor($this->color); |
67
|
|
|
$img->SetLineWeight($this->weight); |
68
|
|
|
|
69
|
|
|
if (isset($this->coords[1])) { |
70
|
|
|
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
|
|
|
$exist_x = true; |
77
|
|
|
} |
78
|
|
|
} else { |
79
|
|
|
$exist_x = false; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
for ($i = 0; $i < $numpoints; ++$i) { |
83
|
|
|
if ($exist_x) { |
|
|
|
|
84
|
|
|
$x = $this->coords[1][$i]; |
85
|
|
|
} else { |
86
|
|
|
$x = $i; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
if (!is_numeric($x) || |
90
|
|
|
!is_numeric($this->coords[0][$i * 2]) || !is_numeric($this->coords[0][$i * 2 + 1])) { |
91
|
|
|
continue; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
$xt = $xscale->Translate($x); |
95
|
|
|
$yt1 = $yscale->Translate($this->coords[0][$i * 2]); |
96
|
|
|
$yt2 = $yscale->Translate($this->coords[0][$i * 2 + 1]); |
97
|
|
|
$img->Line($xt, $yt1, $xt, $yt2); |
98
|
|
|
$img->Line($xt - $this->errwidth, $yt1, $xt + $this->errwidth, $yt1); |
99
|
|
|
$img->Line($xt - $this->errwidth, $yt2, $xt + $this->errwidth, $yt2); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
} // @class |
105
|
|
|
|