1
|
|
|
<?php |
2
|
|
|
namespace Amenadiel\JpGraph\Themes; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Orange Theme class |
6
|
|
|
*/ |
7
|
|
View Code Duplication |
class OrangeTheme extends Theme |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
private $font_color = '#CC4400'; |
10
|
|
|
private $background_color = '#FFEEDD'; |
11
|
|
|
private $axis_color = '#CC6600'; |
12
|
|
|
private $grid_color = '#CC6633'; |
13
|
|
|
|
14
|
|
|
public function GetColorList() |
15
|
|
|
{ |
16
|
|
|
return array( |
17
|
|
|
'#FF9900', |
18
|
|
|
'#FFCC00', |
19
|
|
|
'#AA6600', |
20
|
|
|
'#CCCC00', |
21
|
|
|
'#CC6600', |
22
|
|
|
'#FFFF66', |
23
|
|
|
'#CCFF00', |
24
|
|
|
'#CC3300', |
25
|
|
|
'#669933', |
26
|
|
|
'#EE7700', |
27
|
|
|
'#AAEE33', |
28
|
|
|
'#77AA00', |
29
|
|
|
'#CCFF99', |
30
|
|
|
'#FF6633', |
31
|
|
|
'#885500', |
32
|
|
|
'#AADD00', |
33
|
|
|
'#99CC44', |
34
|
|
|
'#887711', |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function SetupGraph($graph) |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
// graph |
42
|
|
|
/* |
|
|
|
|
43
|
|
|
$img = $graph->img; |
44
|
|
|
$height = $img->height; |
45
|
|
|
$graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); |
46
|
|
|
*/ |
47
|
|
|
$graph->SetFrame(false); |
48
|
|
|
$graph->SetMarginColor('white'); |
49
|
|
|
$graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT); |
50
|
|
|
|
51
|
|
|
// legend |
52
|
|
|
$graph->legend->SetFrameWeight(0); |
53
|
|
|
$graph->legend->Pos(0.5, 0.85, 'center', 'top'); |
54
|
|
|
$graph->legend->SetFillColor('white'); |
55
|
|
|
$graph->legend->SetLayout(LEGEND_HOR); |
56
|
|
|
$graph->legend->SetColumns(3); |
57
|
|
|
$graph->legend->SetShadow(false); |
58
|
|
|
$graph->legend->SetMarkAbsSize(5); |
59
|
|
|
|
60
|
|
|
// xaxis |
61
|
|
|
$graph->xaxis->title->SetColor($this->font_color); |
62
|
|
|
$graph->xaxis->SetColor($this->axis_color, $this->font_color); |
63
|
|
|
$graph->xaxis->SetTickSide(SIDE_BOTTOM); |
64
|
|
|
$graph->xaxis->SetLabelMargin(10); |
65
|
|
|
|
66
|
|
|
// yaxis |
67
|
|
|
$graph->yaxis->title->SetColor($this->font_color); |
68
|
|
|
$graph->yaxis->SetColor($this->axis_color, $this->font_color); |
69
|
|
|
$graph->yaxis->SetTickSide(SIDE_LEFT); |
70
|
|
|
$graph->yaxis->SetLabelMargin(8); |
71
|
|
|
$graph->yaxis->HideLine(); |
72
|
|
|
$graph->yaxis->HideTicks(); |
73
|
|
|
$graph->xaxis->SetTitleMargin(15); |
74
|
|
|
|
75
|
|
|
// grid |
76
|
|
|
$graph->ygrid->SetColor($this->grid_color); |
77
|
|
|
$graph->ygrid->SetLineStyle('dotted'); |
78
|
|
|
|
79
|
|
|
// font |
80
|
|
|
$graph->title->SetColor($this->font_color); |
81
|
|
|
$graph->subtitle->SetColor($this->font_color); |
82
|
|
|
$graph->subsubtitle->SetColor($this->font_color); |
83
|
|
|
|
84
|
|
|
// $graph->img->SetAntiAliasing(); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function SetupPieGraph($graph) |
88
|
|
|
{ |
89
|
|
|
|
90
|
|
|
// graph |
91
|
|
|
$graph->SetFrame(false); |
92
|
|
|
|
93
|
|
|
// legend |
94
|
|
|
$graph->legend->SetFillColor('white'); |
95
|
|
|
/* |
|
|
|
|
96
|
|
|
$graph->legend->SetFrameWeight(0); |
97
|
|
|
$graph->legend->Pos(0.5, 0.85, 'center', 'top'); |
98
|
|
|
$graph->legend->SetLayout(LEGEND_HOR); |
99
|
|
|
$graph->legend->SetColumns(3); |
100
|
|
|
*/ |
101
|
|
|
$graph->legend->SetShadow(false); |
102
|
|
|
$graph->legend->SetMarkAbsSize(5); |
103
|
|
|
|
104
|
|
|
// title |
105
|
|
|
$graph->title->SetColor($this->font_color); |
106
|
|
|
$graph->subtitle->SetColor($this->font_color); |
107
|
|
|
$graph->subsubtitle->SetColor($this->font_color); |
108
|
|
|
|
109
|
|
|
$graph->SetAntiAliasing(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function PreStrokeApply($graph) |
113
|
|
|
{ |
114
|
|
|
if ($graph->legend->HasItems()) { |
115
|
|
|
$img = $graph->img; |
116
|
|
|
$height = $img->height; |
117
|
|
|
$graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25); |
118
|
|
|
} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function ApplyPlot($plot) |
122
|
|
|
{ |
123
|
|
|
switch (get_class($plot)) { |
124
|
|
|
case 'GroupBarPlot': |
|
|
|
|
125
|
|
|
{ |
126
|
|
|
foreach ($plot->plots as $_plot) { |
127
|
|
|
$this->ApplyPlot($_plot); |
128
|
|
|
} |
129
|
|
|
break; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
case 'AccBarPlot': |
|
|
|
|
133
|
|
|
{ |
134
|
|
|
foreach ($plot->plots as $_plot) { |
135
|
|
|
$this->ApplyPlot($_plot); |
136
|
|
|
} |
137
|
|
|
break; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
case 'BarPlot': |
|
|
|
|
141
|
|
|
{ |
142
|
|
|
$plot->Clear(); |
143
|
|
|
|
144
|
|
|
$color = $this->GetNextColor(); |
145
|
|
|
$plot->SetColor($color); |
146
|
|
|
$plot->SetFillColor($color); |
147
|
|
|
$plot->SetShadow('red', 3, 4, false); |
148
|
|
|
break; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
case 'LinePlot': |
|
|
|
|
152
|
|
|
{ |
153
|
|
|
$plot->Clear(); |
154
|
|
|
|
155
|
|
|
$plot->SetColor($this->GetNextColor() . '@0.4'); |
156
|
|
|
$plot->SetWeight(2); |
157
|
|
|
break; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
case 'PiePlot': |
|
|
|
|
161
|
|
|
{ |
162
|
|
|
$plot->ShowBorder(false); |
163
|
|
|
$plot->SetSliceColors($this->GetThemeColors()); |
164
|
|
|
break; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
case 'PiePlot3D': |
|
|
|
|
168
|
|
|
{ |
169
|
|
|
$plot->SetSliceColors($this->GetThemeColors()); |
170
|
|
|
break; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
default: |
|
|
|
|
174
|
|
|
{ |
175
|
|
|
} |
176
|
|
|
} |
177
|
|
|
} |
178
|
|
|
} |
179
|
|
|
|
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.