Merge branch 'QA_3_4'
[phpmyadmin-regexreplace.git] / libraries / chart / pma_pchart_single_radar.php
blob659058217ef92e871b474c9d360cfc37eeb91eb2
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin
5 */
7 /**
8 *
9 */
10 require_once 'pma_pchart_single.php';
12 /**
13 * implements single radar chart
14 * @package phpMyAdmin
16 class PMA_pChart_single_radar extends PMA_pChart_single
18 public function __construct($data, $options = null)
20 parent::__construct($data, $options);
22 $this->normalizeValues();
25 /**
26 * Get the largest value from the data and normalize all the other values.
28 private function normalizeValues()
30 $maxValue = 0;
31 $keys = array_keys($this->data);
32 $valueKey = $keys[0];
33 $maxValue = max($this->data[$valueKey]);
35 foreach ($this->data[$valueKey] as &$value) {
36 $value = $value / $maxValue * 10;
40 /**
41 * graph area for the radar chart does not include grid lines
43 protected function drawGraphArea()
45 $this->chart->drawGraphArea(
46 $this->getGraphAreaColor(RED),
47 $this->getGraphAreaColor(GREEN),
48 $this->getGraphAreaColor(BLUE),
49 FALSE
52 if($this->settings['gradientIntensity']>0)
53 $this->chart->drawGraphAreaGradient(
54 $this->getGraphAreaGradientColor(RED),
55 $this->getGraphAreaGradientColor(GREEN),
56 $this->getGraphAreaGradientColor(BLUE),
57 $this->settings['gradientIntensity']
59 else
60 $this->chart->drawGraphArea(
61 $this->getGraphAreaGradientColor(RED),
62 $this->getGraphAreaGradientColor(GREEN),
63 $this->getGraphAreaGradientColor(BLUE)
68 /**
69 * draws the radar chart
71 protected function drawChart()
73 // when drawing radar graph we can specify the border from the top of
74 // graph area. We want border to be dynamic, so that either the top
75 // or the side of the radar is some distance away from the top or the
76 // side of the graph area.
77 $areaWidth = $this->chart->GArea_X2 - $this->chart->GArea_X1;
78 $areaHeight = $this->chart->GArea_Y2 - $this->chart->GArea_Y1;
80 if ($areaHeight > $areaWidth) {
81 $borderOffset = ($areaHeight - $areaWidth) / 2;
83 else {
84 $borderOffset = 0;
87 // the least ammount that radar is away from the graph area side.
88 $borderOffset += 40;
90 $this->chart->drawRadarAxis($this->dataSet->GetData(), $this->dataSet->GetDataDescription(),
91 TRUE, $borderOffset, 120, 120, 120, 230, 230, 230, -1, 2);
92 $this->chart->drawFilledRadar($this->dataSet->GetData(), $this->dataSet->GetDataDescription(), 50, $borderOffset);