changed comments to comply with phpdoc and added some new comments. Moved color settings to more appropriate places.
This commit is contained in:
@@ -1,5 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Chart functions used to generate various types of charts.
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
define('ERR_NO_GD', 0);
|
define('ERR_NO_GD', 0);
|
||||||
define('ERR_NO_JSON', 1);
|
define('ERR_NO_JSON', 1);
|
||||||
|
|
||||||
@@ -13,15 +21,9 @@ require_once './libraries/chart/pma_pchart_single_radar.php';
|
|||||||
require_once './libraries/chart/pma_pchart_multi_radar.php';
|
require_once './libraries/chart/pma_pchart_multi_radar.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chart functions used to generate various types
|
* Formats a chart for the status page.
|
||||||
* of charts.
|
* @param array $data data for the status chart
|
||||||
*
|
* @return string HTML and JS code for the chart
|
||||||
* @version $Id$
|
|
||||||
* @package phpMyAdmin
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Formats a chart for status page.
|
|
||||||
*/
|
*/
|
||||||
function PMA_chart_status($data)
|
function PMA_chart_status($data)
|
||||||
{
|
{
|
||||||
@@ -42,8 +44,10 @@ function PMA_chart_status($data)
|
|||||||
echo $chartCode;
|
echo $chartCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Formats a chart for profiling page.
|
* Formats a chart for the profiling page.
|
||||||
|
* @param array $data data for the status chart
|
||||||
|
* @return string HTML and JS code for the chart
|
||||||
*/
|
*/
|
||||||
function PMA_chart_profiling($data)
|
function PMA_chart_profiling($data)
|
||||||
{
|
{
|
||||||
@@ -63,8 +67,11 @@ function PMA_chart_profiling($data)
|
|||||||
echo $chartCode;
|
echo $chartCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Formats a chart for query results page.
|
* Formats a chart for the query results page.
|
||||||
|
* @param array $data data for the status chart
|
||||||
|
* @param array $chartSettings settings used to generate the chart
|
||||||
|
* @return string HTML and JS code for the chart
|
||||||
*/
|
*/
|
||||||
function PMA_chart_results($data, &$chartSettings)
|
function PMA_chart_results($data, &$chartSettings)
|
||||||
{
|
{
|
||||||
@@ -232,8 +239,9 @@ function PMA_chart_results($data, &$chartSettings)
|
|||||||
return $chartCode;
|
return $chartCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Simple handler of chart errors.
|
* Simple handler of chart errors.
|
||||||
|
* @param array $errors all occured errors
|
||||||
*/
|
*/
|
||||||
function PMA_handle_chart_err($errors)
|
function PMA_handle_chart_err($errors)
|
||||||
{
|
{
|
||||||
|
@@ -1,29 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the base class that all charts inherit from and some widely used
|
||||||
|
* constants.
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
define('RED', 0);
|
define('RED', 0);
|
||||||
define('GREEN', 1);
|
define('GREEN', 1);
|
||||||
define('BLUE', 2);
|
define('BLUE', 2);
|
||||||
|
|
||||||
class PMA_Chart
|
/**
|
||||||
|
* The base class that all charts inherit from.
|
||||||
|
* @abstract
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
abstract class PMA_chart
|
||||||
{
|
{
|
||||||
/*
|
/**
|
||||||
* The settings array. All the default values are here.
|
* @var array All the default settigs values are here.
|
||||||
*/
|
*/
|
||||||
protected $settings = array(
|
protected $settings = array(
|
||||||
|
|
||||||
/*
|
// Default title for every chart.
|
||||||
* Default title for every chart.
|
|
||||||
*/
|
|
||||||
'titleText' => 'Chart',
|
'titleText' => 'Chart',
|
||||||
|
|
||||||
/*
|
// The style of the chart title.
|
||||||
* The style of the chart title.
|
'titleColor' => '#FAFAFA',
|
||||||
*/
|
|
||||||
'titleStyle' => 'font-size: 12px; font-weight: bold;',
|
|
||||||
|
|
||||||
/*
|
// Colors for the different slices in the pie chart.
|
||||||
* Colors for the different slices in the pie chart.
|
|
||||||
*/
|
|
||||||
'colors' => array(
|
'colors' => array(
|
||||||
'#BCE02E',
|
'#BCE02E',
|
||||||
'#E0642E',
|
'#E0642E',
|
||||||
@@ -45,53 +53,50 @@ class PMA_Chart
|
|||||||
'#87C9BF',
|
'#87C9BF',
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
// Chart background color.
|
||||||
* Chart background color.
|
|
||||||
*/
|
|
||||||
'bgColor' => '#84AD83',
|
'bgColor' => '#84AD83',
|
||||||
|
|
||||||
/*
|
// The width of the chart.
|
||||||
* The width of the chart.
|
|
||||||
*/
|
|
||||||
'width' => 520,
|
'width' => 520,
|
||||||
|
|
||||||
/*
|
// 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.
|
||||||
* Default X Axis label. If empty, label will be taken from the data.
|
|
||||||
*/
|
|
||||||
'xLabel' => '',
|
'xLabel' => '',
|
||||||
|
|
||||||
/*
|
// Default Y Axis label. If empty, label will be taken from the data.
|
||||||
* Default Y Axis label. If empty, label will be taken from the data.
|
|
||||||
*/
|
|
||||||
'yLabel' => '',
|
'yLabel' => '',
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Options that the user has specified
|
* @var array Options that the user has specified
|
||||||
*/
|
*/
|
||||||
private $userSpecifiedSettings = null;
|
private $userSpecifiedSettings = null;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Error codes will be stored here
|
* @var array Error codes will be stored here
|
||||||
*/
|
*/
|
||||||
protected $errors = array();
|
protected $errors = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store user specified options
|
||||||
|
* @param array $options users specified options
|
||||||
|
*/
|
||||||
function __construct($options = null)
|
function __construct($options = null)
|
||||||
{
|
{
|
||||||
$this->userSpecifiedSettings = $options;
|
$this->userSpecifiedSettings = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All the variable initialization has to be done here.
|
||||||
|
*/
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->handleOptions();
|
$this->handleOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* A function which handles passed parameters. Useful if desired
|
* A function which handles passed parameters. Useful if desired
|
||||||
* chart needs to be a little bit different from the default one.
|
* chart needs to be a little bit different from the default one.
|
||||||
*/
|
*/
|
||||||
@@ -109,9 +114,9 @@ class PMA_Chart
|
|||||||
return $this->settings['titleText'];
|
return $this->settings['titleText'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTitleStyle()
|
protected function getTitleColor($component)
|
||||||
{
|
{
|
||||||
return $this->settings['titleStyle'];
|
return $this->hexStrToDecComp($this->settings['titleColor'], $component);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getColors()
|
protected function getColors()
|
||||||
@@ -131,7 +136,7 @@ class PMA_Chart
|
|||||||
|
|
||||||
protected function getBgColor($component)
|
protected function getBgColor($component)
|
||||||
{
|
{
|
||||||
return hexdec(substr($this->settings['bgColor'], ($component * 2) + 1, 2));
|
return $this->hexStrToDecComp($this->settings['bgColor'], $component);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setXLabel($label)
|
protected function setXLabel($label)
|
||||||
@@ -163,6 +168,16 @@ class PMA_Chart
|
|||||||
{
|
{
|
||||||
return $this->errors;
|
return $this->errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get one the dec color component from the hex color string
|
||||||
|
* @param string $colorString color string, i.e. #5F22A99
|
||||||
|
* @param int $component color component to get, i.e. 0 gets red.
|
||||||
|
*/
|
||||||
|
protected function hexStrToDecComp($colorString, $component)
|
||||||
|
{
|
||||||
|
return hexdec(substr($colorString, ($component * 2) + 1, 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,5 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* Holds the base class that all charts using pChart inherit from and some
|
||||||
|
* widely used constants
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
define('TOP', 0);
|
define('TOP', 0);
|
||||||
define('RIGHT', 1);
|
define('RIGHT', 1);
|
||||||
define('BOTTOM', 2);
|
define('BOTTOM', 2);
|
||||||
@@ -10,17 +19,36 @@ require_once 'pma_chart.php';
|
|||||||
require_once 'pChart/pData.class';
|
require_once 'pChart/pData.class';
|
||||||
require_once 'pChart/pChart.class';
|
require_once 'pChart/pChart.class';
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Base class for every chart implemented using pChart.
|
* Base class for every chart implemented using pChart.
|
||||||
|
* @abstract
|
||||||
|
* @package phpMyAdmin
|
||||||
*/
|
*/
|
||||||
abstract class PMA_pChart_Chart extends PMA_Chart
|
abstract class PMA_pChart_chart extends PMA_chart
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var String title text
|
||||||
|
*/
|
||||||
protected $titleText;
|
protected $titleText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array data for the chart
|
||||||
|
*/
|
||||||
protected $data;
|
protected $data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object pData object that holds the description of the data
|
||||||
|
*/
|
||||||
protected $dataSet;
|
protected $dataSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var object pChart object that holds the chart
|
||||||
|
*/
|
||||||
protected $chart;
|
protected $chart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array holds base64 encoded chart image parts
|
||||||
|
*/
|
||||||
protected $partsEncoded = array();
|
protected $partsEncoded = array();
|
||||||
|
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -41,6 +69,21 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
|
|
||||||
// as in CSS (top, right, bottom, left)
|
// as in CSS (top, right, bottom, left)
|
||||||
$this->setAreaMargins(array(20, 20, 40, 60));
|
$this->setAreaMargins(array(20, 20, 40, 60));
|
||||||
|
|
||||||
|
// when graph area gradient is used, this is the color of the graph
|
||||||
|
// area border
|
||||||
|
$this->settings['graphAreaColor'] = '#D5D9DD';
|
||||||
|
|
||||||
|
// the background color of the graph area
|
||||||
|
$this->settings['graphAreaGradientColor'] = '#A3CBA7';
|
||||||
|
|
||||||
|
// the color of the grid lines in the graph area
|
||||||
|
$this->settings['gridColor'] = '#E6E6E6';
|
||||||
|
|
||||||
|
// the color of the scale and the labels
|
||||||
|
$this->settings['scaleColor'] = '#D5D9DD';
|
||||||
|
|
||||||
|
$this->settings['titleBgColor'] = '#000000';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
@@ -54,6 +97,7 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$this->dataSet = new pData;
|
$this->dataSet = new pData;
|
||||||
|
|
||||||
$this->chart->reportWarnings('GD');
|
$this->chart->reportWarnings('GD');
|
||||||
|
$this->chart->ErrorFontName = $this->getFontPath().'tahoma.ttf';
|
||||||
|
|
||||||
// initialize colors
|
// initialize colors
|
||||||
foreach ($this->getColors() as $key => $color) {
|
foreach ($this->getColors() as $key => $color) {
|
||||||
@@ -70,14 +114,24 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$this->chart->setImageMap(true, 'mapid');
|
$this->chart->setImageMap(true, 'mapid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data is put to the $dataSet object according to what type chart is
|
||||||
|
* @abstract
|
||||||
|
*/
|
||||||
abstract protected function prepareDataSet();
|
abstract protected function prepareDataSet();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* all components of the chart are drawn
|
||||||
|
*/
|
||||||
protected function prepareChart()
|
protected function prepareChart()
|
||||||
{
|
{
|
||||||
$this->drawBackground();
|
$this->drawBackground();
|
||||||
$this->drawChart();
|
$this->drawChart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the background
|
||||||
|
*/
|
||||||
protected function drawBackground()
|
protected function drawBackground()
|
||||||
{
|
{
|
||||||
$this->drawCommon();
|
$this->drawCommon();
|
||||||
@@ -86,6 +140,9 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$this->drawGraphArea();
|
$this->drawGraphArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the part of the background which is common to most of the charts
|
||||||
|
*/
|
||||||
protected function drawCommon()
|
protected function drawCommon()
|
||||||
{
|
{
|
||||||
$this->chart->drawGraphAreaGradient(
|
$this->chart->drawGraphAreaGradient(
|
||||||
@@ -96,12 +153,34 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$this->chart->addBorder(2);
|
$this->chart->addBorder(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the chart title
|
||||||
|
*/
|
||||||
protected function drawTitle()
|
protected function drawTitle()
|
||||||
{
|
{
|
||||||
// Draw the title
|
// Draw the title
|
||||||
$this->chart->drawTextBox(0,0,$this->getWidth(),$this->getLabelHeight(),$this->getTitleText(),0,250,250,250,ALIGN_CENTER,True,0,0,0,30);
|
$this->chart->drawTextBox(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$this->getWidth(),
|
||||||
|
$this->getLabelHeight(),
|
||||||
|
$this->getTitleText(),
|
||||||
|
0,
|
||||||
|
$this->getTitleColor(RED),
|
||||||
|
$this->getTitleColor(GREEN),
|
||||||
|
$this->getTitleColor(BLUE),
|
||||||
|
ALIGN_CENTER,
|
||||||
|
True,
|
||||||
|
$this->getTitleBgColor(RED),
|
||||||
|
$this->getTitleBgColor(GREEN),
|
||||||
|
$this->getTitleBgColor(BLUE),
|
||||||
|
30
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calculates and sets the dimensions that will be used for the actual graph
|
||||||
|
*/
|
||||||
protected function setGraphAreaDimensions()
|
protected function setGraphAreaDimensions()
|
||||||
{
|
{
|
||||||
$this->chart->setGraphArea(
|
$this->chart->setGraphArea(
|
||||||
@@ -112,17 +191,49 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws graph area (the area where all bars, lines, points will be seen)
|
||||||
|
*/
|
||||||
protected function drawGraphArea()
|
protected function drawGraphArea()
|
||||||
{
|
{
|
||||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
$this->chart->drawGraphArea(
|
||||||
$this->chart->drawScale($this->dataSet->GetData(),$this->dataSet->GetDataDescription(),$this->getScale(),213,217,221,TRUE,0,2,TRUE);
|
$this->getGraphAreaColor(RED),
|
||||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
$this->getGraphAreaColor(GREEN),
|
||||||
$this->chart->drawGrid(4,TRUE,230,230,230,20);
|
$this->getGraphAreaColor(BLUE),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->chart->drawScale(
|
||||||
|
$this->dataSet->GetData(),
|
||||||
|
$this->dataSet->GetDataDescription(),
|
||||||
|
$this->getScale(),
|
||||||
|
$this->getScaleColor(RED),
|
||||||
|
$this->getScaleColor(GREEN),
|
||||||
|
$this->getScaleColor(BLUE),
|
||||||
|
TRUE,0,2,TRUE
|
||||||
|
);
|
||||||
|
$this->chart->drawGraphAreaGradient(
|
||||||
|
$this->getGraphAreaGradientColor(RED),
|
||||||
|
$this->getGraphAreaGradientColor(GREEN),
|
||||||
|
$this->getGraphAreaGradientColor(BLUE),
|
||||||
|
50
|
||||||
|
);
|
||||||
|
$this->chart->drawGrid(
|
||||||
|
4,
|
||||||
|
TRUE,
|
||||||
|
$this->getGridColor(RED),
|
||||||
|
$this->getGridColor(GREEN),
|
||||||
|
$this->getGridColor(BLUE),
|
||||||
|
20
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the chart
|
||||||
|
* @abstract
|
||||||
|
*/
|
||||||
protected abstract function drawChart();
|
protected abstract function drawChart();
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Renders the chart, base 64 encodes the output and puts it into
|
* Renders the chart, base 64 encodes the output and puts it into
|
||||||
* array partsEncoded.
|
* array partsEncoded.
|
||||||
*
|
*
|
||||||
@@ -169,6 +280,10 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the HTML and JS code for the configured chart
|
||||||
|
* @return string HTML and JS code for the chart
|
||||||
|
*/
|
||||||
public function toString()
|
public function toString()
|
||||||
{
|
{
|
||||||
if (!function_exists('gd_info')) {
|
if (!function_exists('gd_info')) {
|
||||||
@@ -181,7 +296,9 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
$this->prepareChart();
|
$this->prepareChart();
|
||||||
|
|
||||||
//$this->chart->debugImageMap();
|
//$this->chart->debugImageMap();
|
||||||
|
$this->chart->printErrors('GD');
|
||||||
|
|
||||||
|
// check if a user wanted a chart in one part
|
||||||
if ($this->isContinuous()) {
|
if ($this->isContinuous()) {
|
||||||
$this->render(1);
|
$this->render(1);
|
||||||
}
|
}
|
||||||
@@ -195,6 +312,7 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
}
|
}
|
||||||
$returnData .= '</div>';
|
$returnData .= '</div>';
|
||||||
|
|
||||||
|
// add tooltips only if json is available
|
||||||
if (function_exists('json_encode')) {
|
if (function_exists('json_encode')) {
|
||||||
$returnData .= '
|
$returnData .= '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -248,6 +366,31 @@ abstract class PMA_pChart_Chart extends PMA_Chart
|
|||||||
{
|
{
|
||||||
return $this->chart->getImageMap();
|
return $this->chart->getImageMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getGraphAreaColor($component)
|
||||||
|
{
|
||||||
|
return $this->hexStrToDecComp($this->settings['graphAreaColor'], $component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGraphAreaGradientColor($component)
|
||||||
|
{
|
||||||
|
return $this->hexStrToDecComp($this->settings['graphAreaGradientColor'], $component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getGridColor($component)
|
||||||
|
{
|
||||||
|
return $this->hexStrToDecComp($this->settings['gridColor'], $component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getScaleColor($component)
|
||||||
|
{
|
||||||
|
return $this->hexStrToDecComp($this->settings['scaleColor'], $component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTitleBgColor($component)
|
||||||
|
{
|
||||||
|
return $this->hexStrToDecComp($this->settings['titleBgColor'], $component);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -1,10 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_chart.php';
|
require_once 'pma_pchart_chart.php';
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Base class for every chart that uses multiple series.
|
* Base class for every chart that uses multiple series.
|
||||||
* All of these charts will require legend box.
|
* All of these charts will require legend box.
|
||||||
|
* @abstract
|
||||||
|
* @package phpMyAdmin
|
||||||
*/
|
*/
|
||||||
abstract class PMA_pChart_multi extends PMA_pChart_chart
|
abstract class PMA_pChart_multi extends PMA_pChart_chart
|
||||||
{
|
{
|
||||||
@@ -16,6 +25,9 @@ abstract class PMA_pChart_multi extends PMA_pChart_chart
|
|||||||
$this->setLegendMargins(array(20, 10, 0, 0));
|
$this->setLegendMargins(array(20, 10, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data set preparation for multi serie graphs
|
||||||
|
*/
|
||||||
protected function prepareDataSet()
|
protected function prepareDataSet()
|
||||||
{
|
{
|
||||||
$values = array_values($this->data);
|
$values = array_values($this->data);
|
||||||
@@ -48,6 +60,9 @@ abstract class PMA_pChart_multi extends PMA_pChart_chart
|
|||||||
$this->dataSet->SetYAxisName($this->getYLabel());
|
$this->dataSet->SetYAxisName($this->getYLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set graph area dimensions with respect to legend box size
|
||||||
|
*/
|
||||||
protected function setGraphAreaDimensions()
|
protected function setGraphAreaDimensions()
|
||||||
{
|
{
|
||||||
$this->chart->setGraphArea(
|
$this->chart->setGraphArea(
|
||||||
@@ -58,11 +73,17 @@ abstract class PMA_pChart_multi extends PMA_pChart_chart
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* multi serie charts need a legend. draw it
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
$this->drawLegend();
|
$this->drawLegend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws a legend
|
||||||
|
*/
|
||||||
protected function drawLegend()
|
protected function drawLegend()
|
||||||
{
|
{
|
||||||
// Draw the legend
|
// Draw the legend
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_multi.php';
|
require_once 'pma_pchart_multi.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements multi bar chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_multi_bar extends PMA_pChart_multi
|
class PMA_pChart_multi_bar extends PMA_pChart_multi
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -11,6 +22,9 @@ class PMA_pChart_multi_bar extends PMA_pChart_multi
|
|||||||
$this->settings['scale'] = SCALE_NORMAL;
|
$this->settings['scale'] = SCALE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws multi bar graph
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
parent::drawChart();
|
parent::drawChart();
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_multi.php';
|
require_once 'pma_pchart_multi.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements multi line chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_multi_line extends PMA_pChart_multi
|
class PMA_pChart_multi_line extends PMA_pChart_multi
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -11,6 +22,9 @@ class PMA_pChart_multi_line extends PMA_pChart_multi
|
|||||||
$this->settings['scale'] = SCALE_NORMAL;
|
$this->settings['scale'] = SCALE_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws multi line chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
parent::drawChart();
|
parent::drawChart();
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_multi.php';
|
require_once 'pma_pchart_multi.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements multi radar chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_multi_radar extends PMA_pChart_multi
|
class PMA_pChart_multi_radar extends PMA_pChart_multi
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -11,7 +22,7 @@ class PMA_pChart_multi_radar extends PMA_pChart_multi
|
|||||||
$this->normalizeValues();
|
$this->normalizeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Get the largest value from the data and normalize all the other values.
|
* Get the largest value from the data and normalize all the other values.
|
||||||
*/
|
*/
|
||||||
private function normalizeValues()
|
private function normalizeValues()
|
||||||
@@ -19,12 +30,15 @@ class PMA_pChart_multi_radar extends PMA_pChart_multi
|
|||||||
$maxValue = 0;
|
$maxValue = 0;
|
||||||
$keys = array_keys($this->data);
|
$keys = array_keys($this->data);
|
||||||
$valueKey = $keys[1];
|
$valueKey = $keys[1];
|
||||||
|
|
||||||
|
// get the max value
|
||||||
foreach ($this->data[$valueKey] as $values) {
|
foreach ($this->data[$valueKey] as $values) {
|
||||||
if (max($values) > $maxValue) {
|
if (max($values) > $maxValue) {
|
||||||
$maxValue = max($values);
|
$maxValue = max($values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// normalize all the values according to the max value
|
||||||
foreach ($this->data[$valueKey] as &$values) {
|
foreach ($this->data[$valueKey] as &$values) {
|
||||||
foreach ($values as &$value) {
|
foreach ($values as &$value) {
|
||||||
$value = $value / $maxValue * 10;
|
$value = $value / $maxValue * 10;
|
||||||
@@ -32,12 +46,28 @@ class PMA_pChart_multi_radar extends PMA_pChart_multi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* graph area for the radar chart does not include grid lines
|
||||||
|
*/
|
||||||
protected function drawGraphArea()
|
protected function drawGraphArea()
|
||||||
{
|
{
|
||||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
$this->chart->drawGraphArea(
|
||||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
$this->getGraphAreaColor(RED),
|
||||||
|
$this->getGraphAreaColor(GREEN),
|
||||||
|
$this->getGraphAreaColor(BLUE),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->chart->drawGraphAreaGradient(
|
||||||
|
$this->getGraphAreaGradientColor(RED),
|
||||||
|
$this->getGraphAreaGradientColor(GREEN),
|
||||||
|
$this->getGraphAreaGradientColor(BLUE),
|
||||||
|
50
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw multi radar chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
parent::drawChart();
|
parent::drawChart();
|
||||||
|
@@ -1,17 +1,32 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_multi.php';
|
require_once 'pma_pchart_multi.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements pie chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_Pie extends PMA_pChart_multi
|
class PMA_pChart_Pie extends PMA_pChart_multi
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
{
|
{
|
||||||
|
// limit data size, no more than 18 pie slices
|
||||||
$data = array_slice($data, 0, 18, true);
|
$data = array_slice($data, 0, 18, true);
|
||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
|
|
||||||
$this->setAreaMargins(array(20, 10, 20, 20));
|
$this->setAreaMargins(array(20, 10, 20, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* prepare data set for the pie chart
|
||||||
|
*/
|
||||||
protected function prepareDataSet()
|
protected function prepareDataSet()
|
||||||
{
|
{
|
||||||
// Dataset definition
|
// Dataset definition
|
||||||
@@ -21,12 +36,28 @@ class PMA_pChart_Pie extends PMA_pChart_multi
|
|||||||
$this->dataSet->SetAbsciseLabelSerie("Keys");
|
$this->dataSet->SetAbsciseLabelSerie("Keys");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* graph area for the pie chart does not include grid lines
|
||||||
|
*/
|
||||||
protected function drawGraphArea()
|
protected function drawGraphArea()
|
||||||
{
|
{
|
||||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
$this->chart->drawGraphArea(
|
||||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
$this->getGraphAreaColor(RED),
|
||||||
|
$this->getGraphAreaColor(GREEN),
|
||||||
|
$this->getGraphAreaColor(BLUE),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->chart->drawGraphAreaGradient(
|
||||||
|
$this->getGraphAreaGradientColor(RED),
|
||||||
|
$this->getGraphAreaGradientColor(GREEN),
|
||||||
|
$this->getGraphAreaGradientColor(BLUE),
|
||||||
|
50
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw the pie chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
parent::drawChart();
|
parent::drawChart();
|
||||||
@@ -46,6 +77,9 @@ class PMA_pChart_Pie extends PMA_pChart_multi
|
|||||||
120,PIE_PERCENTAGE,FALSE,60,30,10,1);
|
120,PIE_PERCENTAGE,FALSE,60,30,10,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draw legend for the pie chart
|
||||||
|
*/
|
||||||
protected function drawLegend()
|
protected function drawLegend()
|
||||||
{
|
{
|
||||||
$this->chart->drawPieLegend(
|
$this->chart->drawPieLegend(
|
||||||
|
@@ -1,9 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_chart.php';
|
require_once 'pma_pchart_chart.php';
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Base class for every chart that uses only one series.
|
* Base class for every chart that uses only one series.
|
||||||
|
* @abstract
|
||||||
|
* @package phpMyAdmin
|
||||||
*/
|
*/
|
||||||
abstract class PMA_pChart_single extends PMA_pChart_chart
|
abstract class PMA_pChart_single extends PMA_pChart_chart
|
||||||
{
|
{
|
||||||
@@ -12,6 +21,9 @@ abstract class PMA_pChart_single extends PMA_pChart_chart
|
|||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* data set preparation for single serie charts
|
||||||
|
*/
|
||||||
protected function prepareDataSet()
|
protected function prepareDataSet()
|
||||||
{
|
{
|
||||||
$values = array_values($this->data);
|
$values = array_values($this->data);
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_single.php';
|
require_once 'pma_pchart_single.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements single bar chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_single_bar extends PMA_pChart_single
|
class PMA_pChart_single_bar extends PMA_pChart_single
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -9,6 +20,9 @@ class PMA_pChart_single_bar extends PMA_pChart_single
|
|||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws single bar chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
// Draw the bar chart
|
// Draw the bar chart
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_single.php';
|
require_once 'pma_pchart_single.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements single line chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_single_line extends PMA_pChart_single
|
class PMA_pChart_single_line extends PMA_pChart_single
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -9,6 +20,9 @@ class PMA_pChart_single_line extends PMA_pChart_single
|
|||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws single line chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
// Draw the line chart
|
// Draw the line chart
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_single.php';
|
require_once 'pma_pchart_single.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements single radar chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_single_radar extends PMA_pChart_single
|
class PMA_pChart_single_radar extends PMA_pChart_single
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -11,7 +22,7 @@ class PMA_pChart_single_radar extends PMA_pChart_single
|
|||||||
$this->normalizeValues();
|
$this->normalizeValues();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Get the largest value from the data and normalize all the other values.
|
* Get the largest value from the data and normalize all the other values.
|
||||||
*/
|
*/
|
||||||
private function normalizeValues()
|
private function normalizeValues()
|
||||||
@@ -26,12 +37,28 @@ class PMA_pChart_single_radar extends PMA_pChart_single
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* graph area for the radar chart does not include grid lines
|
||||||
|
*/
|
||||||
protected function drawGraphArea()
|
protected function drawGraphArea()
|
||||||
{
|
{
|
||||||
$this->chart->drawGraphArea(213,217,221,FALSE);
|
$this->chart->drawGraphArea(
|
||||||
$this->chart->drawGraphAreaGradient(163,203,167,50);
|
$this->getGraphAreaColor(RED),
|
||||||
|
$this->getGraphAreaColor(GREEN),
|
||||||
|
$this->getGraphAreaColor(BLUE),
|
||||||
|
FALSE
|
||||||
|
);
|
||||||
|
$this->chart->drawGraphAreaGradient(
|
||||||
|
$this->getGraphAreaGradientColor(RED),
|
||||||
|
$this->getGraphAreaGradientColor(GREEN),
|
||||||
|
$this->getGraphAreaGradientColor(BLUE),
|
||||||
|
50
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws the radar chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
// when drawing radar graph we can specify the border from the top of
|
// when drawing radar graph we can specify the border from the top of
|
||||||
|
@@ -1,7 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @author Martynas Mickevicius <mmartynas@gmail.com>
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
require_once 'pma_pchart_multi.php';
|
require_once 'pma_pchart_multi.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* implements stacked bar chart
|
||||||
|
* @package phpMyAdmin
|
||||||
|
*/
|
||||||
class PMA_pChart_stacked_bar extends PMA_pChart_multi
|
class PMA_pChart_stacked_bar extends PMA_pChart_multi
|
||||||
{
|
{
|
||||||
public function __construct($data, $options = null)
|
public function __construct($data, $options = null)
|
||||||
@@ -9,6 +20,9 @@ class PMA_pChart_stacked_bar extends PMA_pChart_multi
|
|||||||
parent::__construct($data, $options);
|
parent::__construct($data, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* draws stacked bar chart
|
||||||
|
*/
|
||||||
protected function drawChart()
|
protected function drawChart()
|
||||||
{
|
{
|
||||||
parent::drawChart();
|
parent::drawChart();
|
||||||
|
Reference in New Issue
Block a user