import plotly.graph_objects as go


FONT = {"family": "Inter, system-ui, -apple-system, sans-serif", "color": "#1f2937"}


def load_data():
    return [
        ("2026-01-01", 8),
        ("2026-02-01", 10),
        ("2026-03-15", 9),
        ("2026-04-15", 12),
        ("2026-06-01", 10),
    ]


def value_table(data):
    return {
        "columns": ["Effective date", "Admission fee (USD)"],
        "rows": [list(row) for row in data],
    }


def _admission_history(data, line_shape):
    dates, fees = zip(*data, strict=True)
    fig = go.Figure(
        go.Scatter(
            x=[*dates, "2026-06-30"],
            y=[*fees, fees[-1]],
            mode="lines",
            line={"shape": line_shape, "color": "#24688c", "width": 3},
            hovertemplate="%{x|%b %d}: $%{y}<extra></extra>",
        )
    )
    fig.add_scatter(
        x=dates,
        y=fees,
        mode="markers",
        marker={"color": "#24688c", "size": 8},
        hovertemplate="Effective %{x|%b %d}: $%{y}<extra></extra>",
    )
    fig.update_layout(
        template="simple_white",
        font=FONT,
        showlegend=False,
        title="Museum admission fee, January to June 2026",
        xaxis={
            "type": "date",
            "tickformat": "%b",
            "dtick": "M1",
            "range": ["2025-12-27", "2026-07-04"],
        },
        yaxis={"title": "Admission fee (USD)", "tickprefix": "$", "range": [7, 13], "dtick": 1},
        margin={"l": 78, "r": 25, "t": 58, "b": 50},
    )
    return fig


def make_before(data) -> go.Figure:
    return _admission_history(data, "linear")


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