Blame view

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