Translation update done using Pootle.
[phpmyadmin-themes.git] / libraries / chart / pma_chart.php
blob670880417f93109631e0a49fa9abdf856323e8af
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Holds the base class that all charts inherit from and some widely used
5 * constants.
6 * @package phpMyAdmin
7 */
9 /**
12 define('RED', 0);
13 define('GREEN', 1);
14 define('BLUE', 2);
16 /**
17 * The base class that all charts inherit from.
18 * @abstract
19 * @package phpMyAdmin
21 abstract class PMA_chart
23 /**
24 * @var array All the default settigs values are here.
26 protected $settings = array(
28 // Default title for every chart.
29 'titleText' => 'Chart',
31 // The style of the chart title.
32 'titleColor' => '#FAFAFA',
34 // Colors for the different slices in the pie chart.
35 'colors' => array(
36 '#BCE02E',
37 '#E0642E',
38 '#E0D62E',
39 '#2E97E0',
40 '#B02EE0',
41 '#E02E75',
42 '#5CE02E',
43 '#E0B02E',
44 '#000000',
45 '#0022E0',
46 '#726CB1',
47 '#481A36',
48 '#BAC658',
49 '#127224',
50 '#825119',
51 '#238C74',
52 '#4C489B',
53 '#87C9BF',
56 // Chart background color.
57 'bgColor' => '#84AD83',
59 // The width of the chart.
60 'width' => 520,
62 // The height of the chart.
63 'height' => 325,
65 // Default X Axis label. If empty, label will be taken from the data.
66 'xLabel' => '',
68 // Default Y Axis label. If empty, label will be taken from the data.
69 'yLabel' => '',
72 /**
73 * @var array Options that the user has specified
75 private $userSpecifiedSettings = null;
77 /**
78 * @var array Error codes will be stored here
80 protected $errors = array();
82 /**
83 * Store user specified options
84 * @param array $options users specified options
86 function __construct($options = null)
88 $this->userSpecifiedSettings = $options;
91 /**
92 * All the variable initialization has to be done here.
94 protected function init()
96 $this->handleOptions();
99 /**
100 * A function which handles passed parameters. Useful if desired
101 * chart needs to be a little bit different from the default one.
103 private function handleOptions()
105 if (is_null($this->userSpecifiedSettings)) {
106 return;
109 $this->settings = array_merge($this->settings, $this->userSpecifiedSettings);
112 protected function getTitleText()
114 return $this->settings['titleText'];
117 protected function getTitleColor($component)
119 return $this->hexStrToDecComp($this->settings['titleColor'], $component);
122 protected function getColors()
124 return $this->settings['colors'];
127 protected function getWidth()
129 return $this->settings['width'];
132 protected function getHeight()
134 return $this->settings['height'];
137 protected function getBgColor($component)
139 return $this->hexStrToDecComp($this->settings['bgColor'], $component);
142 protected function setXLabel($label)
144 $this->settings['xLabel'] = $label;
147 protected function getXLabel()
149 return $this->settings['xLabel'];
152 protected function setYLabel($label)
154 $this->settings['yLabel'] = $label;
157 protected function getYLabel()
159 return $this->settings['yLabel'];
162 public function getSettings()
164 return $this->settings;
167 public function getErrors()
169 return $this->errors;
173 * Get one the dec color component from the hex color string
174 * @param string $colorString color string, i.e. #5F22A99
175 * @param int $component color component to get, i.e. 0 gets red.
177 protected function hexStrToDecComp($colorString, $component)
179 return hexdec(substr($colorString, ($component * 2) + 1, 2));