mirror of https://github.com/CIRCL/AIL-framework
Added terms-plot tool
parent
fb3dea6bd2
commit
465d18fc73
|
@ -679,14 +679,24 @@ def terms_plot_tool():
|
|||
|
||||
@app.route("/terms_plot_tool_data/")
|
||||
def terms_plot_tool_data():
|
||||
num_day = int(request.args.get('num_day'))
|
||||
oneDay = 60*60*24
|
||||
range_start = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_start')))) if request.args.get('range_start') is not None else 0;
|
||||
range_start = range_start.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
range_start = calendar.timegm(range_start.timetuple())
|
||||
range_end = datetime.datetime.utcfromtimestamp(int(float(request.args.get('range_end')))) if request.args.get('range_end') is not None else 0;
|
||||
range_end = range_end.replace(hour=0, minute=0, second=0, microsecond=0)
|
||||
range_end = calendar.timegm(range_end.timetuple())
|
||||
term = request.args.get('term')
|
||||
|
||||
if term is None:
|
||||
print 'cc'
|
||||
|
||||
|
||||
return jsonify()
|
||||
return "None"
|
||||
else:
|
||||
value_range = []
|
||||
for timestamp in range(range_start, range_end+oneDay, oneDay):
|
||||
value = r_serv_term.hget(timestamp, term)
|
||||
curr_value_range = int(value) if value is not None else 0
|
||||
value_range.append([timestamp, curr_value_range])
|
||||
return jsonify(value_range)
|
||||
|
||||
|
||||
@app.route("/terms_plot_top/")
|
||||
|
|
|
@ -177,17 +177,17 @@ var graph_options = {
|
|||
function plotData(){
|
||||
var curthis = $(this);
|
||||
var term = $('#TermInput').val();
|
||||
console.log(term);
|
||||
var range_start = new Date($( ".sliderRange" ).slider( "values", 0 )).getTime() / 1000;
|
||||
var range_end = new Date($( ".sliderRange" ).slider( "values", 1 )).getTime() / 1000;
|
||||
|
||||
$.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month, num_day: 31 }, function(data, status){
|
||||
$.getJSON("{{ url_for('terms_plot_tool_data') }}", { range_start: range_start, range_end: range_end, term: term }, function(data, status){
|
||||
var to_plot = [];
|
||||
for(i=0; i<data.length; i++) {
|
||||
console.log(data);
|
||||
var curr_data = [];
|
||||
for(j=0; j<data[i][1].length; j++) {
|
||||
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
||||
}
|
||||
to_plot.push({ data: curr_data, label: data[i][0]});
|
||||
for(i=0; i<data.length; i++) {
|
||||
curr_data.push([data[i][0]*1000, data[i][1]]);
|
||||
}
|
||||
to_plot.push({ data: curr_data, label: term});
|
||||
var plot = $.plot($("#graph"), to_plot, graph_options);
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue