moved chart dependant code to the chart lib.

This commit is contained in:
Martynas Mickevicius
2010-06-17 17:10:19 +03:00
parent 7074f1b90e
commit d1708970d6
3 changed files with 44 additions and 40 deletions

View File

@@ -1,4 +1,8 @@
<?php <?php
require_once './libraries/chart/pma_ofc_pie.php';
require_once './libraries/chart/pma_pChart_pie.php';
/** /**
* Chart functions used to generate various types * Chart functions used to generate various types
* of charts. * of charts.
@@ -7,11 +11,45 @@
* @package phpMyAdmin * @package phpMyAdmin
*/ */
function PMA_chart_pie($titleText, $data, $options = null) /*
* Formats a chart for status page.
*/
function PMA_chart_status($data)
{ {
require_once('./libraries/chart/pma_ofc_pie.php'); // format keys which will be shown in the chart
$chartData = array();
foreach($data as $dataKey => $dataValue) {
$key = ucwords(str_replace(array('Com_', '_'), array('', ' '), $dataKey));
$value = (int)$dataValue;
$chartData[$key] = $value;
}
//$chart = new PMA_OFC_Pie(__('Query type'), $chartData, $options);
$chart = new PMA_pChart_Pie(__('Query type'), $chartData);
echo $chart->toString();
}
$chart = new PMA_OFC_Pie($titleText, $data, $options); /*
* Formats a chart for profiling page.
*/
function PMA_chart_profiling($data)
{
$chartData = array();
foreach($data as $dataValue) {
$value = (int)($dataValue['Duration']*1000000);
$key = ucwords($dataValue['Status']);
$chartData[$key] = $value;
}
$chart = new PMA_pChart_Pie(
__('Query execution time comparison (in microseconds)'),
$chartData,
array(
'bgColor' => '#e5e5e5',
'width' => 500,
'height' => 325,
)
);
echo $chart->toString(); echo $chart->toString();
} }

View File

@@ -1363,43 +1363,15 @@ function PMA_profilingResults($profiling_results, $show_chart = false)
echo '</div>'; echo '</div>';
if ($show_chart) { if ($show_chart) {
require_once './libraries/chart.lib.php';
echo '<div style="float: left;">'; echo '<div style="float: left;">';
PMA_profilingResultsChart($profiling_results); PMA_chart_profiling($profiling_results);
echo '</div>'; echo '</div>';
} }
echo '</fieldset>' . "\n"; 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 * Formats $value to byte view
* *

View File

@@ -592,13 +592,7 @@ foreach ($used_queries as $name => $value) {
<div> <div>
<?php <?php
// format keys which will be shown in the chart echo PMA_chart_status($used_queries);
$chart_data = array();
foreach($used_queries as $key => $value) {
$key = str_replace(array('Com_', '_'), array('', ' '), $key);
$chart_data[ucwords($key)] = (int)$value;
}
echo PMA_chart_pie(__('Query type'), $chart_data);
?> ?>
</div> </div>