Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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),
    ]
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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)]
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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),
    ]
Exemplo n.º 7
0
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)]
Exemplo n.º 8
0
def update_hist(startdate):
    df = data(CONN_STR, startdate=str(startdate))
    return histogram_(df)
Exemplo n.º 9
0
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',
Exemplo n.º 10
0
def update_table(datepart, startdate):
    #print(startdate)
    df = data(CONN_STR)
    rows = bloodsugar_describe(df, datepart,
                               startdate=str(startdate)).to_dict('records')
    return rows
Exemplo n.º 11
0
def update_graph(startdate, graph):
    df = data(CONN_STR, startdate=str(startdate))
    if graph == 'histogram':
        return histogram_(df)
    else:
        return scatter_(df)