- Replaced pChart profiling chart with highchart chart

- Moved PMA_profilingResults() function code inline in sql.php as its used at only one place
This commit is contained in:
Tyron Madlener 2011-06-07 21:32:05 +02:00
parent e913dcc6e1
commit 902fc1d95d
3 changed files with 75 additions and 40 deletions

View File

@ -1155,6 +1155,48 @@ $(document).ready(function() {
$('.column_heading').live('click', function() {
PMA_changeClassForColumn($(this), 'marked');
});
})
});
/*
* Profiling Chart
*/
$(document).ready(function() {
if($('#profilingchart').length==0) return;
var cdata = new Array();
$.each(jQuery.parseJSON($('#profilingchart').html()),function(key,value) {
cdata.push([key,parseFloat(value)]);
});
PMA_createChart({
chart: {
renderTo: 'profilingchart',
backgroundColor: $('#sqlqueryresults fieldset').css('background-color')
},
title: { text:'', margin:0 },
series: [{
type:'pie',
name: 'Query execution time',
data: cdata
}],
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
distance: 35,
formatter: function() {
return '<b>'+ this.point.name +'</b><br> '+ Highcharts.numberFormat(this.percentage, 2) +' %';
}
}
}
},
tooltip: {
formatter: function() { return '<b>'+ this.point.name +'</b><br/>'+this.y+'s<br/>('+Highcharts.numberFormat(this.percentage, 2) +' %)'; }
}
});
});
/**#@- */

View File

@ -1302,43 +1302,6 @@ 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, $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";
echo ' <th>' . __('Time') . '</th>' . "\n";
echo ' </tr>' . "\n";
foreach($profiling_results as $one_result) {
echo ' <tr>' . "\n";
echo '<td>' . $one_result['Status'] . '</td>' . "\n";
echo '<td>' . $one_result['Duration'] . '</td>' . "\n";
}
echo '</table>' . "\n";
echo '</div>';
if ($show_chart) {
require_once './libraries/chart.lib.php';
echo '<div style="float: left;">';
PMA_chart_profiling($profiling_results);
echo '</div>';
}
echo '</fieldset>' . "\n";
}
/**
* Formats $value to byte view
*

34
sql.php
View File

@ -15,7 +15,14 @@ require_once './libraries/check_user_privileges.lib.php';
require_once './libraries/bookmark.lib.php';
$GLOBALS['js_include'][] = 'jquery/jquery-ui-1.8.custom.js';
$GLOBALS['js_include'][] = 'pMap.js';
if(isset($_SESSION['profiling'])) {
$GLOBALS['js_include'][] = 'highcharts/highcharts.js';
/* Files required for chart exporting */
$GLOBALS['js_include'][] = 'highcharts/exporting.js';
$GLOBALS['js_include'][] = 'canvg/canvg.js';
$GLOBALS['js_include'][] = 'canvg/rgbcolor.js';
}
/**
* Defines the url to return to in case of error in a sql statement
@ -890,7 +897,30 @@ else {
}
if (isset($profiling_results)) {
PMA_profilingResults($profiling_results, true);
echo '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
echo '<div style="float: left;">';
echo '<table>' . "\n";
echo ' <tr>' . "\n";
echo ' <th>' . __('Status') . '</th>' . "\n";
echo ' <th>' . __('Time') . '</th>' . "\n";
echo ' </tr>' . "\n";
$chart_json = Array();
foreach($profiling_results as $one_result) {
echo ' <tr>' . "\n";
echo '<td>' . ucwords($one_result['Status']) . '</td>' . "\n";
echo '<td align="right">' . (PMA_formatNumber($one_result['Duration'],3,1)) . 's</td>' . "\n";
$chart_json[ucwords($one_result['Status'])] = $one_result['Duration'];
}
echo '</table>' . "\n";
echo '</div>';
//require_once './libraries/chart.lib.php';
echo '<div id="profilingchart" style="width:600px; height:400px; float: left;">';
//PMA_chart_profiling($profiling_results);
echo json_encode($chart_json);
echo '</div>';
echo '</fieldset>' . "\n";
}
// Displays the results in a table