|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* JPGraph v4.0.3 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Amenadiel\JpGraph\Graph; |
|
8
|
|
|
|
|
9
|
|
|
define('GANTT_HGRID1', 0); |
|
10
|
|
|
define('GANTT_HGRID2', 1); |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @class HorizontalGridLine |
|
14
|
|
|
* // Responsible for drawinf horizontal gridlines and filled alternatibg rows |
|
15
|
|
|
*/ |
|
16
|
|
|
class HorizontalGridLine |
|
17
|
|
|
{ |
|
18
|
|
|
private $iGraph; |
|
|
|
|
|
|
19
|
|
|
private $iRowColor1 = ''; |
|
20
|
|
|
private $iRowColor2 = ''; |
|
21
|
|
|
private $iShow = false; |
|
22
|
|
|
private $line; |
|
23
|
|
|
private $iStart = 0; // 0=from left margin, 1=just along header |
|
24
|
|
|
|
|
25
|
|
|
public function __construct() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->line = new LineProperty(); |
|
28
|
|
|
$this->line->SetColor('[email protected]'); |
|
29
|
|
|
$this->line->SetStyle('dashed'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function Show($aShow = true) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->iShow = $aShow; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function SetRowFillColor($aColor1, $aColor2 = '') |
|
38
|
|
|
{ |
|
39
|
|
|
$this->iRowColor1 = $aColor1; |
|
40
|
|
|
$this->iRowColor2 = $aColor2; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function SetStart($aStart) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->iStart = $aStart; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function Stroke($aImg, $aScale) |
|
49
|
|
|
{ |
|
50
|
|
|
if (!$this->iShow) { |
|
51
|
|
|
return; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
// Get horizontal width of line |
|
55
|
|
|
/* |
|
56
|
|
|
$limst = $aScale->iStartDate; |
|
57
|
|
|
$limen = $aScale->iEndDate; |
|
58
|
|
|
$xt = round($aScale->TranslateDate($aScale->iStartDate)); |
|
59
|
|
|
$xb = round($aScale->TranslateDate($limen)); |
|
60
|
|
|
*/ |
|
61
|
|
|
|
|
62
|
|
|
if ($this->iStart === 0) { |
|
63
|
|
|
$xt = $aImg->left_margin - 1; |
|
64
|
|
|
} else { |
|
65
|
|
|
$xt = round($aScale->TranslateDate($aScale->iStartDate)) + 1; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$xb = $aImg->width - $aImg->right_margin; |
|
69
|
|
|
|
|
70
|
|
|
$yt = round($aScale->TranslateVertPos(0)); |
|
71
|
|
|
$yb = round($aScale->TranslateVertPos(1)); |
|
72
|
|
|
$height = $yb - $yt; |
|
73
|
|
|
|
|
74
|
|
|
// Loop around for all lines in the chart |
|
75
|
|
|
for ($i = 0; $i < $aScale->iVertLines; ++$i) { |
|
76
|
|
|
$yb = $yt - $height; |
|
77
|
|
|
$this->line->Stroke($aImg, $xt, $yb, $xb, $yb); |
|
78
|
|
|
if ($this->iRowColor1 !== '') { |
|
79
|
|
|
if ($i % 2 == 0) { |
|
80
|
|
|
$aImg->PushColor($this->iRowColor1); |
|
81
|
|
|
$aImg->FilledRectangle($xt, $yt, $xb, $yb); |
|
82
|
|
|
$aImg->PopColor(); |
|
83
|
|
|
} elseif ($this->iRowColor2 !== '') { |
|
84
|
|
|
$aImg->PushColor($this->iRowColor2); |
|
85
|
|
|
$aImg->FilledRectangle($xt, $yt, $xb, $yb); |
|
86
|
|
|
$aImg->PopColor(); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
$yt = round($aScale->TranslateVertPos($i + 1)); |
|
90
|
|
|
} |
|
91
|
|
|
$yb = $yt - $height; |
|
92
|
|
|
$this->line->Stroke($aImg, $xt, $yb, $xb, $yb); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|