added the chart in the profiling window
This commit is contained in:
@@ -7,11 +7,11 @@
|
||||
* @package phpMyAdmin
|
||||
*/
|
||||
|
||||
function PMA_chart_pie($titleText, $data)
|
||||
function PMA_chart_pie($titleText, $data, $options = null)
|
||||
{
|
||||
require_once('./libraries/chart/pma_ofc_pie.php');
|
||||
|
||||
$chart = new PMA_OFC_Pie($titleText, $data);
|
||||
$chart = new PMA_OFC_Pie($titleText, $data, $options);
|
||||
echo $chart->toString();
|
||||
}
|
||||
|
||||
|
@@ -11,21 +11,21 @@ class PMA_Chart
|
||||
* Colors for the different slices in the pie chart.
|
||||
*/
|
||||
protected $colors = array(
|
||||
'#485E70',
|
||||
'#484A70',
|
||||
'#594870',
|
||||
'#6D4870',
|
||||
'#70485E',
|
||||
'#70484A',
|
||||
'#705948',
|
||||
'#706D48',
|
||||
'#5E7048',
|
||||
'#4A7048',
|
||||
'#6D4870',
|
||||
'#70485E',
|
||||
'#485E70',
|
||||
'#484A70',
|
||||
'#487059',
|
||||
'#48706D',
|
||||
'#5F7E95',
|
||||
'#594870',
|
||||
'#5E7048',
|
||||
'#839CAF',
|
||||
'#95775F',
|
||||
'#5F7E95',
|
||||
'#706D48',
|
||||
'#4A7048',
|
||||
'#AF9683',
|
||||
);
|
||||
|
||||
@@ -44,15 +44,30 @@ class PMA_Chart
|
||||
*/
|
||||
protected $height = 250;
|
||||
|
||||
/*
|
||||
* Colors in the colors array have been written down in an gradient
|
||||
* order. Without shuffling pie chart has an angular gradient.
|
||||
* Colors could also be shuffles in the array initializer.
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
shuffle(&$this->colors);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* A function which handles passed parameters. Useful if desired
|
||||
* chart needs to be a little bit different from the default one.
|
||||
*
|
||||
* Option handling could be made more efficient if options would be
|
||||
* stored in an array.
|
||||
*/
|
||||
function handleOptions($options)
|
||||
{
|
||||
if (is_null($options))
|
||||
return;
|
||||
|
||||
if (isset($options['bgColor']))
|
||||
$this->bgColor = $options['bgColor'];
|
||||
if (isset($options['width']))
|
||||
$this->width = $options['width'];
|
||||
if (isset($options['height']))
|
||||
$this->height = $options['height'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -7,10 +7,12 @@ require_once('pma_ofc_chart.php');
|
||||
*/
|
||||
class PMA_OFC_Pie extends PMA_OFC_Chart
|
||||
{
|
||||
function __construct($titleText, $data)
|
||||
function __construct($titleText, $data, $options = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->handleOptions($options);
|
||||
|
||||
include './libraries/chart/ofc/open-flash-chart.php';
|
||||
|
||||
// create and style chart title
|
||||
@@ -43,4 +45,4 @@ class PMA_OFC_Pie extends PMA_OFC_Chart
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
@@ -1339,12 +1339,14 @@ function PMA_profilingCheckbox($sql_query)
|
||||
* Displays the results of SHOW PROFILE
|
||||
*
|
||||
* @param array the results
|
||||
* @param boolean show chart
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function PMA_profilingResults($profiling_results)
|
||||
function PMA_profilingResults($profiling_results, $show_chart = false)
|
||||
{
|
||||
echo '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
|
||||
echo '<div style="float: left;">';
|
||||
echo '<table>' . "\n";
|
||||
echo ' <tr>' . "\n";
|
||||
echo ' <th>' . __('Status') . '</th>' . "\n";
|
||||
@@ -1356,10 +1358,48 @@ function PMA_profilingResults($profiling_results)
|
||||
echo '<td>' . $one_result['Status'] . '</td>' . "\n";
|
||||
echo '<td>' . $one_result['Duration'] . '</td>' . "\n";
|
||||
}
|
||||
|
||||
echo '</table>' . "\n";
|
||||
echo '</div>';
|
||||
|
||||
if ($show_chart) {
|
||||
echo '<div style="float: left;">';
|
||||
PMA_profilingResultsChart($profiling_results);
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</fieldset>' . "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the results of SHOW PROFILE as a chart
|
||||
*
|
||||
* @param array the results
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function PMA_profilingResultsChart($profiling_results)
|
||||
{
|
||||
require_once './libraries/chart.lib.php';
|
||||
|
||||
$chart_data = array();
|
||||
foreach($profiling_results as $one_result) {
|
||||
$value = (int)($one_result['Duration']*1000000);
|
||||
$key = ucwords($one_result['Status']);
|
||||
$chart_data[$key] = $value;
|
||||
}
|
||||
|
||||
echo PMA_chart_pie(
|
||||
__('Query execution time comparison (in microseconds)'),
|
||||
$chart_data,
|
||||
array(
|
||||
'bgColor' => '#e5e5e5',
|
||||
'width' => 500,
|
||||
'height' => 300,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats $value to byte view
|
||||
*
|
||||
|
Reference in New Issue
Block a user