Added some features

-> Limit on max number of rows retreived(500)
 -> An instruction link regarding how to use
 -> Resize plot by dragging it by the bottom right corner
 -> Two additional search criteria
This commit is contained in:
Ammar Yasir 2011-06-21 05:04:00 +05:30
parent fb8a4956a8
commit eaea003064
3 changed files with 67 additions and 24 deletions

View File

@ -32,6 +32,14 @@ $(document).ready(function() {
$('#tableid_1').change(function() {
$('#zoom_search_form').submit();
})
$('#tableid_2').change(function() {
$('#zoom_search_form').submit();
})
$('#tableid_3').change(function() {
$('#zoom_search_form').submit();
})
/**
@ -79,7 +87,6 @@ $(document).ready(function() {
// found results
$("#sqlqueryresults").html(response);
$("#sqlqueryresults").trigger('appendAnchor');
$("#sqlqueryresults").trigger('makegrid');
$('#tbl_search_form')
// work around for bug #3168569 - Issue on toggling the "Hide search criteria" in chrome.
.slideToggle()

View File

@ -3,6 +3,10 @@ var chart_series;
var chart_series_index = -1;
$(document).ready(function() {
var currentChart=null;
// Get query result
@ -12,11 +16,11 @@ $(document).ready(function() {
var currentSettings = {
chart: {
renderTo: 'resizer',
renderTo: 'querychart',
defaultSeriesType: 'scatter',
zoomType: 'xy',
width:$('#resizer').width()-20,
height:$('#resizer').height()-20
width:$('#resizer').width(),
height:$('#resizer').height()
},
xAxis: {
title: { text: $('#tableid_0').val() },
@ -24,13 +28,17 @@ $(document).ready(function() {
yAxis: {
title: { text: $('#tableid_1').val() },
},
title: { text: 'Scatter Plot' },
title: { text: 'Query Results' },
exporting: { enabled: false },
credits: {
enabled: false
},
label: { text: $('#dataLabel').val() },
}
function drawChart(noAnimation) {
currentSettings.chart.width=$('#resizer').width()-20;
currentSettings.chart.width=$('#resizer').width()-3;
currentSettings.chart.height=$('#resizer').height()-20;
if(currentChart!=null) currentChart.destroy();
@ -39,9 +47,25 @@ $(document).ready(function() {
currentChart = PMA_queryChart(chart_data,currentSettings);
if(noAnimation) currentSettings.plotOptions.series.animation = true;
}
$('#resizer').resizable({
resize: function() {
currentChart.setSize(
this.offsetWidth -3,
this.offsetHeight - 20,
false
);
}
});
drawChart();
});
function displayHelp() {
alert("* Each point represents a data row.\n* Hovering over a point will show its label.\n* Drag and select an area in the plot to zoom into it.\n* Click reset zoom link to come back to original state.\n* Click data points to view the data row.\n* The plot can be resized by dragging it along the bottom right corner.");
}
function in_array(element,array) {
for(var i=0; i<array.length; i++)
if(array[i]==element) return true;
@ -117,7 +141,7 @@ function PMA_queryChart(data,passedSettings) {
min: Array.min(xCord) - 2
},
yAxis: {
max: Array.max(yCord) + 2,
max: Array.max(yCord) + 3,
min: Array.min(yCord) - 2
}
};

View File

@ -13,7 +13,10 @@
require_once './libraries/common.inc.php';
require_once './libraries/mysql_charsets.lib.php';
require_once './libraries/tbl_select.lib.php';
require_once './libraries/relation.lib.php';
$GLOBALS['js_include'][] = 'makegrid.js';
$GLOBALS['js_include'][] = 'sql.js';
$GLOBALS['js_include'][] = 'tbl_select.js';
$GLOBALS['js_include'][] = 'tbl_zoom_plot.js';
$GLOBALS['js_include'][] = 'highcharts/highcharts.js';
@ -79,7 +82,7 @@ echo PMA_generate_html_tabs(PMA_tbl_getSubTabs(), $url_params);
if(isset($inputs) && ($inputs[0] != __('pma_null') || $inputs[1] != __('pma_null')))
{
$flag = 2;
for($i = 0 ; $i < 2 ; $i++)
for($i = 0 ; $i < 4 ; $i++)
{
if($inputs[$i] != __('pma_null'))
{
@ -93,24 +96,18 @@ if(isset($inputs) && ($inputs[0] != __('pma_null') || $inputs[1] != __('pma_null
}
if(isset($zoom_submit)) {
$w = $data = array();
$sql_query = 'SELECT *';
// Add the colums to be selected
//$columns = $inputs;
//$columns = PMA_backquote($columns);
//$sql_query .= implode(', ', $columns);
//Add the table
$sql_query .= ' FROM ' . PMA_backquote($table);
for($i = 0 ; $i < 2 ; $i++){
for($i = 0 ; $i < 4 ; $i++){
if($inputs[$i] == __('pma_null'))
continue;
$tmp = array();
// The where clause
$charsets = array();
@ -127,6 +124,11 @@ if(isset($zoom_submit)) {
if ($w) {
$sql_query .= ' WHERE ' . implode(' AND ', $w);
}
$sql_query .= ' LIMIT 500 ';
if ($dataLabel == '')
$dataLabel = PMA_getDisplayField($db,$table);
$settings = array('xLabel' => $inputs[0], 'yLabel' => $inputs[1], 'dataLabel' => $dataLabel);
$result = PMA_DBI_query( $sql_query . ";" , null, PMA_DBI_QUERY_STORE);
@ -150,23 +152,33 @@ if(isset($zoom_submit)) {
<fieldset id="zoom_fieldset_table_qbe">
<?php if(isset($zoom_submit) && !empty($scatter_plot)){ ?>
<div id='resizer' style="width:600px; height:400px;float:right">
<legend><?php echo __('Display Plot'); ?></legend>
<div id="querydata" style="display:none;">
<?php if (isset($data)) ?><center> <a href="#" onClick="displayHelp();"><?php echo __('How to use'); ?></a> </center>
<div id="querydata" style="display:none">
<?php if(isset($data)) echo json_encode($data); ?>
</div>
<div id="querychart" style="float:right">
</div>
<?php //echo $scatter_plot; ?>
</div>
<?php } ?>
<legend><?php echo __('Do a "query by example" (wildcard: "%") for two columns') ?></legend>
<table class="data">
<?php echo PMA_tbl_setTableHeader();?>
<tbody>
<legend><?php echo __('Do a "query by example" (wildcard: "%") for two columns') ?></legend>
<table class="data">
<?php echo PMA_tbl_setTableHeader();?>
<tbody>
<?php
$odd_row = true;
for($i = 0 ; $i < 2 ; $i++){
for($i = 0 ; $i < 4 ; $i++){
if($i == 2){
echo "<tr><td>";
echo __("Additional search criteria");
echo "</td><tr>";
}
?>
<tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<th><select name="inputs[]" id=<?php echo 'tableid_' . $i?> >