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

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