def update_graph(hours_radio=None, hours_text=None): if hours_text: try: hours_text = int(hours_text) df = data(CONN_STR, time_unit='h', amount=int(hours_text)) except: df = data(CONN_STR, time_unit='h', amount=hours_radio) else: df = data(CONN_STR, time_unit='h', amount=hours_radio) return scatter_(df)
def update_time(): df = data(CONN_STR, latest=True) time = df.at[0, 'min_diff'] style = { 'padding': '20px', 'fontSize': '20px', 'background-color': 'grey', "display": "inline-block" } return [ html.Span('Tid: {0:.2f}'.format(time), style=style), ]
def update_scatt(startdate, datepart): df = data(CONN_STR, startdate=str(startdate)) return boxplot_(df, datepart=datepart) #@app.callback( # Output('datatable-bloodsugar-describe', 'rows'), # [Input('dropdown-datepart', 'value'), # Input('input-startdate', 'value')]) #def update_table(datepart, startdate): # #print(startdate) # df = data(CONN_STR) # rows = bloodsugar_describe(df, datepart, startdate=str(startdate)).to_dict('records') # return rows
def update_blood(): df = data(CONN_STR, latest=True) blood_sugar = df.at[0, 'mmol'] if blood_sugar >= 10: style = { 'padding': '20px', 'fontSize': '32px', 'background-color': 'red' } elif 4 <= blood_sugar < 10: style = { 'padding': '20px', 'fontSize': '32px', 'background-color': 'green' } else: style = { 'padding': '20px', 'fontSize': '32px', 'background-color': 'pink' } return [html.Span('Blodsocker: {0:.2f}'.format(blood_sugar), style=style)]
import dash import numpy as np from apps.src.secrets import CONN_STR from apps.src.data import data df = data(CONN_STR, latest=True) app = dash.Dash(__name__) app.title = str(np.round(df.at[0, 'mmol'],1)) server = app.server app.config.suppress_callback_exceptions = True
def update_time(update): df = data(CONN_STR, latest=True) time = df.at[0, 'min_diff'] return [ html.Span(f'Tid: {time} min', style=style_time), ]
def update_blood(update): df = data(CONN_STR, latest=True) blood_sugar = df.at[0, 'mmol'] style = style_(blood_sugar) return [html.Span('Blodsocker: {0:.2f}'.format(blood_sugar), style=style)]
def update_hist(startdate): df = data(CONN_STR, startdate=str(startdate)) return histogram_(df)
import plotly.graph_objs as go import datetime import json import pandas as pd import numpy as np import plotly from apps.src.data import data, bloodsugar_describe from apps.src.fig import scatter_, histogram_, boxplot_ from apps.src.html_style import style_ from apps.src.secrets import CONN_STR from app import app style = {'padding': '5px', 'fontSize': '16px', 'color': 'red'} startdate = datetime.date.today() - datetime.timedelta(days=14) df = data(CONN_STR, startdate=str(startdate)) dateparts = ['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'] graphs = ['scatter', 'histogram'] df1 = bloodsugar_describe(df, 'week') #print(df1.head()) dfb = data(CONN_STR, latest=True) blood_sugar = dfb.at[0, 'mmol'] style = style_(blood_sugar) time = dfb.at[0, 'min_diff'] style_time = style_() dateparts = [ 'minute', 'hour', 'weekday', 'day', 'week', 'month', 'quarter', 'year' ] layout = html.Div([ dcc.Input(id='input-startdate',
def update_table(datepart, startdate): #print(startdate) df = data(CONN_STR) rows = bloodsugar_describe(df, datepart, startdate=str(startdate)).to_dict('records') return rows
def update_graph(startdate, graph): df = data(CONN_STR, startdate=str(startdate)) if graph == 'histogram': return histogram_(df) else: return scatter_(df)