diff --git a/raspberry/python/templates/base.html.j2 b/raspberry/python/templates/base.html.j2
index cc36352..4d7f268 100644
--- a/raspberry/python/templates/base.html.j2
+++ b/raspberry/python/templates/base.html.j2
@@ -8,11 +8,11 @@
{% endblock %}
{% block navbar %}
-{{nav.top.render()}}
+ {{nav.top.render()}}
{% endblock %}
{% block body %}
{{super()}}
-
-{% endblock %}
\ No newline at end of file
+
+{% endblock %}
diff --git a/raspberry/python/templates/data_graph.html.j2 b/raspberry/python/templates/data_graph.html.j2
index f1468c1..d16b98b 100644
--- a/raspberry/python/templates/data_graph.html.j2
+++ b/raspberry/python/templates/data_graph.html.j2
@@ -3,16 +3,18 @@
{% block styles %}
{{super()}}
- {{ css_ressources }}
- {{ js_ressources }}
+ {{ css_resources|safe }}
+ {{ js_resources|safe }}
{% endblock %}
{% block content %}
{% from "bootstrap/pagination.html" import render_pagination %}
+
{{ plot_div|safe }}
-
+
{{ render_pagination(dat) }}
+
@@ -41,6 +43,7 @@
{{ render_pagination(dat) }}
+
{{ plot_script|safe }}
{% endblock %}
diff --git a/raspberry/python/web_app.py b/raspberry/python/web_app.py
index 82010b1..2b97c7b 100755
--- a/raspberry/python/web_app.py
+++ b/raspberry/python/web_app.py
@@ -1,3 +1,4 @@
+#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 17 22:25:52 2017
@@ -14,7 +15,7 @@ from flask import render_template
from flask_bootstrap import Bootstrap
from flask_nav import Nav
from flask_nav.elements import *
-
+import pandas as pd
from bokeh.plotting import figure
from bokeh.embed import components
from bokeh.models import ColumnDataSource
@@ -77,26 +78,27 @@ def all_data():
@app.route('/type_id=')
def by_data_type(dt):
- date_deb = datetime.utcnow()-timedelta(seconds=3600)
+ date_deb = datetime.now()-timedelta(hours=1)
#Récupération des données à afficher
- res = Data.query.filter(Data.type_id == dt).filter(Data.dbdate >= date_deb).order_by(Data.valdate)
+ q = Data.query.filter(Data.type_id == dt).filter(Data.dbdate >= date_deb).order_by(Data.valdate)
+ res = pd.read_sql(q.selectable, db.engine)
- plot_data = ColumnDataSource(data=dict(x = res.values('valdate'), y = res.values('value')))
+ plot_data = ColumnDataSource(data=dict(x = res['data_valdate'], y = res['data_value']))
#Préparation du graphique
- data_plot = figure(tools = TOOLS,
+ data_plot = figure(tools = "hover,pan,reset,save,wheel_zoom",
title = dt,
x_axis_label = 'Date',
x_axis_type = 'datetime',
y_axis_label = dt,
plot_height = 400,
- plot_width = 800,
+ plot_width = 1140,
)
data_plot.line('x', 'y', source=plot_data, line_width=2)
script, div = components(data_plot)
- return render_template('data_graph.html.j2', dat=res.order_by(Data.dbdate.desc()).paginate(per_page=15),
+ return render_template('data_graph.html.j2', dat=q.order_by(Data.dbdate.desc()).paginate(per_page=15),
plot_script=script,
plot_div=div,
js_resources=js_resources,