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
),
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']
59 $this->chart
->drawGraphArea(
60 $this->getGraphAreaGradientColor(RED
),
61 $this->getGraphAreaGradientColor(GREEN
),
62 $this->getGraphAreaGradientColor(BLUE
)
70 protected function 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(),
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.
86 120, PIE_PERCENTAGE
, FALSE, 60, 30, 10, 1);
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(),
102 protected function getLegendBoxWidth()
104 $legendSize = $this->chart
->getPieLegendBoxSize($this->dataSet
->GetData());
105 return $legendSize[0];