Conditions | 131 |
Paths | 0 |
Total Lines | 361 |
Code Lines | 231 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 17292 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
34 | function drawRadar($Object,$Values,$Format="") |
||
35 | { |
||
36 | $this->pChartObject = $Object; |
||
37 | |||
38 | $FixedMax = isset($Format["FixedMax"]) ? $Format["FixedMax"] : VOID; |
||
39 | $AxisR = isset($Format["AxisR"]) ? $Format["AxisR"] : 60; |
||
40 | $AxisG = isset($Format["AxisG"]) ? $Format["AxisG"] : 60; |
||
41 | $AxisB = isset($Format["AxisB"]) ? $Format["AxisB"] : 60; |
||
42 | $AxisAlpha = isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 50; |
||
43 | $AxisRotation = isset($Format["AxisRotation"]) ? $Format["AxisRotation"] : 0; |
||
44 | $DrawTicks = isset($Format["DrawTicks"]) ? $Format["DrawTicks"] : TRUE; |
||
45 | $TicksLength = isset($Format["TicksLength"]) ? $Format["TicksLength"] : 2; |
||
46 | $DrawAxisValues = isset($Format["DrawAxisValues"]) ? $Format["DrawAxisValues"] : TRUE; |
||
47 | $AxisBoxRounded = isset($Format["AxisBoxRounded"]) ? $Format["AxisBoxRounded"] : TRUE; |
||
48 | $AxisFontName = isset($Format["AxisFontName"]) ? $Format["AxisFontName"] : $this->pChartObject->FontName; |
||
49 | $AxisFontSize = isset($Format["AxisFontSize"]) ? $Format["AxisFontSize"] : $this->pChartObject->FontSize; |
||
50 | $WriteValues = isset($Format["WriteValues"]) ? $Format["WriteValues"] : FALSE; |
||
51 | $WriteValuesInBubble = isset($Format["WriteValuesInBubble"]) ? $Format["WriteValuesInBubble"] : TRUE; |
||
52 | $ValueFontName = isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName; |
||
53 | $ValueFontSize = isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize; |
||
54 | $ValuePadding = isset($Format["ValuePadding"]) ? $Format["ValuePadding"] : 4; |
||
55 | $OuterBubbleRadius = isset($Format["OuterBubbleRadius"]) ? $Format["OuterBubbleRadius"] : 2; |
||
56 | $OuterBubbleR = isset($Format["OuterBubbleR"]) ? $Format["OuterBubbleR"] : VOID; |
||
57 | $OuterBubbleG = isset($Format["OuterBubbleG"]) ? $Format["OuterBubbleG"] : VOID; |
||
58 | $OuterBubbleB = isset($Format["OuterBubbleB"]) ? $Format["OuterBubbleB"] : VOID; |
||
59 | $OuterBubbleAlpha = isset($Format["OuterBubbleAlpha"]) ? $Format["OuterBubbleAlpha"] : 100; |
||
60 | $InnerBubbleR = isset($Format["InnerBubbleR"]) ? $Format["InnerBubbleR"] : 255; |
||
61 | $InnerBubbleG = isset($Format["InnerBubbleG"]) ? $Format["InnerBubbleG"] : 255; |
||
62 | $InnerBubbleB = isset($Format["InnerBubbleB"]) ? $Format["InnerBubbleB"] : 255; |
||
63 | $InnerBubbleAlpha = isset($Format["InnerBubbleAlpha"]) ? $Format["InnerBubbleAlpha"] : 100; |
||
64 | $DrawBackground = isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : TRUE; |
||
65 | $BackgroundR = isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255; |
||
66 | $BackgroundG = isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255; |
||
67 | $BackgroundB = isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255; |
||
68 | $BackgroundAlpha = isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 50; |
||
69 | $BackgroundGradient= isset($Format["BackgroundGradient"]) ? $Format["BackgroundGradient"] : NULL; |
||
70 | $Layout = isset($Format["Layout"]) ? $Format["Layout"] : RADAR_LAYOUT_STAR; |
||
71 | $SegmentHeight = isset($Format["SegmentHeight"]) ? $Format["SegmentHeight"] : SEGMENT_HEIGHT_AUTO; |
||
72 | $Segments = isset($Format["Segments"]) ? $Format["Segments"] : 4; |
||
73 | $WriteLabels = isset($Format["WriteLabels"]) ? $Format["WriteLabels"] : TRUE; |
||
74 | $SkipLabels = isset($Format["SkipLabels"]) ? $Format["SkipLabels"] : 1; |
||
75 | $LabelMiddle = isset($Format["LabelMiddle"]) ? $Format["LabelMiddle"] : FALSE; |
||
76 | $LabelsBackground = isset($Format["LabelsBackground"]) ? $Format["LabelsBackground"] : TRUE; |
||
77 | $LabelsBGR = isset($Format["LabelsBGR"]) ? $Format["LabelsBGR"] : 255; |
||
78 | $LabelsBGG = isset($Format["LabelsBGR"]) ? $Format["LabelsBGG"] : 255; |
||
79 | $LabelsBGB = isset($Format["LabelsBGR"]) ? $Format["LabelsBGB"] : 255; |
||
80 | $LabelsBGAlpha = isset($Format["LabelsBGAlpha"]) ? $Format["LabelsBGAlpha"] : 50; |
||
81 | $LabelPos = isset($Format["LabelPos"]) ? $Format["LabelPos"] : RADAR_LABELS_ROTATED; |
||
82 | $LabelPadding = isset($Format["LabelPadding"]) ? $Format["LabelPadding"] : 4; |
||
83 | $DrawPoints = isset($Format["DrawPoints"]) ? $Format["DrawPoints"] : TRUE; |
||
84 | $PointRadius = isset($Format["PointRadius"]) ? $Format["PointRadius"] : 4; |
||
85 | $PointSurrounding = isset($Format["PointRadius"]) ? $Format["PointRadius"] : -30; |
||
86 | $DrawLines = isset($Format["DrawLines"]) ? $Format["DrawLines"] : TRUE; |
||
87 | $LineLoopStart = isset($Format["LineLoopStart"]) ? $Format["LineLoopStart"] : TRUE; |
||
88 | $DrawPoly = isset($Format["DrawPoly"]) ? $Format["DrawPoly"] : FALSE; |
||
89 | $PolyAlpha = isset($Format["PolyAlpha"]) ? $Format["PolyAlpha"] : 40; |
||
90 | $FontSize = $Object->FontSize; |
||
91 | $X1 = $Object->GraphAreaX1; |
||
92 | $Y1 = $Object->GraphAreaY1; |
||
93 | $X2 = $Object->GraphAreaX2; |
||
94 | $Y2 = $Object->GraphAreaY2; |
||
95 | $RecordImageMap = isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE; |
||
96 | |||
97 | /* Cancel default tick length if ticks not enabled */ |
||
98 | if ( $DrawTicks == FALSE ) { $TicksLength = 0; } |
||
99 | |||
100 | /* Data Processing */ |
||
101 | $Data = $Values->getData(); |
||
102 | $Palette = $Values->getPalette(); |
||
103 | |||
104 | /* Catch the number of required axis */ |
||
105 | $LabelSerie = $Data["Abscissa"]; |
||
106 | if ( $LabelSerie != "" ) |
||
107 | { $Points = count($Data["Series"][$LabelSerie]["Data"]); } |
||
108 | else |
||
109 | { |
||
110 | $Points = 0; |
||
111 | foreach($Data["Series"] as $SerieName => $DataArray) |
||
112 | { if ( count($DataArray["Data"]) > $Points ) { $Points = count($DataArray["Data"]); } } |
||
113 | } |
||
114 | |||
115 | /* Draw the axis */ |
||
116 | $CenterX = ($X2-$X1)/2 + $X1; |
||
117 | $CenterY = ($Y2-$Y1)/2 + $Y1; |
||
118 | |||
119 | $EdgeHeight = min(($X2-$X1)/2,($Y2-$Y1)/2); |
||
120 | if ( $WriteLabels ) |
||
121 | $EdgeHeight = $EdgeHeight - $FontSize - $LabelPadding - $TicksLength; |
||
122 | |||
123 | /* Determine the scale if set to automatic */ |
||
124 | if ( $SegmentHeight == SEGMENT_HEIGHT_AUTO) |
||
125 | { |
||
126 | if ( $FixedMax != VOID ) |
||
127 | $Max = $FixedMax; |
||
128 | else |
||
129 | { |
||
130 | $Max = 0; |
||
131 | foreach($Data["Series"] as $SerieName => $DataArray) |
||
132 | { |
||
133 | if ( $SerieName != $LabelSerie ) |
||
134 | { |
||
135 | if ( max($DataArray["Data"]) > $Max ) { $Max = max($DataArray["Data"]); } |
||
136 | } |
||
137 | } |
||
138 | } |
||
139 | $MaxSegments = $EdgeHeight/20; |
||
140 | $Scale = $Object->computeScale(0,$Max,$MaxSegments,array(1,2,5)); |
||
141 | |||
142 | $Segments = $Scale["Rows"]; |
||
143 | $SegmentHeight = $Scale["RowHeight"]; |
||
144 | } |
||
145 | |||
146 | if ( $LabelMiddle && $SkipLabels == 1 ) |
||
147 | { $Axisoffset = (360/$Points)/2; } |
||
148 | elseif ( $LabelMiddle && $SkipLabels != 1 ) |
||
149 | { $Axisoffset = (360/($Points/$SkipLabels))/2; } |
||
150 | elseif ( !$LabelMiddle ) |
||
151 | { $Axisoffset = 0; } |
||
152 | |||
153 | /* Background processing */ |
||
154 | if ( $DrawBackground ) |
||
155 | { |
||
156 | $RestoreShadow = $Object->Shadow; |
||
157 | $Object->Shadow = FALSE; |
||
158 | |||
159 | if ($BackgroundGradient == NULL) |
||
|
|||
160 | { |
||
161 | if ( $Layout == RADAR_LAYOUT_STAR ) |
||
162 | { |
||
163 | $Color = array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha); |
||
164 | $PointArray = ""; |
||
165 | for($i=0;$i<=360;$i=$i+(360/$Points)) |
||
166 | { |
||
167 | $PointArray[] = cos(deg2rad($i+$AxisRotation)) * $EdgeHeight + $CenterX; |
||
168 | $PointArray[] = sin(deg2rad($i+$AxisRotation)) * $EdgeHeight + $CenterY; |
||
169 | } |
||
170 | $Object->drawPolygon($PointArray,$Color); |
||
171 | } |
||
172 | elseif ( $Layout == RADAR_LAYOUT_CIRCLE ) |
||
173 | { |
||
174 | $Color = array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha); |
||
175 | $Object->drawFilledCircle($CenterX,$CenterY,$EdgeHeight,$Color); |
||
176 | } |
||
177 | } |
||
178 | else |
||
179 | { |
||
180 | $GradientROffset = ($BackgroundGradient["EndR"] - $BackgroundGradient["StartR"]) / $Segments; |
||
181 | $GradientGOffset = ($BackgroundGradient["EndG"] - $BackgroundGradient["StartG"]) / $Segments; |
||
182 | $GradientBOffset = ($BackgroundGradient["EndB"] - $BackgroundGradient["StartB"]) / $Segments; |
||
183 | $GradientAlphaOffset = ($BackgroundGradient["EndAlpha"] - $BackgroundGradient["StartAlpha"]) / $Segments; |
||
184 | |||
185 | if ( $Layout == RADAR_LAYOUT_STAR ) |
||
186 | { |
||
187 | for($j=$Segments;$j>=1;$j--) |
||
188 | { |
||
189 | $Color = array("R"=>$BackgroundGradient["StartR"]+$GradientROffset*$j,"G"=>$BackgroundGradient["StartG"]+$GradientGOffset*$j,"B"=>$BackgroundGradient["StartB"]+$GradientBOffset*$j,"Alpha"=>$BackgroundGradient["StartAlpha"]+$GradientAlphaOffset*$j); |
||
190 | $PointArray = ""; |
||
191 | |||
192 | for($i=0;$i<=360;$i=$i+(360/$Points)) |
||
193 | { |
||
194 | $PointArray[] = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
195 | $PointArray[] = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
196 | } |
||
197 | $Object->drawPolygon($PointArray,$Color); |
||
198 | } |
||
199 | } |
||
200 | elseif ( $Layout == RADAR_LAYOUT_CIRCLE ) |
||
201 | { |
||
202 | for($j=$Segments;$j>=1;$j--) |
||
203 | { |
||
204 | $Color = array("R"=>$BackgroundGradient["StartR"]+$GradientROffset*$j,"G"=>$BackgroundGradient["StartG"]+$GradientGOffset*$j,"B"=>$BackgroundGradient["StartB"]+$GradientBOffset*$j,"Alpha"=>$BackgroundGradient["StartAlpha"]+$GradientAlphaOffset*$j); |
||
205 | $Object->drawFilledCircle($CenterX,$CenterY,($EdgeHeight/$Segments)*$j,$Color); |
||
206 | } |
||
207 | } |
||
208 | } |
||
209 | $Object->Shadow = $RestoreShadow; |
||
210 | } |
||
211 | |||
212 | /* Axis to axis lines */ |
||
213 | $Color = array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha); |
||
214 | $ColorDotted = array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha*.8, "Ticks"=>2); |
||
215 | if ( $Layout == RADAR_LAYOUT_STAR ) |
||
216 | { |
||
217 | for($j=1;$j<=$Segments;$j++) |
||
218 | { |
||
219 | for($i=0;$i<360;$i=$i+(360/$Points)) |
||
220 | { |
||
221 | $EdgeX1 = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
222 | $EdgeY1 = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
223 | $EdgeX2 = cos(deg2rad($i+$AxisRotation+(360/$Points))) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
224 | $EdgeY2 = sin(deg2rad($i+$AxisRotation+(360/$Points))) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
225 | |||
226 | $Object->drawLine($EdgeX1,$EdgeY1,$EdgeX2,$EdgeY2,$Color); |
||
227 | } |
||
228 | } |
||
229 | } |
||
230 | elseif ( $Layout == RADAR_LAYOUT_CIRCLE ) |
||
231 | { |
||
232 | for($j=1;$j<=$Segments;$j++) |
||
233 | { |
||
234 | $Radius = ($EdgeHeight/$Segments)*$j; |
||
235 | $Object->drawCircle($CenterX,$CenterY,$Radius,$Radius,$Color); |
||
236 | } |
||
237 | } |
||
238 | |||
239 | if ( $DrawAxisValues ) |
||
240 | { |
||
241 | if ( $LabelsBackground ) |
||
242 | $Options = array("DrawBox"=>TRUE, "Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"BoxR"=>$LabelsBGR,"BoxG"=>$LabelsBGG,"BoxB"=>$LabelsBGB,"BoxAlpha"=>$LabelsBGAlpha); |
||
243 | else |
||
244 | $Options = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE); |
||
245 | |||
246 | if ( $AxisBoxRounded ) { $Options["BoxRounded"] = TRUE; } |
||
247 | |||
248 | $Options["FontName"] = $AxisFontName; |
||
249 | $Options["FontSize"] = $AxisFontSize; |
||
250 | |||
251 | $Angle = 360 / ($Points*2); |
||
252 | for($j=1;$j<=$Segments;$j++) |
||
253 | { |
||
254 | $Label = $j * $SegmentHeight; |
||
255 | |||
256 | if ( $Layout == RADAR_LAYOUT_CIRCLE ) |
||
257 | { |
||
258 | $EdgeX1 = cos(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
259 | $EdgeY1 = sin(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
260 | } |
||
261 | elseif ( $Layout == RADAR_LAYOUT_STAR ) |
||
262 | { |
||
263 | $EdgeX1 = cos(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
264 | $EdgeY1 = sin(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
265 | $EdgeX2 = cos(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; |
||
266 | $EdgeY2 = sin(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; |
||
267 | |||
268 | $EdgeX1 = ($EdgeX2 - $EdgeX1)/2 + $EdgeX1; |
||
269 | $EdgeY1 = ($EdgeY2 - $EdgeY1)/2 + $EdgeY1; |
||
270 | } |
||
271 | |||
272 | $Object->drawText($EdgeX1,$EdgeY1,$Label,$Options); |
||
273 | } |
||
274 | } |
||
275 | |||
276 | /* Axis lines */ |
||
277 | $ID = 0; |
||
278 | for($i=0;$i<360;$i=$i+(360/$Points)) |
||
279 | { |
||
280 | $EdgeX = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterX; |
||
281 | $EdgeY = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterY; |
||
282 | |||
283 | if ($ID % $SkipLabels == 0) |
||
284 | { $Object->drawLine($CenterX,$CenterY,$EdgeX,$EdgeY,$Color); } |
||
285 | else |
||
286 | { $Object->drawLine($CenterX,$CenterY,$EdgeX,$EdgeY,$ColorDotted); } |
||
287 | |||
288 | if ( $WriteLabels ) |
||
289 | { |
||
290 | $LabelX = cos(deg2rad($i+$AxisRotation+$Axisoffset)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterX; |
||
291 | $LabelY = sin(deg2rad($i+$AxisRotation+$Axisoffset)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterY; |
||
292 | |||
293 | if ( $LabelSerie != "" ) |
||
294 | { $Label = isset($Data["Series"][$LabelSerie]["Data"][$ID]) ? $Data["Series"][$LabelSerie]["Data"][$ID] : ""; } |
||
295 | else |
||
296 | $Label = $ID; |
||
297 | |||
298 | if ($ID % $SkipLabels == 0) |
||
299 | { |
||
300 | if ( $LabelPos == RADAR_LABELS_ROTATED ) |
||
301 | $Object->drawText($LabelX,$LabelY,$Label,array("Angle"=>(360-($i+$AxisRotation+$Axisoffset))-90,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); |
||
302 | else |
||
303 | { |
||
304 | if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) < floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); } |
||
305 | if ( (floor($LabelX) > floor($CenterX)) && (floor($LabelY) < floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMLEFT)); } |
||
306 | if ( (floor($LabelX) > floor($CenterX)) && (floor($LabelY) == floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); } |
||
307 | if ( (floor($LabelX) > floor($CenterX)) && (floor($LabelY) > floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPLEFT)); } |
||
308 | if ( (floor($LabelX) < floor($CenterX)) && (floor($LabelY) < floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); } |
||
309 | if ( (floor($LabelX) < floor($CenterX)) && (floor($LabelY) == floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); } |
||
310 | if ( (floor($LabelX) < floor($CenterX)) && (floor($LabelY) > floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPRIGHT)); } |
||
311 | if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) > floor($CenterY)) ) { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPMIDDLE)); } |
||
312 | } |
||
313 | } |
||
314 | } |
||
315 | $ID++; |
||
316 | } |
||
317 | |||
318 | /* Compute the plots position */ |
||
319 | $ID = 0; $Plot = ""; |
||
320 | foreach($Data["Series"] as $SerieName => $DataS) |
||
321 | { |
||
322 | if ( $SerieName != $LabelSerie ) |
||
323 | { |
||
324 | $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding); |
||
325 | foreach($DataS["Data"] as $Key => $Value) |
||
326 | { |
||
327 | $Angle = (360/$Points) * $Key; |
||
328 | $Length = ($EdgeHeight/($Segments*$SegmentHeight))*$Value; |
||
329 | |||
330 | $X = cos(deg2rad($Angle+$AxisRotation)) * $Length + $CenterX; |
||
331 | $Y = sin(deg2rad($Angle+$AxisRotation)) * $Length + $CenterY; |
||
332 | |||
333 | $Plot[$ID][] = array($X,$Y,$Value); |
||
334 | |||
335 | if ( $RecordImageMap ) { $this->pChartObject->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".floor($PointRadius),$this->pChartObject->toHTMLColor($Palette[$ID]["R"],$Palette[$ID]["G"],$Palette[$ID]["B"]),$DataS["Description"],$Data["Series"][$LabelSerie]["Data"][$Key]." = ".$Value); } |
||
336 | } |
||
337 | $ID++; |
||
338 | } |
||
339 | } |
||
340 | |||
341 | /* Draw all that stuff! */ |
||
342 | foreach($Plot as $ID => $Points) |
||
343 | { |
||
344 | $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding); |
||
345 | |||
346 | /* Draw the polygons */ |
||
347 | if ( $DrawPoly ) |
||
348 | { |
||
349 | if ($PolyAlpha != NULL) |
||
350 | $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$PolyAlpha,"Surrounding"=>$PointSurrounding); |
||
351 | |||
352 | $PointsArray = ""; |
||
353 | for($i=0; $i<count($Points);$i++) |
||
354 | { $PointsArray[] = $Points[$i][0]; $PointsArray[] = $Points[$i][1]; } |
||
355 | $Object->drawPolygon($PointsArray,$Color); |
||
356 | } |
||
357 | |||
358 | $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding); |
||
359 | |||
360 | /* Bubble and labels settings */ |
||
361 | $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize,"R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"]); |
||
362 | $InnerColor = array("R"=>$InnerBubbleR,"G"=>$InnerBubbleG,"B"=>$InnerBubbleB,"Alpha"=>$InnerBubbleAlpha); |
||
363 | if ( $OuterBubbleR != VOID ) |
||
364 | $OuterColor = array("R"=>$OuterBubbleR,"G"=>$OuterBubbleG,"B"=>$OuterBubbleB,"Alpha"=>$OuterBubbleAlpha); |
||
365 | else |
||
366 | $OuterColor = array("R"=>$Palette[$ID]["R"]+20,"G"=>$Palette[$ID]["G"]+20,"B"=>$Palette[$ID]["B"]+20,"Alpha"=>$Palette[$ID]["Alpha"]); |
||
367 | |||
368 | /* Loop to the starting points if asked */ |
||
369 | if ( $LineLoopStart && $DrawLines ) |
||
370 | $Object->drawLine($Points[count($Points)-1][0],$Points[count($Points)-1][1],$Points[0][0],$Points[0][1],$Color); |
||
371 | |||
372 | /* Draw the lines & points */ |
||
373 | for($i=0; $i<count($Points);$i++) |
||
374 | { |
||
375 | if ( $DrawLines && $i < count($Points)-1) |
||
376 | $Object->drawLine($Points[$i][0],$Points[$i][1],$Points[$i+1][0],$Points[$i+1][1],$Color); |
||
377 | |||
378 | if ( $DrawPoints ) |
||
379 | $Object->drawFilledCircle($Points[$i][0],$Points[$i][1],$PointRadius,$Color); |
||
380 | |||
381 | if ( $WriteValuesInBubble && $WriteValues ) |
||
382 | { |
||
383 | $TxtPos = $this->pChartObject->getTextBox($Points[$i][0],$Points[$i][1],$ValueFontName,$ValueFontSize,0,$Points[$i][2]); |
||
384 | $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $ValuePadding*2)/2); |
||
385 | |||
386 | $this->pChartObject->drawFilledCircle($Points[$i][0],$Points[$i][1],$Radius+$OuterBubbleRadius,$OuterColor); |
||
387 | $this->pChartObject->drawFilledCircle($Points[$i][0],$Points[$i][1],$Radius,$InnerColor); |
||
388 | } |
||
389 | |||
390 | if ( $WriteValues ) |
||
391 | $this->pChartObject->drawText($Points[$i][0]-1,$Points[$i][1]-1,$Points[$i][2],$TextSettings); |
||
392 | } |
||
393 | } |
||
394 | } |
||
395 | |||
681 | ?> |