import plotly.graph_objects as go


def load_data():
    return [
        (1, 118),
        (2, 122),
        (3, 120),
        (4, 129),
        (5, 125),
        (6, 121),
        (7, 119),
    ]


def value_table(data):
    return {
        "columns": ["Day", "Water use (m³)"],
        "rows": [list(row) for row in data],
    }


def _water_use_chart(data) -> go.Figure:
    periods, values = zip(*data, strict=True)
    fig = go.Figure(
        go.Scatter(x=periods, y=values, mode="lines+markers", line={"color": "#246487"})
    )
    fig.update_layout(
        template="simple_white",
        font={"family": "Inter, system-ui, -apple-system, sans-serif", "color": "#1f2937"},
        title={"text": "Daily water use at the depot", "x": 0.08},
        xaxis={
            "title": "Day of the week",
            "tickmode": "array",
            "tickvals": list(periods),
            "tickangle": 0,
        },
        yaxis_title="Water use (m³)",
        margin={"l": 68, "r": 28, "t": 80, "b": 65},
    )
    return fig


def make_before(data) -> go.Figure:
    fig = _water_use_chart(data)
    fig.update_xaxes(autorange="reversed", ticks="inside", ticklen=14)
    fig.update_yaxes(tick0=0, dtick=1, ticks="inside", ticklen=14)
    return fig


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