fixed option hendling
This commit is contained in:
@@ -35,7 +35,7 @@ function PMA_chart_status($data)
|
||||
//$chart = new PMA_OFC_Pie(__('Query type'), $chartData, $options);
|
||||
$chart = new PMA_pChart_Pie(
|
||||
__('Query statistics'),
|
||||
$chartData);
|
||||
array_slice($chartData, 0, 20, true));
|
||||
echo $chart->toString();
|
||||
}
|
||||
|
||||
@@ -203,8 +203,9 @@ function PMA_chart_results($data, &$chartSettings)
|
||||
return __('Unknown data format.');
|
||||
}
|
||||
|
||||
$chartCode = $chart->toString();
|
||||
$chartSettings = $chart->getSettings();
|
||||
return $chart->toString();
|
||||
return $chartCode;
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -66,63 +66,70 @@ class PMA_Chart
|
||||
'yLabel' => '',
|
||||
);
|
||||
|
||||
/*
|
||||
* Options that the user has specified
|
||||
*/
|
||||
private $userSpecifiedSettings = null;
|
||||
|
||||
function __construct($options = null)
|
||||
{
|
||||
$this->handleOptions($options);
|
||||
$this->userSpecifiedSettings = $options;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->handleOptions();
|
||||
}
|
||||
|
||||
/*
|
||||
* A function which handles passed parameters. Useful if desired
|
||||
* chart needs to be a little bit different from the default one.
|
||||
*
|
||||
* Option handling could be made more efficient if options would be
|
||||
* stored in an array.
|
||||
*/
|
||||
function handleOptions($options)
|
||||
private function handleOptions()
|
||||
{
|
||||
if (is_null($options)) {
|
||||
if (is_null($this->userSpecifiedSettings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->settings = array_merge($this->settings, $options);
|
||||
$this->settings = array_merge($this->settings, $this->userSpecifiedSettings);
|
||||
}
|
||||
|
||||
function getTitleStyle()
|
||||
protected function getTitleStyle()
|
||||
{
|
||||
return $this->settings['titleStyle'];
|
||||
}
|
||||
|
||||
function getColors()
|
||||
protected function getColors()
|
||||
{
|
||||
return $this->settings['colors'];
|
||||
}
|
||||
|
||||
function getWidth()
|
||||
protected function getWidth()
|
||||
{
|
||||
return $this->settings['width'];
|
||||
}
|
||||
|
||||
function getHeight()
|
||||
protected function getHeight()
|
||||
{
|
||||
return $this->settings['height'];
|
||||
}
|
||||
|
||||
function getBgColor($component)
|
||||
protected function getBgColor($component)
|
||||
{
|
||||
return hexdec(substr($this->settings['bgColor'], ($component * 2) + 1, 2));
|
||||
}
|
||||
|
||||
function getXLabel()
|
||||
protected function getXLabel()
|
||||
{
|
||||
return $this->settings['xLabel'];
|
||||
}
|
||||
|
||||
function getYLabel()
|
||||
protected function getYLabel()
|
||||
{
|
||||
return $this->settings['yLabel'];
|
||||
}
|
||||
|
||||
function getSettings()
|
||||
public function getSettings()
|
||||
{
|
||||
return $this->settings;
|
||||
}
|
||||
|
@@ -42,6 +42,8 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// create pChart object
|
||||
$this->chart = new pChart($this->getWidth(), $this->getHeight());
|
||||
|
||||
@@ -145,9 +147,7 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
||||
|
||||
protected function setAreaMargins($areaMargins)
|
||||
{
|
||||
if (!isset($this->settings['areaMargins'])) {
|
||||
$this->settings['areaMargins'] = $areaMargins;
|
||||
}
|
||||
$this->settings['areaMargins'] = $areaMargins;
|
||||
}
|
||||
|
||||
protected function getAreaMargin($side)
|
||||
|
@@ -8,7 +8,7 @@ class PMA_pChart_Pie extends PMA_pChart_multi
|
||||
{
|
||||
parent::__construct($titleText, $data, $options);
|
||||
|
||||
$this->setAreaMargins(array(20, 20, 20, 10));
|
||||
$this->setAreaMargins(array(20, 10, 20, 20));
|
||||
}
|
||||
|
||||
protected function prepareDataSet()
|
||||
|
Reference in New Issue
Block a user