diff --git a/libraries/chart.lib.php b/libraries/chart.lib.php index f2c764ca2..e48bf4a84 100644 --- a/libraries/chart.lib.php +++ b/libraries/chart.lib.php @@ -59,7 +59,12 @@ function PMA_chart_results($data, &$chartSettings) { $chartData = array(); $chart = null; - $chartTitle = __('Query results'); + if (!empty($chartSettings['title'])) { + $chartTitle = $chartSettings['title']; + } + else { + $chartTitle = __('Query results'); + } if (!isset($data[0])) { // empty data diff --git a/libraries/chart/pma_chart.php b/libraries/chart/pma_chart.php index 423641a0d..357dafa4a 100644 --- a/libraries/chart/pma_chart.php +++ b/libraries/chart/pma_chart.php @@ -50,6 +50,16 @@ class PMA_Chart * The height of the chart. */ 'height' => 325, + + /* + * Default X Axis label. If empty, label will be taken from the data. + */ + 'xLabel' => '', + + /* + * Default Y Axis label. If empty, label will be taken from the data. + */ + 'yLabel' => '', ); function __construct($options = null) @@ -98,6 +108,16 @@ class PMA_Chart return hexdec(substr($this->settings['bgColor'], ($component * 2) + 1, 2)); } + function getXLabel() + { + return $this->settings['xLabel']; + } + + function getYLabel() + { + return $this->settings['yLabel']; + } + function getSettings() { return $this->settings; diff --git a/libraries/chart/pma_pchart_bar.php b/libraries/chart/pma_pchart_bar.php index 613d8c2d1..d8947f83d 100644 --- a/libraries/chart/pma_pchart_bar.php +++ b/libraries/chart/pma_pchart_bar.php @@ -31,8 +31,18 @@ class PMA_pChart_bar extends PMA_pChart_Chart $this->dataSet->AddAllSeries(); //$DataSet->RemoveSerie("Serie3"); $this->dataSet->SetAbsciseLabelSerie("Keys"); - $this->dataSet->SetXAxisName($keys[0]); - $this->dataSet->SetYAxisName($keys[1]); + + $xLabel = $this->getXLabel(); + if (empty($xLabel)) { + $xLabel = $keys[0]; + } + $this->dataSet->SetXAxisName($xLabel); + + $yLabel = $this->getYLabel(); + if (empty($yLabel)) { + $yLabel = $keys[1]; + } + $this->dataSet->SetYAxisName($yLabel); //$DataSet->SetYAxisUnit("°C"); //$DataSet->SetXAxisUnit("h"); } diff --git a/tbl_chart.php b/tbl_chart.php index 070da7be7..6aae9844f 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -25,7 +25,7 @@ require_once './libraries/common.inc.php'; */ require './libraries/db_common.inc.php'; $url_params['goto'] = $cfg['DefaultTabDatabase']; -$url_params['back'] = 'view_create.php'; +$url_params['back'] = 'tbl_chart.php'; /* * Import chart functions @@ -40,9 +40,6 @@ $data = array(); $result = PMA_DBI_try_query($sql_query); while ($row = PMA_DBI_fetch_assoc($result)) { $data[] = $row; - /*foreach ($row as $key => $value) { - $chartData[$key][] = $value; - }*/ } // get settings if any posted @@ -89,6 +86,18 @@ $url_params['reload'] = 1; + + + + + + + + + + + +