1
|
|
|
<?php |
2
|
|
|
namespace Amenadiel\JpGraph\Themes; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Green Theme class |
6
|
|
|
*/ |
7
|
|
View Code Duplication |
class GreenTheme extends Theme |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
private $font_color = '#009900'; |
10
|
|
|
private $background_color = '#EEFFDD'; |
11
|
|
|
private $axis_color = '#00CC00'; |
12
|
|
|
private $grid_color = '#33CC33'; |
13
|
|
|
|
14
|
|
|
public function GetColorList() |
15
|
|
|
{ |
16
|
|
|
return array( |
17
|
|
|
'#66CC00', |
18
|
|
|
'#009900', |
19
|
|
|
'#AAFF77', |
20
|
|
|
'#559922', |
21
|
|
|
'#00CC33', |
22
|
|
|
'#99FF00', |
23
|
|
|
'#009966', |
24
|
|
|
'#00FF99', |
25
|
|
|
'#99BB66', |
26
|
|
|
'#33FF00', |
27
|
|
|
'#DDFFBB', |
28
|
|
|
'#669933', |
29
|
|
|
'#BBDDCC', |
30
|
|
|
'#77CCBB', |
31
|
|
|
'#668833', |
32
|
|
|
'#BBEE66', |
33
|
|
|
); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function SetupGraph($graph) |
37
|
|
|
{ |
38
|
|
|
|
39
|
|
|
// graph |
40
|
|
|
/* |
|
|
|
|
41
|
|
|
$img = $graph->img; |
42
|
|
|
$height = $img->height; |
43
|
|
|
$graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); |
44
|
|
|
*/ |
45
|
|
|
$graph->SetFrame(false); |
46
|
|
|
$graph->SetMarginColor('white'); |
47
|
|
|
$graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); |
48
|
|
|
|
49
|
|
|
// legend |
50
|
|
|
$graph->legend->SetFrameWeight(0); |
51
|
|
|
$graph->legend->Pos(0.5, 0.85, 'center', 'top'); |
52
|
|
|
$graph->legend->SetFillColor('white'); |
53
|
|
|
$graph->legend->SetLayout(LEGEND_HOR); |
54
|
|
|
$graph->legend->SetColumns(3); |
55
|
|
|
$graph->legend->SetShadow(false); |
56
|
|
|
$graph->legend->SetMarkAbsSize(5); |
57
|
|
|
|
58
|
|
|
// xaxis |
59
|
|
|
$graph->xaxis->title->SetColor($this->font_color); |
60
|
|
|
$graph->xaxis->SetColor($this->axis_color, $this->font_color); |
61
|
|
|
$graph->xaxis->SetTickSide(SIDE_BOTTOM); |
62
|
|
|
$graph->xaxis->SetLabelMargin(10); |
63
|
|
|
|
64
|
|
|
// yaxis |
65
|
|
|
$graph->yaxis->title->SetColor($this->font_color); |
66
|
|
|
$graph->yaxis->SetColor($this->axis_color, $this->font_color); |
67
|
|
|
$graph->yaxis->SetTickSide(SIDE_LEFT); |
68
|
|
|
$graph->yaxis->SetLabelMargin(8); |
69
|
|
|
$graph->yaxis->HideLine(); |
70
|
|
|
$graph->yaxis->HideTicks(); |
71
|
|
|
$graph->xaxis->SetTitleMargin(15); |
72
|
|
|
|
73
|
|
|
// grid |
74
|
|
|
$graph->ygrid->SetColor($this->grid_color); |
75
|
|
|
$graph->ygrid->SetLineStyle('dotted'); |
76
|
|
|
|
77
|
|
|
// font |
78
|
|
|
$graph->title->SetColor($this->font_color); |
79
|
|
|
$graph->subtitle->SetColor($this->font_color); |
80
|
|
|
$graph->subsubtitle->SetColor($this->font_color); |
81
|
|
|
|
82
|
|
|
// $graph->img->SetAntiAliasing(); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function SetupPieGraph($graph) |
86
|
|
|
{ |
87
|
|
|
|
88
|
|
|
// graph |
89
|
|
|
$graph->SetFrame(false); |
90
|
|
|
|
91
|
|
|
// legend |
92
|
|
|
$graph->legend->SetFillColor('white'); |
93
|
|
|
/* |
|
|
|
|
94
|
|
|
$graph->legend->SetFrameWeight(0); |
95
|
|
|
$graph->legend->Pos(0.5, 0.85, 'center', 'top'); |
96
|
|
|
$graph->legend->SetLayout(LEGEND_HOR); |
97
|
|
|
$graph->legend->SetColumns(3); |
98
|
|
|
*/ |
99
|
|
|
$graph->legend->SetShadow(false); |
100
|
|
|
$graph->legend->SetMarkAbsSize(5); |
101
|
|
|
|
102
|
|
|
// title |
103
|
|
|
$graph->title->SetColor($this->font_color); |
104
|
|
|
$graph->subtitle->SetColor($this->font_color); |
105
|
|
|
$graph->subsubtitle->SetColor($this->font_color); |
106
|
|
|
|
107
|
|
|
$graph->SetAntiAliasing(); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
public function PreStrokeApply($graph) |
111
|
|
|
{ |
112
|
|
|
if ($graph->legend->HasItems()) { |
113
|
|
|
$img = $graph->img; |
114
|
|
|
$height = $img->height; |
115
|
|
|
$graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
public function ApplyPlot($plot) |
120
|
|
|
{ |
121
|
|
|
switch (get_class($plot)) { |
122
|
|
|
case 'GroupBarPlot': |
|
|
|
|
123
|
|
|
{ |
124
|
|
|
foreach ($plot->plots as $_plot) { |
125
|
|
|
$this->ApplyPlot($_plot); |
126
|
|
|
} |
127
|
|
|
break; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
case 'AccBarPlot': |
|
|
|
|
131
|
|
|
{ |
132
|
|
|
foreach ($plot->plots as $_plot) { |
133
|
|
|
$this->ApplyPlot($_plot); |
134
|
|
|
} |
135
|
|
|
break; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
case 'BarPlot': |
|
|
|
|
139
|
|
|
{ |
140
|
|
|
$plot->Clear(); |
141
|
|
|
|
142
|
|
|
$color = $this->GetNextColor(); |
143
|
|
|
$plot->SetColor($color); |
144
|
|
|
$plot->SetFillColor($color); |
145
|
|
|
$plot->SetShadow('red', 3, 4, false); |
146
|
|
|
break; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
case 'LinePlot': |
|
|
|
|
150
|
|
|
{ |
151
|
|
|
$plot->Clear(); |
152
|
|
|
|
153
|
|
|
$plot->SetColor($this->GetNextColor() . '@0.4'); |
154
|
|
|
$plot->SetWeight(2); |
155
|
|
|
break; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
case 'PiePlot': |
|
|
|
|
159
|
|
|
{ |
160
|
|
|
$plot->ShowBorder(false); |
161
|
|
|
$plot->SetSliceColors($this->GetThemeColors()); |
162
|
|
|
break; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
case 'PiePlot3D': |
|
|
|
|
166
|
|
|
{ |
167
|
|
|
$plot->SetSliceColors($this->GetThemeColors()); |
168
|
|
|
break; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
default: |
|
|
|
|
172
|
|
|
{ |
173
|
|
|
} |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.