import plotly.graph_objects as go


def load_data():
    """Return illustrative daily counts of completed inspections."""
    return [
        ("Mon", 18),
        ("Tue", 24),
        ("Wed", 21),
        ("Thu", 29),
        ("Fri", 26),
    ]


def value_table(data):
    """Return the daily inspection counts in display order."""
    return {
        "columns": ["Day", "Inspections completed"],
        "rows": [list(row) for row in data],
    }


def _inspection_chart(data, *, background, foreground, marks) -> go.Figure:
    days, counts = zip(*data, strict=True)
    fig = go.Figure(go.Bar(x=days, y=counts, marker_color=marks))
    fig.update_layout(
        template="simple_white",
        plot_bgcolor=background,
        paper_bgcolor=background,
        font={"family": "Inter, system-ui, -apple-system, sans-serif", "color": foreground},
        title={"text": "Inspections completed by day", "x": 0, "xanchor": "left"},
        xaxis={"tickfont": {"color": foreground}, "tickcolor": foreground, "linecolor": foreground},
        yaxis={
            "title": "Inspections completed",
            "range": [0, 32],
            "tickfont": {"color": foreground},
            "tickcolor": foreground,
            "linecolor": foreground,
        },
        margin={"l": 76, "r": 24, "t": 56, "b": 48},
    )
    return fig


def make_after(data) -> go.Figure:
    """Show the same counts with dark text and blue bars on white."""
    return _inspection_chart(data, background="#ffffff", foreground="#1f2937", marks="#245785")


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