added configurable settings for title and labels

This commit is contained in:
Martynas Mickevicius
2010-06-23 14:06:57 +03:00
parent 278ee6e2ca
commit c2e7aef7ba
4 changed files with 51 additions and 7 deletions

View File

@@ -59,7 +59,12 @@ function PMA_chart_results($data, &$chartSettings)
{
$chartData = array();
$chart = null;
if (!empty($chartSettings['title'])) {
$chartTitle = $chartSettings['title'];
}
else {
$chartTitle = __('Query results');
}
if (!isset($data[0])) {
// empty data

View File

@@ -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;

View File

@@ -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");
}

View File

@@ -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;
<tr><td><label for="height"><?php echo __("Height"); ?></label></td>
<td><input type="text" name="chartSettings[height]" id="height" value="<?php echo $chartSettings['height']; ?>" /></td>
</tr>
<tr><td><label for="title"><?php echo __("Title"); ?></label></td>
<td><input type="text" name="chartSettings[title]" id="height" value="<?php echo $chartSettings['title']; ?>" /></td>
</tr>
<tr><td><label for="xLabel"><?php echo __("X Axis label"); ?></label></td>
<td><input type="text" name="chartSettings[xLabel]" id="height" value="<?php echo $chartSettings['xLabel']; ?>" /></td>
</tr>
<tr><td><label for="yLabel"><?php echo __("Y Axis label"); ?></label></td>
<td><input type="text" name="chartSettings[yLabel]" id="height" value="<?php echo $chartSettings['yLabel']; ?>" /></td>
</tr>
</table>
</fieldset>