import plotly.express as px


import plotly.graph_objects as go


def load_data():
    tips = px.data.tips()
    return [
        (str(day), float(bill))
        for day, bill in tips[["day", "total_bill"]].itertuples(index=False, name=None)
    ]


def value_table(data):
    return {"columns": ["Day", "Bill (USD)"], "rows": [list(row) for row in data]}


def make_before(data) -> go.Figure:
    fig = go.Figure()
    for day in ("Thur", "Fri", "Sat", "Sun"):
        bills = [bill for name, bill in data if name == day]
        fig.add_trace(go.Box(y=bills, name=day, showlegend=False))
    fig.update_traces(boxpoints=False)
    fig.update_layout(template="simple_white", yaxis_title="Bill (USD)")
    return fig


if __name__ == "__main__":
    print(make_before(load_data()).to_json())
