diff options
author | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-10-28 20:51:37 +0400 |
---|---|---|
committer | Atul Pratap Singh <atulpratapsingh05@gmail.com> | 2012-10-28 20:51:37 +0400 |
commit | aa12956816f857e22d67e327cfd01afa0d8147e8 (patch) | |
tree | 583a24231c05135f2c33fde1e52f11658b55aedf /js/tbl_chart.js | |
parent | e89b5cd217b40e2d988ffab2ef0a7c933e5ca57a (diff) |
Fix bug #3571970 for master
Diffstat (limited to 'js/tbl_chart.js')
-rw-r--r-- | js/tbl_chart.js | 77 |
1 files changed, 58 insertions, 19 deletions
diff --git a/js/tbl_chart.js b/js/tbl_chart.js index 62a63a5d7d..2dd576fa24 100644 --- a/js/tbl_chart.js +++ b/js/tbl_chart.js @@ -2,12 +2,14 @@ var chart_xaxis_idx = -1; var chart_series; -var chart_data; +var chart_data = null; var temp_chart_title; var y_values_text; +var currentChart = null; +var nonJqplotSettings = null; +var currentSettings = null; $(function() { - var currentChart = null; chart_series = $('select[name="chartSeries"]').val(); // If no series is selected null is returned. // In such case initialize chart_series to empty array. @@ -30,7 +32,7 @@ $(function() { currentChart.replot( {resetAxes: true}) }); - var nonJqplotSettings = { + nonJqplotSettings = { chart: { type: 'line', width: $('#resizer').width() - 20, @@ -38,7 +40,7 @@ $(function() { } } - var currentSettings = { + currentSettings = { grid: { drawBorder: false, shadow: false, @@ -140,24 +142,50 @@ $(function() { currentSettings.axes.yaxis.label = $(this).val(); drawChart(); }); +}); - function drawChart() { - nonJqplotSettings.chart.width = $('#resizer').width() - 20; - nonJqplotSettings.chart.height = $('#resizer').height() - 20; - - // todo: a better way using .replot() ? - if (currentChart != null) { - currentChart.destroy(); - } - currentChart = PMA_queryChart(chart_data, currentSettings, nonJqplotSettings); + +/** + * Ajax Event handler for 'Go' button click + * + */ +$("#tblchartform").live('submit', function(event) { + if(!checkFormElementInRange(this, 'session_max_rows', PMA_messages['strNotValidRowNumber'], 1) + || !checkFormElementInRange(this, 'pos', PMA_messages['strNotValidRowNumber'], 0-1)) { + return false; + } + + var $form = $(this); + if (! checkSqlQuery($form[0])) { + return false; } + // remove any div containing a previous error message + $('.error').remove(); + var $msgbox = PMA_ajaxShowMessage(); + PMA_prepareForAjaxRequest($form); + + $.post($form.attr('action'), $form.serialize() , function(data) { + if (data.success == true) { + $('.success').fadeOut(); + if (typeof data.chartData != 'undefined') { + chart_data = jQuery.parseJSON(data.chartData); + drawChart(); + $('div#querychart').height($('div#resizer').height() * 0.96); + $('div#querychart').width($('div#resizer').width() * 0.96); + currentChart.replot( {resetAxes: true}); + $('#querychart').show(); + } + } else { + PMA_ajaxRemoveMessage($msgbox); + PMA_ajaxShowMessage(data.error, false); + chart_data = null; + drawChart(); + } + PMA_ajaxRemoveMessage($msgbox); + }, "json"); // end $.post() - drawChart(); - $('div#querychart').height($('div#resizer').height() * 0.96); - $('div#querychart').width($('div#resizer').width() * 0.96); - currentChart.replot( {resetAxes: true}) - $('#querychart').show(); -}); + return false; +}); // end function isColumnNumeric(columnName) { @@ -172,6 +200,17 @@ function isColumnNumeric(columnName) return isNumeric; } +function drawChart() { + nonJqplotSettings.chart.width = $('#resizer').width() - 20; + nonJqplotSettings.chart.height = $('#resizer').height() - 20; + + // todo: a better way using .replot() ? + if (currentChart != null) { + currentChart.destroy(); + } + currentChart = PMA_queryChart(chart_data, currentSettings, nonJqplotSettings); +} + function PMA_queryChart(data, passedSettings, passedNonJqplotSettings) { if ($('#querychart').length == 0) { |