Plot live cadence data
This commit is contained in:
9
app.py
9
app.py
@@ -53,7 +53,14 @@ def home():
|
||||
def overview():
|
||||
cadences = db.get_all_cadences()
|
||||
last_cadence = cadences[-1]['rpm']
|
||||
return render_template('overview.html', last_cadence=last_cadence, cadences=cadences)
|
||||
|
||||
plot = {
|
||||
"x": [c['logged_at'] for c in cadences],
|
||||
"y": [c['rpm'] for c in cadences],
|
||||
"type": 'scatter'
|
||||
}
|
||||
|
||||
return render_template('overview.html', last_cadence=last_cadence, plot=plot, cadences=cadences)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,7 +1,18 @@
|
||||
<h1
|
||||
class="mb-4 text-4xl font-extrabold leading-none tracking-tight text-gray-900 md:text-5xl lg:text-6xl dark:text-white">
|
||||
class="mb-4 text-4xl font-extrabold leading-none tracking-tight text-gray-900 md:text-5xl lg:text-6xl dark:text-white text-center">
|
||||
{{last_cadence}} rpm</h1>
|
||||
|
||||
<div id="overview-plot" class="w-full mt-2 aspect-video"></div>
|
||||
<script>
|
||||
Plotly.newPlot(document.getElementById("overview-plot"), [
|
||||
{{ plot | tojson}}
|
||||
], {
|
||||
margin: { t: 0 }, xaxis: { showgrid: false, showticklabels: false }, yaxis: {
|
||||
showgrid: false
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="relative overflow-x-auto">
|
||||
<table class="w-full text-sm text-left text-gray-500 dark:text-gray-400">
|
||||
<thead class="text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
|
||||
|
||||
Reference in New Issue
Block a user