source: trunk/xgraph/jpgraph/themes/SoftyTheme.class.php@ 42

Last change on this file since 42 was 42, checked in by marrucho, 11 years ago
File size: 5.7 KB
Line 
1<?php
2
3/**
4* Softy Theme class
5*/
6class SoftyTheme extends Theme
7{
8 protected $font_color = '#000000';
9 protected $background_color = '#F7F8F4';
10 protected $axis_color = '#000000';
11 protected $grid_color = '#CCCCCC';
12
13 function GetColorList() {
14 return array(
15 '#CFE7FB',
16 '#F9D76F',
17 '#B9D566',
18 '#FFBB90',
19 '#66BBBB',
20 '#E69090',
21 '#BB90BB',
22 '#9AB67C',
23 '#D1CC66',
24
25/*
26
27 '#AFD8F8',
28 '#F6BD0F',
29 '#8BBA00',
30 '#FF8E46',
31 '#008E8E',
32
33 '#D64646',
34 '#8E468E',
35 '#588526',
36 '#B3AA00',
37 '#008ED6',
38
39 '#9D080D',
40 '#A186BE',
41 */
42 );
43 }
44
45 function SetupGraph($graph) {
46
47 // graph
48 $graph->SetFrame(false);
49 $graph->SetMarginColor('white');
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 // y2~
76 if (isset($graph->y2axis)) {
77 $graph->y2axis->title->SetColor($this->font_color);
78 $graph->y2axis->SetColor($this->axis_color, $this->font_color);
79 $graph->y2axis->SetTickSide(SIDE_LEFT);
80 $graph->y2axis->SetLabelMargin(8);
81 $graph->y2axis->HideLine();
82 $graph->y2axis->HideTicks();
83 }
84
85 // yn
86 if (isset($graph->y2axis)) {
87 foreach ($graph->ynaxis as $axis) {
88 $axis->title->SetColor($this->font_color);
89 $axis->SetColor($this->axis_color, $this->font_color);
90 $axis->SetTickSide(SIDE_LEFT);
91 $axis->SetLabelMargin(8);
92 $axis->HideLine();
93 $axis->HideTicks();
94 }
95 }
96
97 // grid
98 $graph->ygrid->SetColor($this->grid_color);
99 $graph->ygrid->SetLineStyle('dotted');
100 $graph->ygrid->SetFill(true, '#FFFFFF', $this->background_color);
101 $graph->xgrid->Show();
102 $graph->xgrid->SetColor($this->grid_color);
103 $graph->xgrid->SetLineStyle('dotted');
104
105
106 // font
107 $graph->title->SetColor($this->font_color);
108 $graph->subtitle->SetColor($this->font_color);
109 $graph->subsubtitle->SetColor($this->font_color);
110
111// $graph->img->SetAntiAliasing();
112 }
113
114
115 function SetupPieGraph($graph) {
116
117 // graph
118 $graph->SetFrame(false);
119
120 // title
121 $graph->title->SetColor($this->font_color);
122 $graph->subtitle->SetColor($this->font_color);
123 $graph->subsubtitle->SetColor($this->font_color);
124
125 $graph->SetAntiAliasing();
126 }
127
128
129 function PreStrokeApply($graph) {
130 if ($graph->legend->HasItems()) {
131 $img = $graph->img;
132 $graph->SetMargin($img->left_margin, $img->right_margin, $img->top_margin, $img->height * 0.25);
133// $graph->SetMargin(200, $img->right_margin, $img->top_margin, $height * 0.25);
134 }
135 }
136
137 function ApplyPlot($plot) {
138
139 switch (get_class($plot))
140 {
141 case 'BarPlot':
142 {
143 $plot->Clear();
144
145 $color = $this->GetNextColor();
146 $plot->SetColor($color);
147 $plot->SetFillColor($color);
148 $plot->SetShadow('red', 3, 4, false);
149 $plot->value->SetAlign('center', 'center');
150 break;
151 }
152
153 case 'LinePlot':
154 {
155 $plot->Clear();
156
157 $plot->SetColor($this->GetNextColor());
158 $plot->SetWeight(2);
159// $plot->SetBarCenter();
160 break;
161 }
162
163 case 'PiePlot':
164 {
165 $plot->ShowBorder(false);
166 $plot->SetSliceColors($this->GetThemeColors());
167 break;
168 }
169
170
171 case 'GroupBarPlot':
172 {
173 foreach ($plot->plots as $_plot) {
174 $this->ApplyPlot($_plot);
175 }
176 break;
177 }
178
179 case 'AccBarPlot':
180 {
181 $plot->value->SetAlign('center', 'center');
182 foreach ($plot->plots as $_plot) {
183 $this->ApplyPlot($_plot);
184 $_plot->SetValuePos('center');
185 }
186 break;
187 }
188
189 case 'ScatterPlot':
190 {
191 break;
192 }
193
194
195 case 'PiePlot3D':
196 {
197 $plot->SetSliceColors($this->GetThemeColors());
198 break;
199 }
200
201 default:
202 {
203 }
204 }
205 }
206}
207
208
209?>
Note: See TracBrowser for help on using the repository browser.