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_before(data) -> go.Figure:
    """Show inspection counts with dark marks and text on a dark background."""
    return _inspection_chart(data, background="#1f2937", foreground="#374151", marks="#334155")


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