2 /* vim: set expandtab sw=4 ts=4 sts=4: */
10 require_once 'pma_pchart_multi.php';
13 * implements pie chart
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));
28 * prepare data set for the pie chart
30 protected function prepareDataSet()
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");
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
),
50 $this->chart
->drawGraphAreaGradient(
51 $this->getGraphAreaGradientColor(RED
),
52 $this->getGraphAreaGradientColor(GREEN
),
53 $this->getGraphAreaGradientColor(BLUE
),
61 protected function drawChart()
65 // draw pie chart in the middle of graph area
66 $middleX = ($this->chart
->GArea_X1 +
$this->chart
->GArea_X2
) / 2;
67 $middleY = ($this->chart
->GArea_Y1 +
$this->chart
->GArea_Y2
) / 2;
69 $this->chart
->drawPieGraph(
70 $this->dataSet
->GetData(),
71 $this->dataSet
->GetDataDescription(),
73 // pie graph is skewed. Upper part is shorter than the
74 // lower part. This is why we set an offset to the
75 // Y middle coordiantes.
77 120, PIE_PERCENTAGE
, FALSE, 60, 30, 10, 1);
81 * draw legend for the pie chart
83 protected function drawLegend()
85 $this->chart
->drawPieLegend(
86 $this->getWidth() - $this->getLegendMargin(RIGHT
) - $this->getLegendBoxWidth(),
87 $this->getLabelHeight() +
$this->getLegendMargin(TOP
),
88 $this->dataSet
->GetData(),
89 $this->dataSet
->GetDataDescription(),
93 protected function getLegendBoxWidth()
95 $legendSize = $this->chart
->getPieLegendBoxSize($this->dataSet
->GetData());
96 return $legendSize[0];