source: trunk/xgraph/jpgraph/themes/UniversalTheme.class.php

Last change on this file was 42, checked in by marrucho, 11 years ago
File size: 5.2 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 $height = $img->height;
118 $graph->SetMargin(
119 $img->raw_left_margin,
120 $img->raw_right_margin,
121 $img->raw_top_margin,
122 $height * 0.25
123 );
124 }
125 }
126
127 function ApplyPlot($plot) {
128
129 switch (get_class($plot))
130 {
131 case 'GroupBarPlot':
132 {
133 foreach ($plot->plots as $_plot) {
134 $this->ApplyPlot($_plot);
135 }
136 break;
137 }
138
139 case 'AccBarPlot':
140 {
141 foreach ($plot->plots as $_plot) {
142 $this->ApplyPlot($_plot);
143 }
144 break;
145 }
146
147 case 'BarPlot':
148 {
149 $plot->Clear();
150
151 $color = $this->GetNextColor();
152 $plot->SetColor($color);
153 $plot->SetFillColor($color);
154 $plot->SetShadow('red', 3, 4, false);
155 break;
156 }
157
158 case 'LinePlot':
159 {
160 $plot->Clear();
161 $plot->SetColor($this->GetNextColor().'@0.4');
162 $plot->SetWeight(2);
163 break;
164 }
165
166 case 'PiePlot':
167 {
168 $plot->SetCenter(0.5, 0.45);
169 $plot->ShowBorder(false);
170 $plot->SetSliceColors($this->GetThemeColors());
171 break;
172 }
173
174 case 'PiePlot3D':
175 {
176 $plot->SetSliceColors($this->GetThemeColors());
177 break;
178 }
179
180 default:
181 {
182 }
183 }
184 }
185}
186
187
188?>
Note: See TracBrowser for help on using the repository browser.