import plotly.graph_objects as go


def load_data():
    return [
        ("Jan", 42, "Observed"),
        ("Feb", 44, "Observed"),
        ("Mar", 43, "Observed"),
        ("Apr", 48, "Observed"),
        ("May", 51, "Observed"),
        ("Jun", 54, "Forecast"),
        ("Jul", 58, "Forecast"),
        ("Aug", 60, "Forecast"),
    ]


def value_table(data):
    return {"columns": ["Month", "Demand (MWh)", "Status"], "rows": [list(row) for row in data]}


def demand_figure():
    fig = go.Figure()
    fig.update_layout(
        template="simple_white",
        font={"family": "Inter, system-ui, -apple-system, sans-serif", "color": "#1f2937"},
        title="Monthly electricity demand",
        yaxis={"title": "Demand (MWh)", "range": [38, 66]},
        xaxis_tickangle=0,
        margin={"l": 76, "r": 36, "t": 56, "b": 52},
        showlegend=False,
    )
    return fig


def make_before(data) -> go.Figure:
    months, demand, _ = zip(*data, strict=True)
    fig = demand_figure()
    fig.add_scatter(x=months, y=demand, mode="lines+markers", line_color="#356890")
    return fig


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