source: trunk/client/modules/Elezioni/grafici/themes/UniversalTheme.class.php@ 417

Last change on this file since 417 was 266, checked in by roby, 6 years ago
File size: 5.0 KB
Line 
1<?php
2
3/**
4* Universal Theme class
5*/
6class UniversalTheme extends Theme
7{
8 private $font_color = '#444444';
9 private $background_color = '#F4F4F4';
10 private $axis_color = '#888888';
11 private $grid_color = '#E3E3E3';
12
13 function GetColorList() {
14 return array(
15 '#61a9f3',#blue
16 '#f381b9',#red
17 '#61E3A9',#green
18
19 #'#D56DE2',
20 '#85eD82',
21 '#F7b7b7',
22 '#CFDF49',
23 '#88d8f2',
24 '#07AF7B',
25 '#B9E3F9',
26 '#FFF3AD',
27 '#EF606A',
28 '#EC8833',
29 '#FFF100',
30 '#87C9A5',
31 );
32 }
33
34 function SetupGraph($graph) {
35
36 // graph
37 /*
38 $img = $graph->img;
39 $height = $img->height;
40 $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $height * 0.25);
41 */
42 $graph->SetFrame(false);
43 $graph->SetMarginColor('white');
44 $graph->SetBox(true, '#DADADA');
45// $graph->SetBackgroundGradient($this->background_color, '#FFFFFF', GRAD_HOR, BGRAD_PLOT);
46
47 // legend
48 $graph->legend->SetFrameWeight(0);
49 $graph->legend->Pos(0.5, 0.85, 'center', 'top');
50 $graph->legend->SetFillColor('white');
51 $graph->legend->SetLayout(LEGEND_HOR);
52 $graph->legend->SetColumns(3);
53 $graph->legend->SetShadow(false);
54 $graph->legend->SetMarkAbsSize(5);
55
56 // xaxis
57 $graph->xaxis->title->SetColor($this->font_color);
58 $graph->xaxis->SetColor($this->axis_color, $this->font_color);
59 $graph->xaxis->SetTickSide(SIDE_BOTTOM);
60 $graph->xaxis->SetLabelMargin(10);
61 $graph->xaxis->HideTicks();
62 $graph->xaxis->SetTitleMargin(15);
63 //$graph->xaxis->SetLabelMargin(30);
64
65 // yaxis
66 $graph->yaxis->title->SetColor($this->font_color);
67 $graph->yaxis->SetColor($this->axis_color, $this->font_color);
68 $graph->yaxis->SetTickSide(SIDE_LEFT);
69 $graph->yaxis->SetLabelMargin(8);
70// $graph->yaxis->SetTickPositions(array(50, 100, 150));
71// $graph->yaxis->HideLine();
72 $graph->yaxis->HideTicks();
73
74 // grid
75 $graph->ygrid->SetColor($this->grid_color);
76 $graph->ygrid->SetFill(true, '#FFFFFF', $this->background_color);
77 // $graph->ygrid->SetLineStyle('dotted');
78
79
80 // font
81 $graph->title->SetColor($this->font_color);
82 $graph->subtitle->SetColor($this->font_color);
83 $graph->subsubtitle->SetColor($this->font_color);
84
85 $graph->img->SetAntiAliasing();
86 }
87
88
89 function SetupPieGraph($graph) {
90
91 // graph
92 $graph->SetFrame(false);
93
94 // legend
95 $graph->legend->SetFillColor('white');
96
97 $graph->legend->SetFrameWeight(0);
98 $graph->legend->Pos(0.5, 0.80, 'center', 'top');
99 $graph->legend->SetLayout(LEGEND_HOR);
100 $graph->legend->SetColumns(4);
101
102 $graph->legend->SetShadow(false);
103 $graph->legend->SetMarkAbsSize(5);
104
105 // title
106 $graph->title->SetColor($this->font_color);
107 $graph->subtitle->SetColor($this->font_color);
108 $graph->subsubtitle->SetColor($this->font_color);
109
110 $graph->SetAntiAliasing();
111 }
112
113
114 function PreStrokeApply($graph) {
115 if ($graph->legend->HasItems()) {
116 $img = $graph->img;
117 $graph->SetMargin(
118 $img->raw_left_margin,
119 $img->raw_right_margin,
120 $img->raw_top_margin,
121 is_numeric($img->raw_bottom_margin) ? $img->raw_bottom_margin : $img->height * 0.25
122 );
123 }
124 }
125
126 function ApplyPlot($plot) {
127
128 switch (get_class($plot))
129 {
130 case 'GroupBarPlot':
131 {
132 foreach ($plot->plots as $_plot) {
133 $this->ApplyPlot($_plot);
134 }
135 break;
136 }
137
138 case 'AccBarPlot':
139 {
140 foreach ($plot->plots as $_plot) {
141 $this->ApplyPlot($_plot);
142 }
143 break;
144 }
145
146 case 'BarPlot':
147 {
148 $plot->Clear();
149
150 $color = $this->GetNextColor();
151 $plot->SetColor($color);
152 $plot->SetFillColor($color);
153 $plot->SetShadow('red', 3, 4, false);
154 break;
155 }
156
157 case 'LinePlot':
158 {
159 $plot->Clear();
160 $plot->SetColor($this->GetNextColor().'@0.4');
161 $plot->SetWeight(2);
162 break;
163 }
164
165 case 'PiePlot':
166 {
167 $plot->SetCenter(0.5, 0.45);
168 $plot->ShowBorder(false);
169 $plot->SetSliceColors($this->GetThemeColors());
170 break;
171 }
172
173 case 'PiePlot3D':
174 {
175 $plot->SetSliceColors($this->GetThemeColors());
176 break;
177 }
178
179 default:
180 {
181 }
182 }
183 }
184}
185
186
187?>
Note: See TracBrowser for help on using the repository browser.