added radar chart type to the query results charts.
This commit is contained in:
@@ -8,6 +8,8 @@ require_once './libraries/chart/pma_pchart_multi_bar.php';
|
||||
require_once './libraries/chart/pma_pchart_stacked_bar.php';
|
||||
require_once './libraries/chart/pma_pchart_single_line.php';
|
||||
require_once './libraries/chart/pma_pchart_multi_line.php';
|
||||
require_once './libraries/chart/pma_pchart_single_radar.php';
|
||||
require_once './libraries/chart/pma_pchart_multi_radar.php';
|
||||
|
||||
/**
|
||||
* Chart functions used to generate various types
|
||||
@@ -124,6 +126,9 @@ function PMA_chart_results($data, &$chartSettings)
|
||||
case 'line':
|
||||
$chart = new PMA_pChart_single_line($chartTitle, $chartData, $chartSettings);
|
||||
break;
|
||||
case 'radar':
|
||||
$chart = new PMA_pChart_single_radar($chartTitle, $chartData, $chartSettings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -188,6 +193,9 @@ function PMA_chart_results($data, &$chartSettings)
|
||||
case 'line':
|
||||
$chart = new PMA_pChart_multi_line($chartTitle, $chartData, $chartSettings);
|
||||
break;
|
||||
case 'radar':
|
||||
$chart = new PMA_pChart_multi_radar($chartTitle, $chartData, $chartSettings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
68
libraries/chart/pma_pchart_multi_radar.php
Normal file
68
libraries/chart/pma_pchart_multi_radar.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
require_once 'pma_pchart_multi.php';
|
||||
|
||||
class PMA_pChart_multi_radar extends PMA_pChart_multi
|
||||
{
|
||||
public function __construct($titleText, $data, $options = null)
|
||||
{
|
||||
parent::__construct($titleText, $data, $options);
|
||||
|
||||
$this->normalizeValues();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the largest value from the data and normalize all the other values.
|
||||
*/
|
||||
private function normalizeValues()
|
||||
{
|
||||
$maxValue = 0;
|
||||
$keys = array_keys($this->data);
|
||||
$valueKey = $keys[1];
|
||||
foreach ($this->data[$valueKey] as $values) {
|
||||
if (max($values) > $maxValue) {
|
||||
$maxValue = max($values);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->data[$valueKey] as &$values) {
|
||||
foreach ($values as &$value) {
|
||||
$value = $value / $maxValue * 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function drawGraphArea()
|
||||
{
|
||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
||||
}
|
||||
|
||||
protected function drawChart()
|
||||
{
|
||||
parent::drawChart();
|
||||
|
||||
// when drawing radar graph we can specify the border from the top of
|
||||
// graph area. We want border to be dynamic, so that either the top
|
||||
// or the side of the radar is some distance away from the top or the
|
||||
// side of the graph area.
|
||||
$areaWidth = $this->chart->GArea_X2 - $this->chart->GArea_X1;
|
||||
$areaHeight = $this->chart->GArea_Y2 - $this->chart->GArea_Y1;
|
||||
|
||||
if ($areaHeight > $areaWidth) {
|
||||
$borderOffset = ($areaHeight - $areaWidth) / 2;
|
||||
}
|
||||
else {
|
||||
$borderOffset = 0;
|
||||
}
|
||||
|
||||
// the least ammount that radar is away from the graph area side.
|
||||
$borderOffset += 40;
|
||||
|
||||
// Draw the radar chart
|
||||
$this->chart->drawRadarAxis($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),TRUE,$borderOffset,120,120,120,230,230,230,-1,2);
|
||||
$this->chart->drawFilledRadar($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),50,$borderOffset);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -20,8 +20,10 @@ abstract class PMA_pChart_single extends PMA_pChart_chart
|
||||
// Dataset definition
|
||||
$this->dataSet->AddPoint($values[1], "Values");
|
||||
$this->dataSet->AddPoint($values[0], "Keys");
|
||||
$this->dataSet->AddAllSeries();
|
||||
//$DataSet->RemoveSerie("Serie3");
|
||||
|
||||
//$this->dataSet->AddAllSeries();
|
||||
$this->dataSet->AddSerie("Values");
|
||||
|
||||
$this->dataSet->SetAbsciseLabelSerie("Keys");
|
||||
|
||||
$xLabel = $this->getXLabel();
|
||||
@@ -35,8 +37,6 @@ abstract class PMA_pChart_single extends PMA_pChart_chart
|
||||
$yLabel = $keys[1];
|
||||
}
|
||||
$this->dataSet->SetYAxisName($yLabel);
|
||||
//$DataSet->SetYAxisUnit("°C");
|
||||
//$DataSet->SetXAxisUnit("h");
|
||||
}
|
||||
}
|
||||
|
||||
|
59
libraries/chart/pma_pchart_single_radar.php
Normal file
59
libraries/chart/pma_pchart_single_radar.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
require_once 'pma_pchart_single.php';
|
||||
|
||||
class PMA_pChart_single_radar extends PMA_pChart_single
|
||||
{
|
||||
public function __construct($titleText, $data, $options = null)
|
||||
{
|
||||
parent::__construct($titleText, $data, $options);
|
||||
|
||||
$this->normalizeValues();
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the largest value from the data and normalize all the other values.
|
||||
*/
|
||||
private function normalizeValues()
|
||||
{
|
||||
$maxValue = 0;
|
||||
$keys = array_keys($this->data);
|
||||
$valueKey = $keys[1];
|
||||
$maxValue = max($this->data[$valueKey]);
|
||||
|
||||
foreach ($this->data[$valueKey] as &$value) {
|
||||
$value = $value / $maxValue * 10;
|
||||
}
|
||||
}
|
||||
|
||||
protected function drawGraphArea()
|
||||
{
|
||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
||||
}
|
||||
|
||||
protected function drawChart()
|
||||
{
|
||||
// when drawing radar graph we can specify the border from the top of
|
||||
// graph area. We want border to be dynamic, so that either the top
|
||||
// or the side of the radar is some distance away from the top or the
|
||||
// side of the graph area.
|
||||
$areaWidth = $this->chart->GArea_X2 - $this->chart->GArea_X1;
|
||||
$areaHeight = $this->chart->GArea_Y2 - $this->chart->GArea_Y1;
|
||||
|
||||
if ($areaHeight > $areaWidth) {
|
||||
$borderOffset = ($areaHeight - $areaWidth) / 2;
|
||||
}
|
||||
else {
|
||||
$borderOffset = 0;
|
||||
}
|
||||
|
||||
// the least ammount that radar is away from the graph area side.
|
||||
$borderOffset += 40;
|
||||
|
||||
$this->chart->drawRadarAxis($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),TRUE,$borderOffset,120,120,120,230,230,230,-1,2);
|
||||
$this->chart->drawFilledRadar($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),50,$borderOffset);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -91,7 +91,7 @@ $url_params['reload'] = 1;
|
||||
<td><input type="text" name="chartSettings[title]" id="title" value="<?php echo $chartSettings['title']; ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<?php if ($chartSettings['type'] != 'pie') { ?>
|
||||
<?php if ($chartSettings['type'] != 'pie' && $chartSettings['type'] != 'radar') { ?>
|
||||
<tr><td><label for="xLabel"><?php echo __("X Axis label"); ?></label></td>
|
||||
<td><input type="text" name="chartSettings[xLabel]" id="xLabel" value="<?php echo $chartSettings['xLabel']; ?>" /></td>
|
||||
</tr>
|
||||
@@ -125,6 +125,7 @@ $url_params['reload'] = 1;
|
||||
<td>
|
||||
<input type="radio" name="chartSettings[type]" value="bar" <?php echo ($chartSettings['type'] == 'bar' ? 'checked' : ''); ?>>Bar
|
||||
<input type="radio" name="chartSettings[type]" value="line" <?php echo ($chartSettings['type'] == 'line' ? 'checked' : ''); ?>>Line
|
||||
<input type="radio" name="chartSettings[type]" value="radar" <?php echo ($chartSettings['type'] == 'radar' ? 'checked' : ''); ?>>Radar
|
||||
<?php if ($chartSettings['multi'] == false) { ?>
|
||||
<input type="radio" name="chartSettings[type]" value="pie" <?php echo ($chartSettings['type'] == 'pie' ? 'checked' : ''); ?>>Pie
|
||||
<?php } ?>
|
||||
|
Reference in New Issue
Block a user