diff --git a/libraries/chart.lib.php b/libraries/chart.lib.php index 0f2015a1e..1b7c3079c 100644 --- a/libraries/chart.lib.php +++ b/libraries/chart.lib.php @@ -32,10 +32,10 @@ function PMA_chart_status($data) $chartData[$key] = $value; } - //$chart = new PMA_OFC_Pie(__('Query type'), $chartData, $options); $chart = new PMA_pChart_Pie( - __('Query statistics'), - array_slice($chartData, 0, 18, true)); + array_slice($chartData, 0, 18, true), + array('titleText' => __('Query statistics')) + ); $chartCode = $chart->toString(); PMA_handle_chart_err($chart->getErrors()); echo $chartCode; @@ -54,8 +54,9 @@ function PMA_chart_profiling($data) } $chart = new PMA_pChart_Pie( - __('Query execution time comparison (in microseconds)'), - array_slice($chartData, 0, 18, true)); + array_slice($chartData, 0, 18, true), + array('titleText' => __('Query execution time comparison (in microseconds)')) + ); $chartCode = $chart->toString(); PMA_handle_chart_err($chart->getErrors()); echo $chartCode; @@ -70,11 +71,8 @@ function PMA_chart_results($data, &$chartSettings) $chart = null; // set default title if not already set - if (!empty($chartSettings['title'])) { - $chartTitle = $chartSettings['title']; - } - else { - $chartTitle = __('Query results'); + if (empty($chartSettings['titleText'])) { + $chartSettings['titleText'] = __('Query results'); } // set default type if not already set @@ -111,7 +109,7 @@ function PMA_chart_results($data, &$chartSettings) } $chartSettings['legend'] = true; - $chart = new PMA_pChart_pie($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_pie($chartData, $chartSettings); } else { // loop through the rows @@ -125,13 +123,13 @@ function PMA_chart_results($data, &$chartSettings) switch ($chartSettings['type']) { case 'bar': default: - $chart = new PMA_pChart_single_bar($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_single_bar($chartData, $chartSettings); break; case 'line': - $chart = new PMA_pChart_single_line($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_single_line($chartData, $chartSettings); break; case 'radar': - $chart = new PMA_pChart_single_radar($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_single_radar($chartData, $chartSettings); break; } } @@ -186,19 +184,19 @@ function PMA_chart_results($data, &$chartSettings) switch ($chartSettings['barType']) { case 'stacked': default: - $chart = new PMA_pChart_stacked_bar($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_stacked_bar($chartData, $chartSettings); break; case 'multi': - $chart = new PMA_pChart_multi_bar($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_multi_bar($chartData, $chartSettings); break; } break; case 'line': - $chart = new PMA_pChart_multi_line($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_multi_line($chartData, $chartSettings); break; case 'radar': - $chart = new PMA_pChart_multi_radar($chartTitle, $chartData, $chartSettings); + $chart = new PMA_pChart_multi_radar($chartData, $chartSettings); break; } } diff --git a/libraries/chart/pma_chart.php b/libraries/chart/pma_chart.php index 305f3e220..9ecfa7ad2 100644 --- a/libraries/chart/pma_chart.php +++ b/libraries/chart/pma_chart.php @@ -10,6 +10,12 @@ class PMA_Chart * The settings array. All the default values are here. */ protected $settings = array( + + /* + * Default title for every chart. + */ + 'titleText' => 'Chart', + /* * The style of the chart title. */ @@ -98,6 +104,11 @@ class PMA_Chart $this->settings = array_merge($this->settings, $this->userSpecifiedSettings); } + protected function getTitleText() + { + return $this->settings['titleText']; + } + protected function getTitleStyle() { return $this->settings['titleStyle']; diff --git a/libraries/chart/pma_pchart_chart.php b/libraries/chart/pma_pchart_chart.php index 710a60fc0..80d7f68c2 100644 --- a/libraries/chart/pma_pchart_chart.php +++ b/libraries/chart/pma_pchart_chart.php @@ -23,11 +23,10 @@ abstract class PMA_pChart_Chart extends PMA_Chart protected $imageEncoded; - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { parent::__construct($options); - $this->titleText = $titleText; $this->data = $data; $this->settings['fontPath'] = './libraries/chart/pChart/fonts/'; @@ -92,7 +91,7 @@ abstract class PMA_pChart_Chart extends PMA_Chart protected function drawTitle() { // Draw the title - $this->chart->drawTextBox(0,0,$this->getWidth(),$this->getLabelHeight(),$this->titleText,0,255,255,255,ALIGN_CENTER,TRUE,0,0,0,30); + $this->chart->drawTextBox(0,0,$this->getWidth(),$this->getLabelHeight(),$this->getTitleText(),0,255,255,255,ALIGN_CENTER,TRUE,0,0,0,30); } protected function setGraphAreaDimensions() diff --git a/libraries/chart/pma_pchart_multi.php b/libraries/chart/pma_pchart_multi.php index b4f67db40..9114b8e51 100644 --- a/libraries/chart/pma_pchart_multi.php +++ b/libraries/chart/pma_pchart_multi.php @@ -8,9 +8,9 @@ require_once 'pma_pchart_chart.php'; */ abstract class PMA_pChart_multi extends PMA_pChart_chart { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); // as in CSS (top, right, bottom, left) $this->setLegendMargins(array(20, 10, 0, 0)); diff --git a/libraries/chart/pma_pchart_multi_bar.php b/libraries/chart/pma_pchart_multi_bar.php index 194ba2cc7..a268f9351 100644 --- a/libraries/chart/pma_pchart_multi_bar.php +++ b/libraries/chart/pma_pchart_multi_bar.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_multi.php'; class PMA_pChart_multi_bar extends PMA_pChart_multi { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); $this->settings['scale'] = SCALE_NORMAL; } diff --git a/libraries/chart/pma_pchart_multi_line.php b/libraries/chart/pma_pchart_multi_line.php index 078728470..576b40ff8 100644 --- a/libraries/chart/pma_pchart_multi_line.php +++ b/libraries/chart/pma_pchart_multi_line.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_multi.php'; class PMA_pChart_multi_line extends PMA_pChart_multi { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); $this->settings['scale'] = SCALE_NORMAL; } diff --git a/libraries/chart/pma_pchart_multi_radar.php b/libraries/chart/pma_pchart_multi_radar.php index e50634029..1a3170714 100644 --- a/libraries/chart/pma_pchart_multi_radar.php +++ b/libraries/chart/pma_pchart_multi_radar.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_multi.php'; class PMA_pChart_multi_radar extends PMA_pChart_multi { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); $this->normalizeValues(); } diff --git a/libraries/chart/pma_pchart_pie.php b/libraries/chart/pma_pchart_pie.php index f740dc6cd..cd848eda7 100644 --- a/libraries/chart/pma_pchart_pie.php +++ b/libraries/chart/pma_pchart_pie.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_multi.php'; class PMA_pChart_Pie extends PMA_pChart_multi { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); $this->setAreaMargins(array(20, 10, 20, 20)); } diff --git a/libraries/chart/pma_pchart_single.php b/libraries/chart/pma_pchart_single.php index 097fd0ac9..d6d4c34c2 100644 --- a/libraries/chart/pma_pchart_single.php +++ b/libraries/chart/pma_pchart_single.php @@ -7,9 +7,9 @@ require_once 'pma_pchart_chart.php'; */ abstract class PMA_pChart_single extends PMA_pChart_chart { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); } protected function prepareDataSet() diff --git a/libraries/chart/pma_pchart_single_bar.php b/libraries/chart/pma_pchart_single_bar.php index 024826af7..d08e4f6e7 100644 --- a/libraries/chart/pma_pchart_single_bar.php +++ b/libraries/chart/pma_pchart_single_bar.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_single.php'; class PMA_pChart_single_bar extends PMA_pChart_single { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); } protected function drawChart() diff --git a/libraries/chart/pma_pchart_single_line.php b/libraries/chart/pma_pchart_single_line.php index b5f86ffbf..4104ad28e 100644 --- a/libraries/chart/pma_pchart_single_line.php +++ b/libraries/chart/pma_pchart_single_line.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_single.php'; class PMA_pChart_single_line extends PMA_pChart_single { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); } protected function drawChart() diff --git a/libraries/chart/pma_pchart_single_radar.php b/libraries/chart/pma_pchart_single_radar.php index 48c6d00f1..b1c017e32 100644 --- a/libraries/chart/pma_pchart_single_radar.php +++ b/libraries/chart/pma_pchart_single_radar.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_single.php'; class PMA_pChart_single_radar extends PMA_pChart_single { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); $this->normalizeValues(); } diff --git a/libraries/chart/pma_pchart_stacked_bar.php b/libraries/chart/pma_pchart_stacked_bar.php index 53575058d..5b8fcedca 100644 --- a/libraries/chart/pma_pchart_stacked_bar.php +++ b/libraries/chart/pma_pchart_stacked_bar.php @@ -4,9 +4,9 @@ require_once 'pma_pchart_multi.php'; class PMA_pChart_stacked_bar extends PMA_pChart_multi { - public function __construct($titleText, $data, $options = null) + public function __construct($data, $options = null) { - parent::__construct($titleText, $data, $options); + parent::__construct($data, $options); } protected function drawChart() diff --git a/tbl_chart.php b/tbl_chart.php index 04e3db7fe..f2c9d5ee9 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -87,8 +87,8 @@ $url_params['reload'] = 1; - - + +