Plot prices using plotly
This commit is contained in:
65
static/plotly-2.12.1.min.js
vendored
Normal file
65
static/plotly-2.12.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -4,6 +4,7 @@
|
|||||||
<link rel="stylesheet" href="/static/classless.css">
|
<link rel="stylesheet" href="/static/classless.css">
|
||||||
<link rel="stylesheet" href="/static/fioul.css">
|
<link rel="stylesheet" href="/static/fioul.css">
|
||||||
<link rel="icon" type="image/png" href="/static/favicon.png" />
|
<link rel="icon" type="image/png" href="/static/favicon.png" />
|
||||||
|
<script src="/static/plotly-2.12.1.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Prix du m³ de fioul pour Languidic</h1>
|
<h1>Prix du m³ de fioul pour Languidic</h1>
|
||||||
@@ -16,5 +17,27 @@
|
|||||||
</tr>
|
</tr>
|
||||||
% end
|
% end
|
||||||
</table>
|
</table>
|
||||||
|
<div id="price-plot"></div>
|
||||||
|
<script>
|
||||||
|
var plotDiv = document.getElementById('price-plot');
|
||||||
|
var plotData = [{
|
||||||
|
x: {{ [str(d.date) for d in results] }},
|
||||||
|
y: {{ [d.price for d in results] }},
|
||||||
|
type: 'scatter',
|
||||||
|
}];
|
||||||
|
var plotLayout = {
|
||||||
|
margin: { t: 0 }
|
||||||
|
};
|
||||||
|
var plotConfig = {
|
||||||
|
responsive: true,
|
||||||
|
displaylogo: false,
|
||||||
|
};
|
||||||
|
Plotly.newPlot(
|
||||||
|
plotDiv,
|
||||||
|
plotData,
|
||||||
|
plotLayout,
|
||||||
|
plotConfig,
|
||||||
|
);
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -6,15 +6,14 @@ from bottle import hook, request, route, run, static_file, view
|
|||||||
import models
|
import models
|
||||||
from models import Price
|
from models import Price
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# Web application
|
# Web application
|
||||||
|
|
||||||
|
|
||||||
@route("/")
|
@route("/")
|
||||||
@view("search_results")
|
@view("search_results", template_settings={'noescape':True})
|
||||||
def results_page():
|
def results_page():
|
||||||
query = Price.select().order_by(Price.date.desc())
|
results = Price.select().order_by(Price.date.desc())
|
||||||
results = list(query)
|
|
||||||
day_classes = {
|
day_classes = {
|
||||||
0: "monday",
|
0: "monday",
|
||||||
1: "tuesday",
|
1: "tuesday",
|
||||||
|
|||||||
Reference in New Issue
Block a user