import plotly.graph_objects as go


def load_data():
    return [
        (12, -1800),
        (15, -900),
        (18, 0),
        (21, 900),
        (24, 1800),
    ]


def value_table(data):
    return {
        "columns": ["Electricity price (cents per kWh)", "Annual net savings (dollars)"],
        "rows": [list(row) for row in data],
    }


def make_after(data) -> go.Figure:
    prices, savings = zip(*data, strict=True)
    fig = go.Figure(
        go.Scatter(
            x=prices,
            y=savings,
            mode="lines+markers",
            line_color="#356890",
            hovertemplate="%{x} cents per kWh: $%{y:,}<extra></extra>",
        )
    )
    fig.update_layout(
        template="simple_white",
        font={"family": "Inter, system-ui, -apple-system, sans-serif", "color": "#1f2937"},
        title="Heat pump savings depend on the electricity price",
        xaxis={"title": "Electricity price (cents per kWh)", "tickvals": prices},
        yaxis={
            "title": "Annual net savings (dollars)",
            "range": [-2100, 2100],
            "zeroline": True,
            "zerolinecolor": "#9ca3af",
            "tickformat": ",d",
        },
        margin={"l": 88, "r": 24, "t": 56, "b": 60},
    )
    return fig


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