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