Linked plot button with server

pull/68/head
Mokaddem 2016-08-15 15:54:53 +02:00
parent 82f70e61f4
commit 88ed8a239d
2 changed files with 36 additions and 8 deletions

View File

@ -474,18 +474,23 @@ def sentiment_analysis_plot_tool():
@app.route("/sentiment_analysis_plot_tool_getdata/")
@app.route("/sentiment_analysis_plot_tool_getdata/", methods=['GET'])
def sentiment_analysis_plot_tool_getdata():
getProviders = request.args.get('getProviders')
if getProviders:
if getProviders == 'True':
providers = []
for cur_provider in r_serv_charts.smembers('providers_set'):
providers.append(cur_provider)
return jsonify(providers)
else:
return 0
query = request.args.get('query')
Qdate = request.args.get('Qdate')
print query
print Qdate
data = [[1,12], [2,32], [3,11]]
return jsonify(data)

View File

@ -94,7 +94,7 @@
</div>
<!-- /.row -->
<div class="row">
<button class="btn btn-info" style="margin-right: 8px; float: right;">Plot!</button>
<button id="plot_btn" class="btn btn-info" style="margin-right: 8px; float: right;">Plot!</button>
</div>
</div>
<!-- /.panel-body -->
@ -139,14 +139,14 @@
$(document).ready(function(){
activePage = $('h1.page-header').attr('data-page');
$("#"+activePage).addClass("active");
var li_text = "<li><div class='checkbox'></div><label class='provider'><input value='' type='checkbox'></input> "
var li_text = "<li><div class='checkbox'></div><label class='provider'><input value='"
var li_text_mid = "' type='checkbox'></input> "
var li_text_end = "</label></li>"
$.getJSON('/sentiment_analysis_plot_tool_getdata/?getProviders=True', function(data){
console.log(data);
for(i=0; i<data.length; i++){
var providerList = i%2 == 0 ? '#providerList1' : '#providerList2';
$(providerList).append(li_text + data[i] + li_text_end);
$(providerList).append(li_text + data[i] + li_text_mid + data[i] + li_text_end);
}
});
@ -167,6 +167,28 @@
$( "#amount" ).val( new Date($( ".sliderRange" ).slider( "values", 0 )).toLocaleDateString() +
" - " + new Date($( ".sliderRange" ).slider( "values", 1 )).toLocaleDateString() );
$('#plot_btn').click(plotData);
function plotData(){
var query = $( "input:checked" ).map(function () {return this.value;}).get().join(",");
var Qdate = 2;
$.getJSON('/sentiment_analysis_plot_tool_getdata/?getProviders=False&query='+query+'&Qdate='+Qdate, function(data){
console.log(data);
});
}
function randNum(){
return ((Math.floor( Math.random()* (1+40-20) ) ) + 20)* 1200;
}
@ -175,9 +197,10 @@
var likes = [[1, 5+randNum()], [2, 10+randNum()], [3, 15+randNum()], [4, 20+randNum()],[5, 25+randNum()],[6, 30+randNum()],[7, 35+randNum()],[8, 40+randNum()],[9, 45+randNum()],[10, 50+randNum()],[11, 55+randNum()],[12, 60+randNum()],[13, 65+randNum()],[14, 70+randNum()],[15, 75+randNum()],[16, 80+randNum()],[17, 85+randNum()],[18, 90+randNum()],[19, 85+randNum()],[20, 80+randNum()],[21, 75+randNum()],[22, 80+randNum()],[23, 75+randNum()],[24, 70+randNum()],[25, 65+randNum()],[26, 75+randNum()],[27,80+randNum()],[28, 85+randNum()],[29, 90+randNum()], [30, 95+randNum()]];
var likes2 = [[1, 5+randNum()], [2, 10+randNum()], [3, 15+randNum()], [4, 20+randNum()],[5, 25+randNum()],[6, 30+randNum()],[7, 35+randNum()],[8, 40+randNum()],[9, 45+randNum()],[10, 50+randNum()],[11, 55+randNum()],[12, 60+randNum()],[13, 65+randNum()],[14, 70+randNum()],[15, 75+randNum()],[16, 80+randNum()],[17, 85+randNum()],[18, 90+randNum()],[19, 85+randNum()],[20, 80+randNum()],[21, 75+randNum()],[22, 80+randNum()],[23, 75+randNum()],[24, 70+randNum()],[25, 65+randNum()],[26, 75+randNum()],[27,80+randNum()],[28, 85+randNum()],[29, 90+randNum()], [30, 95+randNum()]];
var plot = $.plot($("#graph"),
[ { data: likes, label: "Fans"} ], {
[ { data: likes, label: "Fans"}, { data: likes2, label: "Fans"} ], {
series: {
lines: { show: true,
lineWidth: 2,