Heuristic ranking analysis
[contractdashboard.git] / lib / pChart2.1.0 / class / pRadar.class.php
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
<?php
 /*
     pRadar - class to draw radar charts
 
     Version     : 2.1.0
     Made by     : Jean-Damien POGOLOTTI
     Last Update : 26/01/11
 
     This file can be distributed under the license you can find at :
 
                       http://www.pchart.net/license
 
     You can find the whole class documentation on the pChart web site.
 */
 
 define("SEGMENT_HEIGHT_AUTO"           , 690001);
 
 define("RADAR_LAYOUT_STAR"             , 690011);
 define("RADAR_LAYOUT_CIRCLE"           , 690012);
 
 define("RADAR_LABELS_ROTATED"          , 690021);
 define("RADAR_LABELS_HORIZONTAL"       , 690022);
 
 /* pRadar class definition */
 class pRadar
  {
   var $pChartObject;
 
   /* Class creator */
   function pRadar()
    { }
 
   /* Draw a radar chart */
   function drawRadar($Object,$Values,$Format="")
    {
     $this->pChartObject = $Object;
 
     $AxisR             = isset($Format["AxisR"]) ? $Format["AxisR"] : 60;
     $AxisG             = isset($Format["AxisG"]) ? $Format["AxisG"] : 60;
     $AxisB             = isset($Format["AxisB"]) ? $Format["AxisB"] : 60;
     $AxisAlpha         = isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 50;
     $AxisRotation      = isset($Format["AxisRotation"]) ? $Format["AxisRotation"] : 0;
     $DrawTicks         = isset($Format["DrawTicks"]) ? $Format["DrawTicks"] : TRUE;
     $TicksLength       = isset($Format["TicksLength"]) ? $Format["TicksLength"] : 2;
     $DrawAxisValues    = isset($Format["DrawAxisValues"]) ? $Format["DrawAxisValues"] : TRUE;
     $AxisBoxRounded    = isset($Format["AxisBoxRounded"]) ? $Format["AxisBoxRounded"] : TRUE;
     $AxisFontName      = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName;
     $AxisFontSize      = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize;
     $DrawBackground    = isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : TRUE;
     $BackgroundR       = isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255;
     $BackgroundG       = isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255;
     $BackgroundB       = isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255;
     $BackgroundAlpha   = isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 50;
     $BackgroundGradient= isset($Format["BackgroundGradient"]) ? $Format["BackgroundGradient"] : NULL;
     $Layout            = isset($Format["Layout"]) ? $Format["Layout"] : RADAR_LAYOUT_STAR;
     $SegmentHeight     = isset($Format["SegmentHeight"]) ? $Format["SegmentHeight"] : SEGMENT_HEIGHT_AUTO;
     $Segments          = isset($Format["Segments"]) ? $Format["Segments"] : 4;
     $WriteLabels       = isset($Format["WriteLabels"]) ? $Format["WriteLabels"] : TRUE;
     $SkipLabels        = isset($Format["SkipLabels"]) ? $Format["SkipLabels"] : 1;
     $LabelMiddle       = isset($Format["LabelMiddle"]) ? $Format["LabelMiddle"] : FALSE;
     $LabelsBackground  = isset($Format["LabelsBackground"]) ? $Format["LabelsBackground"] : TRUE;
     $LabelsBGR         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGR"] : 255;
     $LabelsBGG         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGG"] : 255;
     $LabelsBGB         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGB"] : 255;
     $LabelsBGAlpha     = isset($Format["LabelsBGAlpha"]) ? $Format["LabelsBGAlpha"] : 50;
     $LabelPos          = isset($Format["LabelPos"]) ? $Format["LabelPos"] : RADAR_LABELS_ROTATED;
     $LabelPadding      = isset($Format["LabelPadding"]) ? $Format["LabelPadding"] : 4;
     $DrawPoints        = isset($Format["DrawPoints"]) ? $Format["DrawPoints"] : TRUE;
     $PointRadius       = isset($Format["PointRadius"]) ? $Format["PointRadius"] : 4;
     $PointSurrounding  = isset($Format["PointRadius"]) ? $Format["PointRadius"] : -30;
     $DrawLines         = isset($Format["DrawLines"]) ? $Format["DrawLines"] : TRUE;
     $LineLoopStart     = isset($Format["LineLoopStart"]) ? $Format["LineLoopStart"] : TRUE;
     $DrawPoly          = isset($Format["DrawPoly"]) ? $Format["DrawPoly"] : FALSE;
     $PolyAlpha         = isset($Format["PolyAlpha"]) ? $Format["PolyAlpha"] : 40;
     $FontSize          = $Object->FontSize;
     $X1                = $Object->GraphAreaX1;
     $Y1                = $Object->GraphAreaY1;
     $X2                = $Object->GraphAreaX2;
     $Y2                = $Object->GraphAreaY2;
 
     // if ( $AxisBoxRounded ) { $DrawAxisValues = TRUE; }
 
     /* Cancel default tick length if ticks not enabled */
     if ( $DrawTicks == FALSE ) { $TicksLength = 0; }
 
     /* Data Processing */
     $Data    = $Values->getData();
     $Palette = $Values->getPalette();
 
     /* Catch the number of required axis */
     $LabelSerie = $Data["Abscissa"];
     if ( $LabelSerie != "" )
      { $Points = count($Data["Series"][$LabelSerie]["Data"]); }
     else
      {
       $Points = 0;
       foreach($Data["Series"] as $SerieName => $DataArray)
        { if ( count($DataArray["Data"]) > $Points ) { $Points = count($DataArray["Data"]); } }
      }
 
     /* Draw the axis */
     $CenterX = ($X2-$X1)/2 + $X1;
     $CenterY = ($Y2-$Y1)/2 + $Y1;
 
     $EdgeHeight = min(($X2-$X1)/2,($Y2-$Y1)/2);
     if ( $WriteLabels )
      $EdgeHeight = $EdgeHeight - $FontSize - $LabelPadding - $TicksLength;
 
     /* Determine the scale if set to automatic */
     if ( $SegmentHeight == SEGMENT_HEIGHT_AUTO)
      {
       $Max = 0;
       foreach($Data["Series"] as $SerieName => $DataArray)
        {
         if ( $SerieName != $LabelSerie )
          {
           if ( max($DataArray["Data"]) > $Max ) { $Max = max($DataArray["Data"]); }
          }
        }
       $MaxSegments = $EdgeHeight/20;
       $Scale = $Object->computeScale(0,$Max,$MaxSegments,array(1,2,5));
 
       $Segments      = $Scale["Rows"];
       $SegmentHeight = $Scale["RowHeight"];
      }
 
     if ( $LabelMiddle && $SkipLabels == 1 )
      { $Axisoffset = (360/$Points)/2; }
     elseif ( $LabelMiddle && $SkipLabels != 1 )
      { $Axisoffset = (360/($Points/$SkipLabels))/2; }
     elseif ( !$LabelMiddle )
      { $Axisoffset = 0; }
 
     /* Background processing */
     if ( $DrawBackground )
      {
       $RestoreShadow = $Object->Shadow;
       $Object->Shadow = FALSE;
 
       if ($BackgroundGradient == NULL)
        {
         if ( $Layout == RADAR_LAYOUT_STAR )
          {
           $Color      = array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha);
           $PointArray = "";
           for($i=0;$i<=360;$i=$i+(360/$Points))
            {
             $PointArray[] = cos(deg2rad($i+$AxisRotation)) * $EdgeHeight + $CenterX;
             $PointArray[] = sin(deg2rad($i+$AxisRotation)) * $EdgeHeight + $CenterY;
            }
           $Object->drawPolygon($PointArray,$Color);
          }
         elseif ( $Layout == RADAR_LAYOUT_CIRCLE )
          {
           $Color = array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha);
           $Object->drawFilledCircle($CenterX,$CenterY,$EdgeHeight,$Color);
          }
        }
       else
        {
         $GradientROffset       = ($BackgroundGradient["EndR"] - $BackgroundGradient["StartR"]) / $Segments;
         $GradientGOffset       = ($BackgroundGradient["EndG"] - $BackgroundGradient["StartG"]) / $Segments;
         $GradientBOffset       = ($BackgroundGradient["EndB"] - $BackgroundGradient["StartB"]) / $Segments;
         $GradientAlphaOffset   = ($BackgroundGradient["EndAlpha"] - $BackgroundGradient["StartAlpha"]) / $Segments;
 
         if ( $Layout == RADAR_LAYOUT_STAR )
          {
           for($j=$Segments;$j>=1;$j--)
            {
             $Color      = array("R"=>$BackgroundGradient["StartR"]+$GradientROffset*$j,"G"=>$BackgroundGradient["StartG"]+$GradientGOffset*$j,"B"=>$BackgroundGradient["StartB"]+$GradientBOffset*$j,"Alpha"=>$BackgroundGradient["StartAlpha"]+$GradientAlphaOffset*$j);
             $PointArray = "";
 
             for($i=0;$i<=360;$i=$i+(360/$Points))
              {
               $PointArray[] = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
               $PointArray[] = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
              }
             $Object->drawPolygon($PointArray,$Color);
            }
          }
         elseif ( $Layout == RADAR_LAYOUT_CIRCLE )
          {
           for($j=$Segments;$j>=1;$j--)
            {
             $Color = array("R"=>$BackgroundGradient["StartR"]+$GradientROffset*$j,"G"=>$BackgroundGradient["StartG"]+$GradientGOffset*$j,"B"=>$BackgroundGradient["StartB"]+$GradientBOffset*$j,"Alpha"=>$BackgroundGradient["StartAlpha"]+$GradientAlphaOffset*$j);
             $Object->drawFilledCircle($CenterX,$CenterY,($EdgeHeight/$Segments)*$j,$Color);
            }
          }
        }
       $Object->Shadow = $RestoreShadow;
      }
 
     /* Axis to axis lines */
     $Color = array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha);
     $ColorDotted = array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha*.8, "Ticks"=>2);
     if ( $Layout == RADAR_LAYOUT_STAR )
      {
       for($j=1;$j<=$Segments;$j++)
        {
         for($i=0;$i<360;$i=$i+(360/$Points))
          {
           $EdgeX1 = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
           $EdgeY1 = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
           $EdgeX2 = cos(deg2rad($i+$AxisRotation+(360/$Points))) * ($EdgeHeight/$Segments)*$j + $CenterX;
           $EdgeY2 = sin(deg2rad($i+$AxisRotation+(360/$Points))) * ($EdgeHeight/$Segments)*$j + $CenterY;
 
           $Object->drawLine($EdgeX1,$EdgeY1,$EdgeX2,$EdgeY2,$Color);
          }
        }
      }
     elseif ( $Layout == RADAR_LAYOUT_CIRCLE )
      {
       for($j=1;$j<=$Segments;$j++)
        {
         $Radius = ($EdgeHeight/$Segments)*$j;
         $Object->drawCircle($CenterX,$CenterY,$Radius,$Radius,$Color);
        }
      }
 
     if ( $DrawAxisValues )
      {
       if ( $LabelsBackground )
        $Options = array("DrawBox"=>TRUE, "Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"BoxR"=>$LabelsBGR,"BoxG"=>$LabelsBGG,"BoxB"=>$LabelsBGB,"BoxAlpha"=>$LabelsBGAlpha);
       else
        $Options = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE);
 
       if ( $AxisBoxRounded ) { $Options["BoxRounded"] = TRUE; }
 
       $Options["FontName"] = $AxisFontName;
       $Options["FontSize"] = $AxisFontSize;
 
       $Angle  = 360 / ($Points*2);
       for($j=1;$j<=$Segments;$j++)
        {
         $Label  = $j * $SegmentHeight;
 
         if ( $Layout == RADAR_LAYOUT_CIRCLE )
          {
           $EdgeX1 = cos(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
           $EdgeY1 = sin(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
          }
         elseif ( $Layout == RADAR_LAYOUT_STAR )
          {
           $EdgeX1 = cos(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
           $EdgeY1 = sin(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
           $EdgeX2 = cos(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
           $EdgeY2 = sin(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
 
           $EdgeX1 = ($EdgeX2 - $EdgeX1)/2 + $EdgeX1;
           $EdgeY1 = ($EdgeY2 - $EdgeY1)/2 + $EdgeY1;
          }
 
         $Object->drawText($EdgeX1,$EdgeY1,$Label,$Options);
        }
      }
 
     /* Axis lines */
     $ID = 0;
     for($i=0;$i<360;$i=$i+(360/$Points))
      {
       $EdgeX = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterX;
       $EdgeY = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterY;
 
       if ($ID % $SkipLabels == 0)
        { $Object->drawLine($CenterX,$CenterY,$EdgeX,$EdgeY,$Color); }
       else
        { $Object->drawLine($CenterX,$CenterY,$EdgeX,$EdgeY,$ColorDotted); }
 
       if ( $WriteLabels )
        {
         $LabelX = cos(deg2rad($i+$AxisRotation+$Axisoffset)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterX;
         $LabelY = sin(deg2rad($i+$AxisRotation+$Axisoffset)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterY;
 
         if ( $LabelSerie != "" )
          { $Label = isset($Data["Series"][$LabelSerie]["Data"][$ID]) ? $Data["Series"][$LabelSerie]["Data"][$ID] : ""; }
         else
          $Label = $ID;
 
         if ($ID % $SkipLabels == 0)
          {
           if ( $LabelPos == RADAR_LABELS_ROTATED )
            $Object->drawText($LabelX,$LabelY,$Label,array("Angle"=>(360-($i+$AxisRotation+$Axisoffset))-90,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
           else
            {
             if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
             if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMLEFT)); }
             if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) == floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
             if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPLEFT)); }
             if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); }
             if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) == floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); }
             if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPRIGHT)); }
             if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )  { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPMIDDLE)); }
            }
          }
        }
       $ID++;
      }
 
     /* Compute the plots position */
     $ID = 0; $Plot = "";
     foreach($Data["Series"] as $SerieName => $Data)
      {
       if ( $SerieName != $LabelSerie )
        {
         $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
         foreach($Data["Data"] as $Key => $Value)
          {
           $Angle  = (360/$Points) * $Key;
           $Length = ($EdgeHeight/($Segments*$SegmentHeight))*$Value;
 
           $X = cos(deg2rad($Angle+$AxisRotation)) * $Length  + $CenterX;
           $Y = sin(deg2rad($Angle+$AxisRotation)) * $Length  + $CenterY;
 
           $Plot[$ID][] = array($X,$Y);
          }
         $ID++;
        }
      }
 
     /* Draw all that stuff! */
     foreach($Plot as $ID => $Points)
      {
       $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
 
       /* Draw the polygons */
       if ( $DrawPoly )
        {
         if ($PolyAlpha != NULL)
          $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$PolyAlpha,"Surrounding"=>$PointSurrounding);
 
         $PointsArray = "";
         for($i=0; $i<count($Points);$i++) 
          { $PointsArray[] = $Points[$i][0]; $PointsArray[] = $Points[$i][1]; }
         $Object->drawPolygon($PointsArray,$Color);
        }
 
       $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
 
       /* Draw the lines & points */
       for($i=0; $i<count($Points);$i++) 
        {
         if ( $DrawLines && $i < count($Points)-1)
          $Object->drawLine($Points[$i][0],$Points[$i][1],$Points[$i+1][0],$Points[$i+1][1],$Color);
 
         if ( $DrawPoints )
          $Object->drawFilledCircle($Points[$i][0],$Points[$i][1],$PointRadius,$Color);
        }
 
       /* Loop to the starting points if asked */
       if ( $LineLoopStart && $DrawLines )
        $Object->drawLine($Points[$i-1][0],$Points[$i-1][1],$Points[0][0],$Points[0][1],$Color);
 
      }
    }
 
 
 
   /* Draw a radar chart */
   function drawPolar($Object,$Values,$Format="")
    {
     $this->pChartObject = $Object;
 
     $AxisR             = isset($Format["AxisR"]) ? $Format["AxisR"] : 60;
     $AxisG             = isset($Format["AxisG"]) ? $Format["AxisG"] : 60;
     $AxisB             = isset($Format["AxisB"]) ? $Format["AxisB"] : 60;
     $AxisAlpha         = isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 50;
     $AxisRotation      = isset($Format["AxisRotation"]) ? $Format["AxisRotation"] : -90;
     $DrawTicks         = isset($Format["DrawTicks"]) ? $Format["DrawTicks"] : TRUE;
     $TicksLength       = isset($Format["TicksLength"]) ? $Format["TicksLength"] : 2;
     $DrawAxisValues    = isset($Format["DrawAxisValues"]) ? $Format["DrawAxisValues"] : TRUE;
     $AxisBoxRounded    = isset($Format["AxisBoxRounded"]) ? $Format["AxisBoxRounded"] : TRUE;
     $AxisFontName      = isset($Format["FontName"]) ? $Format["FontName"] : $this->pChartObject->FontName;
     $AxisFontSize      = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->pChartObject->FontSize;
     $DrawBackground    = isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : TRUE;
     $BackgroundR       = isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255;
     $BackgroundG       = isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255;
     $BackgroundB       = isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255;
     $BackgroundAlpha   = isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 50;
     $BackgroundGradient= isset($Format["BackgroundGradient"]) ? $Format["BackgroundGradient"] : NULL;
     $AxisSteps         = isset($Format["AxisSteps"]) ? $Format["AxisSteps"] : 20;
     $SegmentHeight     = isset($Format["SegmentHeight"]) ? $Format["SegmentHeight"] : SEGMENT_HEIGHT_AUTO;
     $Segments          = isset($Format["Segments"]) ? $Format["Segments"] : 4;
     $WriteLabels       = isset($Format["WriteLabels"]) ? $Format["WriteLabels"] : TRUE;
     $LabelsBackground  = isset($Format["LabelsBackground"]) ? $Format["LabelsBackground"] : TRUE;
     $LabelsBGR         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGR"] : 255;
     $LabelsBGG         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGG"] : 255;
     $LabelsBGB         = isset($Format["LabelsBGR"]) ? $Format["LabelsBGB"] : 255;
     $LabelsBGAlpha     = isset($Format["LabelsBGAlpha"]) ? $Format["LabelsBGAlpha"] : 50;
     $LabelPos          = isset($Format["LabelPos"]) ? $Format["LabelPos"] : RADAR_LABELS_ROTATED;
     $LabelPadding      = isset($Format["LabelPadding"]) ? $Format["LabelPadding"] : 4;
     $DrawPoints        = isset($Format["DrawPoints"]) ? $Format["DrawPoints"] : TRUE;
     $PointRadius       = isset($Format["PointRadius"]) ? $Format["PointRadius"] : 4;
     $PointSurrounding  = isset($Format["PointRadius"]) ? $Format["PointRadius"] : -30;
     $DrawLines         = isset($Format["DrawLines"]) ? $Format["DrawLines"] : TRUE;
     $LineLoopStart     = isset($Format["LineLoopStart"]) ? $Format["LineLoopStart"] : FALSE;
     $DrawPoly          = isset($Format["DrawPoly"]) ? $Format["DrawPoly"] : FALSE;
     $PolyAlpha         = isset($Format["PolyAlpha"]) ? $Format["PolyAlpha"] : NULL;
     $FontSize          = $Object->FontSize;
     $X1                = $Object->GraphAreaX1;
     $Y1                = $Object->GraphAreaY1;
     $X2                = $Object->GraphAreaX2;
     $Y2                = $Object->GraphAreaY2;
 
     if ( $AxisBoxRounded ) { $DrawAxisValues = TRUE; }
 
     /* Cancel default tick length if ticks not enabled */
     if ( $DrawTicks == FALSE ) { $TicksLength = 0; }
 
     /* Data Processing */
     $Data    = $Values->getData();
     $Palette = $Values->getPalette();
 
     /* Catch the number of required axis */
     $LabelSerie = $Data["Abscissa"];
     if ( $LabelSerie != "" )
      { $Points = count($Data["Series"][$LabelSerie]["Data"]); }
     else
      {
       $Points = 0;
       foreach($Data["Series"] as $SerieName => $DataArray)
        { if ( count($DataArray["Data"]) > $Points ) { $Points = count($DataArray["Data"]); } }
      }
 
     /* Draw the axis */
     $CenterX = ($X2-$X1)/2 + $X1;
     $CenterY = ($Y2-$Y1)/2 + $Y1;
 
     $EdgeHeight = min(($X2-$X1)/2,($Y2-$Y1)/2);
     if ( $WriteLabels )
      $EdgeHeight = $EdgeHeight - $FontSize - $LabelPadding - $TicksLength;
 
     /* Determine the scale if set to automatic */
     if ( $SegmentHeight == SEGMENT_HEIGHT_AUTO)
      {
       $Max = 0;
       foreach($Data["Series"] as $SerieName => $DataArray)
        {
         if ( $SerieName != $LabelSerie )
          {
           if ( max($DataArray["Data"]) > $Max ) { $Max = max($DataArray["Data"]); }
          }
        }
       $MaxSegments = $EdgeHeight/20;
       $Scale = $Object->computeScale(0,$Max,$MaxSegments,array(1,2,5));
 
       $Segments      = $Scale["Rows"];
       $SegmentHeight = $Scale["RowHeight"];
      }
 
 
     /* Background processing */
     if ( $DrawBackground )
      {
       $RestoreShadow = $Object->Shadow;
       $Object->Shadow = FALSE;
 
       if ($BackgroundGradient == NULL)
        {
         $Color = array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha);
         $Object->drawFilledCircle($CenterX,$CenterY,$EdgeHeight,$Color);
        }
       else
        {
         $GradientROffset       = ($BackgroundGradient["EndR"] - $BackgroundGradient["StartR"]) / $Segments;
         $GradientGOffset       = ($BackgroundGradient["EndG"] - $BackgroundGradient["StartG"]) / $Segments;
         $GradientBOffset       = ($BackgroundGradient["EndB"] - $BackgroundGradient["StartB"]) / $Segments;
         $GradientAlphaOffset   = ($BackgroundGradient["EndAlpha"] - $BackgroundGradient["StartAlpha"]) / $Segments;
 
         for($j=$Segments;$j>=1;$j--)
          {
           $Color      = array("R"=>$BackgroundGradient["StartR"]+$GradientROffset*$j,"G"=>$BackgroundGradient["StartG"]+$GradientGOffset*$j,"B"=>$BackgroundGradient["StartB"]+$GradientBOffset*$j,"Alpha"=>$BackgroundGradient["StartAlpha"]+$GradientAlphaOffset*$j);
           $Object->drawFilledCircle($CenterX,$CenterY,($EdgeHeight/$Segments)*$j,$Color);
          }
        }
       $Object->Shadow = $RestoreShadow;
      }
 
     /* Axis to axis lines */
     $Color = array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha);
     for($j=1;$j<=$Segments;$j++)
      {
       $Radius = ($EdgeHeight/$Segments)*$j;
       $Object->drawCircle($CenterX,$CenterY,$Radius,$Radius,$Color);
      }
 
     if ( $DrawAxisValues )
      {
       if ( $LabelsBackground )
        $Options = array("DrawBox"=>TRUE, "Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"BoxR"=>$LabelsBGR,"BoxG"=>$LabelsBGG,"BoxB"=>$LabelsBGB,"BoxAlpha"=>$LabelsBGAlpha);
       else
        $Options = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE);
 
       if ( $AxisBoxRounded ) { $Options["BoxRounded"] = TRUE; }
 
       $Options["FontName"] = $AxisFontName;
       $Options["FontSize"] = $AxisFontSize;
 
       $Angle  = 360 / ($Points*2);
       for($j=1;$j<=$Segments;$j++)
        {
         $EdgeX1 = cos(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX;
         $EdgeY1 = sin(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
         $Label  = $j*$SegmentHeight;
 
         $Object->drawText($EdgeX1,$EdgeY1,$Label,$Options);
        }
      }
 
     /* Axis lines */
     $ID = 0;
     for($i=0;$i<=359;$i=$i+$AxisSteps)
      {
       $EdgeX = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterX;
       $EdgeY = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$TicksLength) + $CenterY;
 
       $Object->drawLine($CenterX,$CenterY,$EdgeX,$EdgeY,$Color);
 
       if ( $WriteLabels )
        {
         $LabelX = cos(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterX;
         $LabelY = sin(deg2rad($i+$AxisRotation)) * ($EdgeHeight+$LabelPadding+$TicksLength) + $CenterY;
         $Label = $i."";
 
         if ( $LabelPos == RADAR_LABELS_ROTATED )
          $Object->drawText($LabelX,$LabelY,$Label,array("Angle"=>(360-$i),"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
         else
          {
           if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
           if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMLEFT)); }
           if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) == floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
           if ( (floor($LabelX) >  floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPLEFT)); }
           if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) <  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_BOTTOMRIGHT)); }
           if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) == floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); }
           if ( (floor($LabelX) <  floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPRIGHT)); }
           if ( (floor($LabelX) == floor($CenterX)) && (floor($LabelY) >  floor($CenterY)) )    { $Object->drawText($LabelX,$LabelY,$Label,array("Align"=>TEXT_ALIGN_TOPMIDDLE)); }
          }
        }
       $ID++;
      }
 
     /* Compute the plots position */
     $ID = 0; $Plot = "";
     foreach($Data["Series"] as $SerieName => $DataSet)
      {
       if ( $SerieName != $LabelSerie )
        {
         $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
         foreach($DataSet["Data"] as $Key => $Value)
          {
           $Angle  = $Data["Series"][$LabelSerie]["Data"][$Key];
           $Length = ($EdgeHeight/($Segments*$SegmentHeight))*$Value;
 
           $X = cos(deg2rad($Angle+$AxisRotation)) * $Length  + $CenterX;
           $Y = sin(deg2rad($Angle+$AxisRotation)) * $Length  + $CenterY;
 
           $Plot[$ID][] = array($X,$Y);
          }
         $ID++;
        }
      }
 
     /* Draw all that stuff! */
     foreach($Plot as $ID => $Points)
      {
       $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
 
       /* Draw the polygons */
       if ( $DrawPoly )
        {
         if ($PolyAlpha != NULL)
          $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$PolyAlpha,"Surrounding"=>$PointSurrounding);
 
         $PointsArray = "";
         for($i=0; $i<count($Points);$i++) 
          { $PointsArray[] = $Points[$i][0]; $PointsArray[] = $Points[$i][1]; }
 
         $Object->drawPolygon($PointsArray,$Color);
        }
 
       $Color = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"],"Surrounding"=>$PointSurrounding);
       
       /* Draw the lines & points */
       for($i=0; $i<count($Points);$i++) 
        {
         if ( $DrawLines && $i < count($Points)-1)
          $Object->drawLine($Points[$i][0],$Points[$i][1],$Points[$i+1][0],$Points[$i+1][1],$Color);
 
         if ( $DrawPoints )
          $Object->drawFilledCircle($Points[$i][0],$Points[$i][1],$PointRadius,$Color);
        }
 
       /* Loop to the starting points if asked */
       if ( $LineLoopStart && $DrawLines )
        $Object->drawLine($Points[$i-1][0],$Points[$i-1][1],$Points[0][0],$Points[0][1],$Color);
      }
    }
  }
?>