import plotly.graph_objects as go


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


def load_data():
    return [
        (0, 50),
        (1, 100),
        (2, 200),
        (3, 400),
        (4, 800),
        (5, 1600),
        (6, 3200),
    ]


def value_table(data):
    return {
        "columns": ["Day", "Active cultures"],
        "rows": [list(row) for row in data],
    }


def _culture_growth(data):
    days, counts = zip(*data, strict=True)
    fig = go.Figure(
        go.Scatter(
            x=days,
            y=counts,
            mode="lines+markers",
            line={"color": "#24688c"},
            hovertemplate="Day %{x}: %{y:,} active cultures<extra></extra>",
        )
    )
    fig.update_layout(
        template="simple_white",
        font=FONT,
        title="Active cultures by day",
        xaxis={"title": "Day", "dtick": 1},
        yaxis_title="Active cultures",
        margin={"l": 96, "r": 24, "t": 60, "b": 60},
    )
    return fig


def make_before(data) -> go.Figure:
    fig = _culture_growth(data)
    fig.update_yaxes(rangemode="tozero")
    return fig


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