import plotly.graph_objects as go


def load_data():
    """Return individual fulfillment times in minutes."""
    return [11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40]


def value_table(data):
    return {
        "columns": ["Order", "Fulfillment time (minutes)"],
        "rows": [[index, minutes] for index, minutes in enumerate(data, start=1)],
    }


def _style_fulfillment_figure(fig, subtitle):
    fig.update_layout(
        template="simple_white",
        font={"family": "Inter, system-ui, -apple-system, sans-serif", "color": "#1f2937"},
        title={"text": "Order fulfillment times", "subtitle": {"text": subtitle}},
        xaxis={"title": "Fulfillment time (minutes)", "range": [8, 43], "dtick": 5},
        margin={"l": 35, "r": 24, "t": 74, "b": 62},
    )
    return fig


def make_before(data) -> go.Figure:
    fig = go.Figure(
        go.Box(
            x=data,
            boxpoints=False,
            orientation="h",
            marker_color="#22628a",
            name="Orders",
        )
    )
    fig.update_yaxes(showticklabels=False, showline=False, ticks="")
    return _style_fulfillment_figure(fig, "Median and quartiles")


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