import plotly.graph_objects as go


def load_data():
    return [
        ("Jan", 18),
        ("Feb", 16),
        ("Mar", 17),
        ("Apr", 14),
        ("May", 13),
        ("Jun", 12),
    ]


def value_table(data):
    return {
        "columns": ["Month", "Median wait (minutes)"],
        "rows": [list(row) for row in data],
    }


def _appointment_wait_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": "Clinic appointment wait", "x": 0.08},
        xaxis={"title": "Month", "tickmode": "array", "tickvals": list(periods), "tickangle": 0},
        yaxis_title="Median wait (minutes)",
        margin={"l": 68, "r": 28, "t": 80, "b": 65},
    )
    return fig


def make_after(data) -> go.Figure:
    return _appointment_wait_chart(data)


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