Generate plotly html
This commit is contained in:
parent
c36429f3df
commit
bb201c83b5
21
display/generate_html.py
Normal file
21
display/generate_html.py
Normal file
@ -0,0 +1,21 @@
|
||||
import sqlite3
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
|
||||
TABLE_NAME = "stats"
|
||||
|
||||
INTERVAL = 20 # on cron interval is 10min
|
||||
|
||||
|
||||
# Create your connection.
|
||||
cnx = sqlite3.connect('data.sqlite')
|
||||
|
||||
df = pd.read_sql_query(f"SELECT * FROM {TABLE_NAME}", cnx)
|
||||
df = df.set_index("date")
|
||||
df = df[::INTERVAL]
|
||||
print(f"Find {len(df)} items")
|
||||
|
||||
|
||||
fig = px.area(df, title="Wide-Form Input")
|
||||
fig.for_each_trace(lambda trace: trace.update(fillcolor = trace.line.color))
|
||||
fig.write_html("stats.html", include_plotlyjs="cdn")
|
@ -1,5 +1,5 @@
|
||||
|
||||
|
||||
plotly
|
||||
pygal
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user