|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JPGraph v4.0.3 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Plot; |
|
8
|
|
|
|
|
9
|
|
|
use Amenadiel\JpGraph\Graph; |
|
10
|
|
|
use Amenadiel\JpGraph\Util; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* File: JPGRAPH_PLOTBAND.PHP |
|
14
|
|
|
* // Description: PHP4 Graph Plotting library. Extension module. |
|
15
|
|
|
* // Created: 2004-02-18 |
|
16
|
|
|
* // Ver: $Id: jpgraph_plotband.php 1106 2009-02-22 20:16:35Z ljp $ |
|
17
|
|
|
* // |
|
18
|
|
|
* // Copyright (c) Asial Corporation. All rights reserved. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @class PlotBand |
|
23
|
|
|
* // Factory class which is used by the client. |
|
24
|
|
|
* // It is responsible for factoring the corresponding pattern |
|
25
|
|
|
* // concrete class. |
|
26
|
|
|
*/ |
|
27
|
|
|
class PlotBand |
|
28
|
|
|
{ |
|
29
|
|
|
public $depth; // Determine if band should be over or under the plots |
|
30
|
|
|
private $prect; |
|
31
|
|
|
private $dir; |
|
32
|
|
|
private $min; |
|
33
|
|
|
private $max; |
|
34
|
|
|
|
|
35
|
|
|
public function __construct($aDir, $aPattern, $aMin, $aMax, $aColor = 'black', $aWeight = 1, $aDepth = DEPTH_BACK) |
|
36
|
|
|
{ |
|
37
|
|
|
$f = new Graph\RectPatternFactory(); |
|
38
|
|
|
$this->prect = $f->Create($aPattern, $aColor, $aWeight); |
|
39
|
|
|
if (is_numeric($aMin) && is_numeric($aMax) && ($aMin > $aMax)) { |
|
40
|
|
|
Util\JpGraphError::RaiseL(16004); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
//('Min value for plotband is larger than specified max value. Please correct.'); |
|
44
|
|
|
$this->dir = $aDir; |
|
45
|
|
|
$this->min = $aMin; |
|
46
|
|
|
$this->max = $aMax; |
|
47
|
|
|
$this->depth = $aDepth; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
// Set position. aRect contains absolute image coordinates |
|
51
|
|
|
public function SetPos($aRect) |
|
52
|
|
|
{ |
|
53
|
|
|
assert($this->prect != null); |
|
54
|
|
|
$this->prect->SetPos($aRect); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function ShowFrame($aFlag = true) |
|
58
|
|
|
{ |
|
59
|
|
|
$this->prect->ShowFrame($aFlag); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// Set z-order. In front of pplot or in the back |
|
63
|
|
|
public function SetOrder($aDepth) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->depth = $aDepth; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function SetDensity($aDens) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->prect->SetDensity($aDens); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function GetDir() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->dir; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function GetMin() |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->min; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function GetMax() |
|
84
|
|
|
{ |
|
85
|
|
|
return $this->max; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function PreStrokeAdjust($aGraph) |
|
|
|
|
|
|
89
|
|
|
{ |
|
90
|
|
|
// Nothing to do |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
// Display band |
|
94
|
|
|
public function Stroke($aImg, $aXScale, $aYScale) |
|
95
|
|
|
{ |
|
96
|
|
|
assert($this->prect != null); |
|
97
|
|
|
if ($this->dir == HORIZONTAL) { |
|
98
|
|
|
if ($this->min === 'min') { |
|
99
|
|
|
$this->min = $aYScale->GetMinVal(); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
if ($this->max === 'max') { |
|
103
|
|
|
$this->max = $aYScale->GetMaxVal(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
// Only draw the bar if it actually appears in the range |
|
107
|
|
|
if ($this->min < $aYScale->GetMaxVal() && $this->max > $aYScale->GetMinVal()) { |
|
108
|
|
|
// Trucate to limit of axis |
|
109
|
|
|
$this->min = max($this->min, $aYScale->GetMinVal()); |
|
110
|
|
|
$this->max = min($this->max, $aYScale->GetMaxVal()); |
|
111
|
|
|
|
|
112
|
|
|
$x = $aXScale->scale_abs[0]; |
|
113
|
|
|
$y = $aYScale->Translate($this->max); |
|
114
|
|
|
$width = $aXScale->scale_abs[1] - $aXScale->scale_abs[0] + 1; |
|
115
|
|
|
$height = abs($y - $aYScale->Translate($this->min)) + 1; |
|
116
|
|
|
$this->prect->SetPos(new Util\Rectangle($x, $y, $width, $height)); |
|
117
|
|
|
$this->prect->Stroke($aImg); |
|
118
|
|
|
} |
|
119
|
|
|
} else { |
|
120
|
|
|
// VERTICAL |
|
121
|
|
|
if ($this->min === 'min') { |
|
122
|
|
|
$this->min = $aXScale->GetMinVal(); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if ($this->max === 'max') { |
|
126
|
|
|
$this->max = $aXScale->GetMaxVal(); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
// Only draw the bar if it actually appears in the range |
|
130
|
|
|
if ($this->min < $aXScale->GetMaxVal() && $this->max > $aXScale->GetMinVal()) { |
|
131
|
|
|
// Trucate to limit of axis |
|
132
|
|
|
$this->min = max($this->min, $aXScale->GetMinVal()); |
|
133
|
|
|
$this->max = min($this->max, $aXScale->GetMaxVal()); |
|
134
|
|
|
|
|
135
|
|
|
$y = $aYScale->scale_abs[1]; |
|
136
|
|
|
$x = $aXScale->Translate($this->min); |
|
137
|
|
|
$height = abs($aYScale->scale_abs[1] - $aYScale->scale_abs[0]); |
|
138
|
|
|
$width = abs($x - $aXScale->Translate($this->max)); |
|
139
|
|
|
$this->prect->SetPos(new Util\Rectangle($x, $y, $width, $height)); |
|
140
|
|
|
$this->prect->Stroke($aImg); |
|
141
|
|
|
} |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.