added configurable settings for title and labels
This commit is contained in:
@@ -59,7 +59,12 @@ function PMA_chart_results($data, &$chartSettings)
|
|||||||
{
|
{
|
||||||
$chartData = array();
|
$chartData = array();
|
||||||
$chart = null;
|
$chart = null;
|
||||||
|
if (!empty($chartSettings['title'])) {
|
||||||
|
$chartTitle = $chartSettings['title'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
$chartTitle = __('Query results');
|
$chartTitle = __('Query results');
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($data[0])) {
|
if (!isset($data[0])) {
|
||||||
// empty data
|
// empty data
|
||||||
|
@@ -50,6 +50,16 @@ class PMA_Chart
|
|||||||
* The height of the chart.
|
* The height of the chart.
|
||||||
*/
|
*/
|
||||||
'height' => 325,
|
'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)
|
function __construct($options = null)
|
||||||
@@ -98,6 +108,16 @@ class PMA_Chart
|
|||||||
return hexdec(substr($this->settings['bgColor'], ($component * 2) + 1, 2));
|
return hexdec(substr($this->settings['bgColor'], ($component * 2) + 1, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getXLabel()
|
||||||
|
{
|
||||||
|
return $this->settings['xLabel'];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getYLabel()
|
||||||
|
{
|
||||||
|
return $this->settings['yLabel'];
|
||||||
|
}
|
||||||
|
|
||||||
function getSettings()
|
function getSettings()
|
||||||
{
|
{
|
||||||
return $this->settings;
|
return $this->settings;
|
||||||
|
@@ -31,8 +31,18 @@ class PMA_pChart_bar extends PMA_pChart_Chart
|
|||||||
$this->dataSet->AddAllSeries();
|
$this->dataSet->AddAllSeries();
|
||||||
//$DataSet->RemoveSerie("Serie3");
|
//$DataSet->RemoveSerie("Serie3");
|
||||||
$this->dataSet->SetAbsciseLabelSerie("Keys");
|
$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->SetYAxisUnit("°C");
|
||||||
//$DataSet->SetXAxisUnit("h");
|
//$DataSet->SetXAxisUnit("h");
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ require_once './libraries/common.inc.php';
|
|||||||
*/
|
*/
|
||||||
require './libraries/db_common.inc.php';
|
require './libraries/db_common.inc.php';
|
||||||
$url_params['goto'] = $cfg['DefaultTabDatabase'];
|
$url_params['goto'] = $cfg['DefaultTabDatabase'];
|
||||||
$url_params['back'] = 'view_create.php';
|
$url_params['back'] = 'tbl_chart.php';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Import chart functions
|
* Import chart functions
|
||||||
@@ -40,9 +40,6 @@ $data = array();
|
|||||||
$result = PMA_DBI_try_query($sql_query);
|
$result = PMA_DBI_try_query($sql_query);
|
||||||
while ($row = PMA_DBI_fetch_assoc($result)) {
|
while ($row = PMA_DBI_fetch_assoc($result)) {
|
||||||
$data[] = $row;
|
$data[] = $row;
|
||||||
/*foreach ($row as $key => $value) {
|
|
||||||
$chartData[$key][] = $value;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get settings if any posted
|
// get settings if any posted
|
||||||
@@ -89,6 +86,18 @@ $url_params['reload'] = 1;
|
|||||||
<tr><td><label for="height"><?php echo __("Height"); ?></label></td>
|
<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>
|
<td><input type="text" name="chartSettings[height]" id="height" value="<?php echo $chartSettings['height']; ?>" /></td>
|
||||||
</tr>
|
</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>
|
</table>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
Reference in New Issue
Block a user