mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-27 00:07:16 +00:00
Added terms-plot tool
This commit is contained in:
parent
fb3dea6bd2
commit
465d18fc73
2 changed files with 22 additions and 12 deletions
|
@ -679,14 +679,24 @@ def terms_plot_tool():
|
||||||
|
|
||||||
@app.route("/terms_plot_tool_data/")
|
@app.route("/terms_plot_tool_data/")
|
||||||
def 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')
|
term = request.args.get('term')
|
||||||
|
|
||||||
if term is None:
|
if term is None:
|
||||||
print 'cc'
|
return "None"
|
||||||
|
else:
|
||||||
|
value_range = []
|
||||||
return jsonify()
|
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/")
|
@app.route("/terms_plot_top/")
|
||||||
|
|
|
@ -177,17 +177,17 @@ var graph_options = {
|
||||||
function plotData(){
|
function plotData(){
|
||||||
var curthis = $(this);
|
var curthis = $(this);
|
||||||
var term = $('#TermInput').val();
|
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 = [];
|
var to_plot = [];
|
||||||
|
console.log(data);
|
||||||
|
var curr_data = [];
|
||||||
for(i=0; i<data.length; i++) {
|
for(i=0; i<data.length; i++) {
|
||||||
var curr_data = [];
|
curr_data.push([data[i][0]*1000, data[i][1]]);
|
||||||
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]});
|
|
||||||
}
|
}
|
||||||
|
to_plot.push({ data: curr_data, label: term});
|
||||||
var plot = $.plot($("#graph"), to_plot, graph_options);
|
var plot = $.plot($("#graph"), to_plot, graph_options);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue