Update based on master
[phpmyadmin-regexreplace.git] / libraries / chart / pma_pchart_pie.php
blob0366ba48ba246da3cd636965f9784f35a1807ccb
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin
5 */
7 /**
9 */
10 require_once 'pma_pchart_multi.php';
12 /**
13 * implements pie chart
14 * @package phpMyAdmin
16 class PMA_pChart_Pie extends PMA_pChart_multi
18 public function __construct($data, $options = null)
20 // limit data size, no more than 18 pie slices
21 $data = array_slice($data, 0, 18, true);
22 parent::__construct($data, $options);
24 $this->setAreaMargins(array(20, 10, 20, 20));
27 /**
28 * prepare data set for the pie chart
30 protected function prepareDataSet()
32 // Dataset definition
33 $this->dataSet->AddPoint(array_values($this->data), "Values");
34 $this->dataSet->AddPoint(array_keys($this->data), "Keys");
35 $this->dataSet->AddAllSeries();
36 $this->dataSet->SetAbsciseLabelSerie("Keys");
39 /**
40 * graph area for the pie chart does not include grid lines
42 protected function drawGraphArea()
44 $this->chart->drawGraphArea(
45 $this->getGraphAreaColor(RED),
46 $this->getGraphAreaColor(GREEN),
47 $this->getGraphAreaColor(BLUE),
48 FALSE
51 if($this->settings['gradientIntensity']>0)
52 $this->chart->drawGraphAreaGradient(
53 $this->getGraphAreaGradientColor(RED),
54 $this->getGraphAreaGradientColor(GREEN),
55 $this->getGraphAreaGradientColor(BLUE),
56 $this->settings['gradientIntensity']
58 else
59 $this->chart->drawGraphArea(
60 $this->getGraphAreaGradientColor(RED),
61 $this->getGraphAreaGradientColor(GREEN),
62 $this->getGraphAreaGradientColor(BLUE)
67 /**
68 * draw the pie chart
70 protected function drawChart()
72 parent::drawChart();
74 // draw pie chart in the middle of graph area
75 $middleX = ($this->chart->GArea_X1 + $this->chart->GArea_X2) / 2;
76 $middleY = ($this->chart->GArea_Y1 + $this->chart->GArea_Y2) / 2;
78 $this->chart->drawPieGraph(
79 $this->dataSet->GetData(),
80 $this->dataSet->GetDataDescription(),
81 $middleX,
82 // pie graph is skewed. Upper part is shorter than the
83 // lower part. This is why we set an offset to the
84 // Y middle coordiantes.
85 $middleY - 15,
86 120, PIE_PERCENTAGE, FALSE, 60, 30, 10, 1);
89 /**
90 * draw legend for the pie chart
92 protected function drawLegend()
94 $this->chart->drawPieLegend(
95 $this->getWidth() - $this->getLegendMargin(RIGHT) - $this->getLegendBoxWidth(),
96 $this->getLabelHeight() + $this->getLegendMargin(TOP),
97 $this->dataSet->GetData(),
98 $this->dataSet->GetDataDescription(),
99 250, 250, 250);
102 protected function getLegendBoxWidth()
104 $legendSize = $this->chart->getPieLegendBoxSize($this->dataSet->GetData());
105 return $legendSize[0];