Translation update done using Pootle.
[phpmyadmin-themes.git] / libraries / chart / pma_pchart_multi.php
blob171cc50fe5855ee9b08672408e153f29bbef9e3d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * @package phpMyAdmin
5 */
7 /**
9 */
10 require_once 'pma_pchart_chart.php';
12 /**
13 * Base class for every chart that uses multiple series.
14 * All of these charts will require legend box.
15 * @abstract
16 * @package phpMyAdmin
18 abstract class PMA_pChart_multi extends PMA_pChart_chart
20 public function __construct($data, $options = null)
22 parent::__construct($data, $options);
24 // as in CSS (top, right, bottom, left)
25 $this->setLegendMargins(array(20, 10, 0, 0));
28 /**
29 * data set preparation for multi serie graphs
31 protected function prepareDataSet()
33 $values = array_values($this->data);
34 $keys = array_keys($this->data);
36 // Dataset definition
37 $this->dataSet->AddPoint($values[0], "Keys");
39 $i = 0;
40 foreach ($values[1] as $seriesName => $seriesData) {
41 $this->dataSet->AddPoint($seriesData, "Values".$i);
42 $this->dataSet->SetSerieName($seriesName, "Values".$i);
43 $i++;
45 $this->dataSet->AddAllSeries();
47 $this->dataSet->RemoveSerie("Keys");
48 $this->dataSet->SetAbsciseLabelSerie("Keys");
50 $xLabel = $this->getXLabel();
51 if (empty($xLabel)) {
52 $this->setXLabel($keys[0]);
54 $yLabel = $this->getYLabel();
55 if (empty($yLabel)) {
56 $this->setYLabel($keys[1]);
59 $this->dataSet->SetXAxisName($this->getXLabel());
60 $this->dataSet->SetYAxisName($this->getYLabel());
63 /**
64 * set graph area dimensions with respect to legend box size
66 protected function setGraphAreaDimensions()
68 $this->chart->setGraphArea(
69 $this->getAreaMargin(LEFT),
70 $this->getLabelHeight() + $this->getAreaMargin(TOP),
71 $this->getWidth() - $this->getAreaMargin(RIGHT) - $this->getLegendBoxWidth() - $this->getLegendMargin(LEFT) - $this->getLegendMargin(RIGHT),
72 $this->getHeight() - $this->getAreaMargin(BOTTOM)
76 /**
77 * multi serie charts need a legend. draw it
79 protected function drawChart()
81 $this->drawLegend();
84 /**
85 * draws a legend
87 protected function drawLegend()
89 // Draw the legend
90 $this->chart->drawLegend(
91 $this->getWidth() - $this->getLegendMargin(RIGHT) - $this->getLegendBoxWidth(),
92 $this->getLabelHeight() + $this->getLegendMargin(TOP),
93 $this->dataSet->GetDataDescription(),
94 250,250,250,50,50,50
98 protected function setLegendMargins($legendMargins)
100 if (!isset($this->settings['legendMargins'])) {
101 $this->settings['legendMargins'] = $legendMargins;
105 protected function getLegendMargin($side)
107 return $this->settings['legendMargins'][$side];
110 protected function getLegendBoxWidth()
112 $legendSize = $this->chart->getLegendBoxSize($this->dataSet->GetDataDescription());
113 return $legendSize[0];