Chart title has been put to the settings array.

This commit is contained in:
Martynas Mickevicius
2010-07-09 16:27:25 +03:00
parent e5c8b5a894
commit 6b806f2047
14 changed files with 51 additions and 43 deletions

View File

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

View File

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

View File

@@ -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()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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()

View File

@@ -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()

View File

@@ -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()

View File

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

View File

@@ -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()

View File

@@ -87,8 +87,8 @@ $url_params['reload'] = 1;
<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="title" value="<?php echo $chartSettings['title']; ?>" /></td>
<tr><td><label for="titleText"><?php echo __("Title"); ?></label></td>
<td><input type="text" name="chartSettings[titleText]" id="titleText" value="<?php echo $chartSettings['titleText']; ?>" /></td>
</tr>
<?php if ($chartSettings['type'] != 'pie' && $chartSettings['type'] != 'radar') { ?>