diff options
Diffstat (limited to '97suifangqa/apps/indicator/static/javascripts/card_chart.js')
-rw-r--r-- | 97suifangqa/apps/indicator/static/javascripts/card_chart.js | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/97suifangqa/apps/indicator/static/javascripts/card_chart.js b/97suifangqa/apps/indicator/static/javascripts/card_chart.js index 75cbf78..92a91c0 100644 --- a/97suifangqa/apps/indicator/static/javascripts/card_chart.js +++ b/97suifangqa/apps/indicator/static/javascripts/card_chart.js @@ -129,7 +129,7 @@ $(document).ready(function(){ //console.log(event); //console.log(this); var date = moment(this.x).utc().format('YYYY-MM-DD'); - TB_show(false, indicator_url+'popup/edithistorydata?card_id='+detail_card_id+'&date='+date+'&no_title=true&TB_iframe=true&height=351&width=630', false); + TB_show(false, indicator_url+'popup/edithistorydata?card_id='+detail_card_id+'&date='+date+'&no_title=true&TB_iframe=true&height=360&width=632', false); } } } @@ -138,9 +138,9 @@ $(document).ready(function(){ var getdata_type = "num"; var getdata_num = 10; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_date_str, end_date_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_date_str, end_date_str ); $(".act_card_container").addClass("move_div_2_left"); return false; @@ -152,17 +152,14 @@ $(document).ready(function(){ $(this).removeClass("unselected"); var begin_str = $(this).attr("begin_date"); var end_date = $(this).attr("end_date"); - // add 2 days to 'end_str' - // otherwise xAxis maybe incomplete to show the last data point var end_mm = moment(end_date); - end_mm.add('days', 2); var end_str = end_mm.format('YYYY-MM-DD'); var getdata_type = "date"; var getdata_num = null; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_str, end_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str ); return false; }); @@ -172,17 +169,14 @@ $(document).ready(function(){ $(".shift_date").addClass("unselected"); var begin_str = $("#search_begin_date").val(); var end_date = $("#search_end_date").val(); - // add 2 days to 'end_str' - // otherwise xAxis maybe incomplete to show the last data point var end_mm = moment(end_date); - end_mm.add('days', 2); var end_str = end_mm.format('YYYY-MM-DD'); var getdata_type = "date"; var getdata_num = null; detail_chart_getdata_draw(detail_chart_str, - detail_chart_options_str, - getdata_type, getdata_num, - begin_str, end_str + detail_chart_options_str, + getdata_type, getdata_num, + begin_str, end_str ); return false; }); @@ -226,6 +220,7 @@ $(document).ready(function(){ }); }); +// detail_chart_getdata_draw {{{ // destroy the original chart and new. // chart_str: (string), // name of global var of chart to draw; @@ -256,27 +251,34 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end //console.log(dataJson); if (dataJson.failed || dataJson.number_rsp == 0) { // getdata failed or get no data + // XXX: tooltip?? return false; } else { var begin_dt = moment(dataJson.begin_rsp); var end_dt = moment(dataJson.end_rsp); + var begin_dt_axis = begin_dt.clone(); + var end_dt_axis = end_dt.clone(); if (dataJson.number_rsp == 1) { // only one data point // (3days) dp_date (4days) - begin_dt.subtract('days', 3); - end_dt.add('days', 4); + begin_dt_axis.subtract('days', 3); + end_dt_axis.add('days', 4); } else { var diff_days = end_dt.diff(begin_dt, 'days'); var days_toadd = Math.floor(diff_days*0.10) + 1; - end_dt.add('days', days_toadd); + end_dt_axis.add('days', days_toadd); } // type == "date" if (type == "date") { // use date of request instead begin_dt = moment(dataJson.begin_req); end_dt = moment(dataJson.end_req); + // add 2 days to 'end_dt' + // otherwise xAxis maybe incomplete + // to show the last data point + end_dt_axis = end_dt.clone().add('days', 2); } // update datepicker @@ -291,8 +293,8 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end // set chart data window[options_str].chart.renderTo = chart_str; - window[options_str].xAxis.min = begin_dt.valueOf(); - window[options_str].xAxis.max = end_dt.valueOf(); + window[options_str].xAxis.min = begin_dt_axis.valueOf(); + window[options_str].xAxis.max = end_dt_axis.valueOf(); window[options_str].series[0].data = dataJson.data; // destroy original chart and // redraw with new options and data @@ -305,11 +307,12 @@ function detail_chart_getdata_draw(chart_str, options_str, type, num, begin, end } }); } +// }}} -// get data for detail card table +// get data for detail card table {{{ // if append=true, then keep original data, // otherwise, replace original data with new data -function get_card_data_table(type, num, begin, end, append){ +function get_card_data_table(type, num, begin, end, append) { var type2 = type || "num"; // default get data by 'num' var num2 = num || ""; var begin2 = begin || ""; @@ -343,13 +346,13 @@ function get_card_data_table(type, num, begin, end, append){ } var record_html = r.value_html + unit_str; if (r.is_normal == true) { - var state = '正常'; + var state = '<span class="normal">正常</span>'; } else if (r.is_normal == false) { - var state = '不正常'; + var state = '<span class="abnormal">不正常</span>'; } else { - var state = '未知'; + var state = '<span class="unknwon">未知</span>'; } // tr_html var tr_html = '<tr id="record_' + r.id + '">'; @@ -357,7 +360,7 @@ function get_card_data_table(type, num, begin, end, append){ tr_html += '<td class="record">' + record_html + '</td>'; tr_html += '<td class="state">' + state + '</td>'; tr_html += '</tr>'; - //console.log('tr_html: ', tr_html); + //console.log('tr_html: '+tr_html); data_html += tr_html + '\n'; } // update table @@ -377,5 +380,6 @@ function get_card_data_table(type, num, begin, end, append){ } }); } +// }}} // vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=javascript: // |