From 4eee45db5a29c47ba42c3db2afbd7dcc5f2d4cf5 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 28 Apr 2012 12:36:49 +0530 Subject: [PATCH] Update axis title upon changing the axis --- js/tbl_chart.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/tbl_chart.js b/js/tbl_chart.js index 05600ee5e8..0f510f700e 100644 --- a/js/tbl_chart.js +++ b/js/tbl_chart.js @@ -4,11 +4,13 @@ var chart_series; var chart_series_index = -1; var chart_data; var temp_chart_title; +var y_values_text; $(function() { var currentChart = null; chart_series = 'columns'; chart_xaxis_idx = $('select[name="chartXAxis"]').val(); + y_values_text = $('input[name="yaxis_label"]').val(); $('#resizer').resizable({ minHeight:240, @@ -88,6 +90,9 @@ $(function() { $('select[name="chartXAxis"]').change(function() { chart_xaxis_idx = this.value; + var xaxis_title = $(this).children('option:selected').text(); + $('input[name="xaxis_label"]').val(xaxis_title); + currentSettings.xAxis.title.text = xaxis_title; drawChart(); }); $('select[name="chartSeries"]').change(function() { @@ -95,13 +100,18 @@ $(function() { chart_series_index = this.selectedIndex; if (chart_series_index != 0) { $('span.span_pie').show(); - } else if ($(this).children('option').size() > 2) { + var yaxis_title = $(this).children('option:selected').text(); + } else { $('span.span_pie').hide(); if (currentSettings.chart.type == 'pie') { $('input#radio_line').prop('checked', true); currentSettings.chart.type = 'line'; } + var yaxis_title = y_values_text; } + $('input[name="yaxis_label"]').val(yaxis_title); + currentSettings.yAxis.title.text = yaxis_title; + drawChart(); });