diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index be634e77..8a2d4d37 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -677,6 +677,18 @@ def terms_plot_tool(): return render_template("terms_plot_tool.html") +@app.route("/terms_plot_tool_data/") +def terms_plot_tool_data(): + num_day = int(request.args.get('num_day')) + term = request.args.get('term') + + if term is None: + print 'cc' + + + return jsonify() + + @app.route("/terms_plot_top/") def terms_plot_top(): return render_template("terms_plot_top.html") diff --git a/var/www/templates/terms_plot_tool.html b/var/www/templates/terms_plot_tool.html index c3373658..d663eb60 100644 --- a/var/www/templates/terms_plot_tool.html +++ b/var/www/templates/terms_plot_tool.html @@ -76,8 +76,8 @@
- - + +
@@ -139,13 +139,62 @@ } }); -$( "#amount" ).val( new Date($( ".sliderRange" ).slider( "values", 0 )).toLocaleDateString() + - " - " + new Date($( ".sliderRange" ).slider( "values", 1 )).toLocaleDateString() ); - -$('#plot_btn').click(plotData); + $( "#amount" ).val( new Date($( ".sliderRange" ).slider( "values", 0 )).toLocaleDateString() + + " - " + new Date($( ".sliderRange" ).slider( "values", 1 )).toLocaleDateString() ); + + $('#plot-btn').click(plotData); }); + + + diff --git a/var/www/templates/terms_plot_top.html b/var/www/templates/terms_plot_top.html index f17e4f37..d7c4c8c4 100644 --- a/var/www/templates/terms_plot_top.html +++ b/var/www/templates/terms_plot_top.html @@ -307,6 +307,10 @@ set_today = "TopTermFreq_set_day"; set_week = "TopTermFreq_set_week"; set_month = "TopTermFreq_set_month"; +var plot_today; +var plot_week; +var plot_month; + var promises = []; // Used to know when everything has been received promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today, num_day: 1 }, function(data, status){ @@ -323,15 +327,14 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today } to_plot.push({ data: curr_data, label: data[i][0]}); if ( i < (data.length/2)) - table_today.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-today", data[i][0])+"") + table_today.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0])+"") else - table_today2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-today", data[i][0])+"") + table_today2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("today", data[i][0])+"") } - var plot_today = $.plot($("#graph-today"), to_plot, graph_options); + plot_today = $.plot($("#graph-today"), to_plot, graph_options); })); promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, num_day: 7 }, function(data, status){ - console.log(data); data.sort(function(a, b){return b[2]-a[2];}); // Sort data var table = $("#table-week") @@ -344,15 +347,14 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, } to_plot.push({ data: curr_data, label: data[i][0]}); if ( i < (data.length/2)) - table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-week", data[i][0])+"") + table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0])+"") else - table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-week", data[i][0])+"") + table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("week", data[i][0])+"") } - var plot_week = $.plot($("#graph-week"), to_plot, graph_options); + plot_week = $.plot($("#graph-week"), to_plot, graph_options); })); promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month, num_day: 31 }, function(data, status){ - console.log(data); data.sort(function(a, b){return b[2]-a[2];}); // Sort data var table = $("#table-month") @@ -365,11 +367,11 @@ promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month } to_plot.push({ data: curr_data, label: data[i][0]}); if ( i < (data.length/2)) - table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-month", data[i][0])+"") + table.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0])+"") else - table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("graph-month", data[i][0])+"") + table2.append(""+data[i][0]+""+data[i][2]+""+addbuttons(data[i][0])+""+addcheckbox("month", data[i][0])+"") } - var plot_month = $.plot($("#graph-month"), to_plot, graph_options); + plot_month = $.plot($("#graph-month"), to_plot, graph_options); })); /* When everything has been received, start adding tooltip */ @@ -384,9 +386,9 @@ $.when.apply($, promises).done( function (arg) { function addbuttons(term) { - return ""+ - ""; } @@ -401,7 +403,6 @@ function perform_operation(){ var data_to_send = { section: curr_section, action:"add", term: curr_term}; - console.log(data_to_send); $.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){ if(status == "success") { location.reload(); @@ -414,6 +415,44 @@ function hide_or_show() { var graph = $(this).attr('data-graph'); var checked = $(this).prop('checked') console.log(curr_term + ' ' + graph + ' ' + checked); + + if(graph == "today") { + var graphData = plot_today.getData(); + var index; + for(i=0; i