Commit 3736be77 authored by Kristian Tan's avatar Kristian Tan

Order chart by date

parent fe057870
from flask import Flask, render_template, request from flask import Flask, render_template, request
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import desc from sqlalchemy import asc
import os import os
from datetime import datetime, date, timedelta from datetime import datetime, date, timedelta
# from daily_usage import DailyUsage # from daily_usage import DailyUsage
...@@ -103,7 +103,7 @@ def main(): ...@@ -103,7 +103,7 @@ def main():
values = [] values = []
max = 0 max = 0
records = DailyUsage.query.order_by(desc(DailyUsage.date)).all() records = DailyUsage.query.order_by(asc(DailyUsage.date)).all()
for record in records: for record in records:
labels.append(date(record.date.year, record.date.month, record.date.day)) labels.append(date(record.date.year, record.date.month, record.date.day))
values.append(record.kwhUsed) values.append(record.kwhUsed)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment