diff options
author | Madhura Jayaratne <madhura.cj@gmail.com> | 2014-08-21 17:59:29 +0400 |
---|---|---|
committer | Madhura Jayaratne <madhura.cj@gmail.com> | 2014-08-21 17:59:29 +0400 |
commit | 94738c9e67c1c92be465e4a73ec50260075e9851 (patch) | |
tree | cfb4e9121534523a787506b623a318b5d2173a50 /js/tbl_chart.js | |
parent | ed6968eabccf210bbdff467382cfa6800ea63d6c (diff) | |
parent | fae385866931b72a15fcabc2ef805bd629ada2a1 (diff) |
Merge branch 'QA_4_2'
Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
Diffstat (limited to 'js/tbl_chart.js')
-rw-r--r-- | js/tbl_chart.js | 92 |
1 files changed, 53 insertions, 39 deletions
diff --git a/js/tbl_chart.js b/js/tbl_chart.js index 1dafa0f5d0..c909141242 100644 --- a/js/tbl_chart.js +++ b/js/tbl_chart.js @@ -6,6 +6,9 @@ var temp_chart_title; var currentChart = null; var currentSettings = null; +var dateTimeCols = []; +var numericCols = []; + function extractDate(dateString) { var matches, match; var dateTimeRegExp = /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/; @@ -176,6 +179,51 @@ function getSelectedSeries() { return ret; } +function onXAxisChange() { + var $xAxisSelect = $('select[name="chartXAxis"]'); + currentSettings.mainAxis = parseInt($xAxisSelect.val(), 10); + if (dateTimeCols.indexOf(currentSettings.mainAxis) != -1) { + $('span.span_timeline').show(); + } else { + $('span.span_timeline').hide(); + if (currentSettings.type == 'timeline') { + $('input#radio_line').prop('checked', true); + currentSettings.type = 'line'; + } + } + if (numericCols.indexOf(currentSettings.mainAxis) != -1) { + $('span.span_scatter').show(); + } else { + $('span.span_scatter').hide(); + if (currentSettings.type == 'scatter') { + $('input#radio_line').prop('checked', true); + currentSettings.type = 'line'; + } + } + var xaxis_title = $xAxisSelect.children('option:selected').text(); + $('input[name="xaxis_label"]').val(xaxis_title); + currentSettings.xaxisLabel = xaxis_title; +} + +function onDataSeriesChange() { + var $seriesSelect = $('select[name="chartSeries"]'); + currentSettings.selectedSeries = getSelectedSeries(); + var yaxis_title; + if (currentSettings.selectedSeries.length == 1) { + $('span.span_pie').show(); + yaxis_title = $seriesSelect.children('option:selected').text(); + } else { + $('span.span_pie').hide(); + if (currentSettings.type == 'pie') { + $('input#radio_line').prop('checked', true); + currentSettings.type = 'line'; + } + yaxis_title = PMA_messages.strYValues; + } + $('input[name="yaxis_label"]').val(yaxis_title); + currentSettings.yaxisLabel = yaxis_title; +} + /** * Unbind all event handlers before tearing down a page */ @@ -288,13 +336,11 @@ AJAX.registerOnload('tbl_chart.js', function () { } }); - var dateTimeCols = []; var vals = $('input[name="dateTimeCols"]').val().split(' '); $.each(vals, function (i, v) { dateTimeCols.push(parseInt(v, 10)); }); - var numericCols = []; vals = $('input[name="numericCols"]').val().split(' '); $.each(vals, function (i, v) { numericCols.push(parseInt(v, 10)); @@ -302,48 +348,13 @@ AJAX.registerOnload('tbl_chart.js', function () { // handle changing the x-axis $('select[name="chartXAxis"]').change(function () { - currentSettings.mainAxis = parseInt($(this).val(), 10); - if (dateTimeCols.indexOf(currentSettings.mainAxis) != -1) { - $('span.span_timeline').show(); - } else { - $('span.span_timeline').hide(); - if (currentSettings.type == 'timeline') { - $('input#radio_line').prop('checked', true); - currentSettings.type = 'line'; - } - } - if (numericCols.indexOf(currentSettings.mainAxis) != -1) { - $('span.span_scatter').show(); - } else { - $('span.span_scatter').hide(); - if (currentSettings.type == 'scatter') { - $('input#radio_line').prop('checked', true); - currentSettings.type = 'line'; - } - } - var xaxis_title = $(this).children('option:selected').text(); - $('input[name="xaxis_label"]').val(xaxis_title); - currentSettings.xaxisLabel = xaxis_title; + onXAxisChange(); drawChart(); }); // handle changing the selected data series $('select[name="chartSeries"]').change(function () { - currentSettings.selectedSeries = getSelectedSeries(); - var yaxis_title; - if (currentSettings.selectedSeries.length == 1) { - $('span.span_pie').show(); - yaxis_title = $(this).children('option:selected').text(); - } else { - $('span.span_pie').hide(); - if (currentSettings.type == 'pie') { - $('input#radio_line').prop('checked', true); - currentSettings.type = 'line'; - } - yaxis_title = PMA_messages.strYValues; - } - $('input[name="yaxis_label"]').val(yaxis_title); - currentSettings.yaxisLabel = yaxis_title; + onDataSeriesChange(); drawChart(); }); @@ -373,6 +384,9 @@ AJAX.registerOnload('tbl_chart.js', function () { saveChartAsImage(); }); + onXAxisChange(); + onDataSeriesChange(); + $("#tblchartform").submit(); }); |