import plotly.graph_objects as go


def load_data():
    return [(1970, -11014), (1971, 397747), (1972, 521943), (1973, 1647001), (1974, 1435102)]


def value_table(data):
    return {"columns": ["Year", "Net income (nominal USD)"], "rows": [list(row) for row in data]}


def make_before(data) -> go.Figure:
    years, values = zip(*data, strict=True)
    fig = go.Figure(go.Bar(x=years, y=values))
    fig.update_layout(
        template="simple_white",
        xaxis_title="Year",
        xaxis_tickvals=list(years),
        yaxis_title="Net income (USD)",
        yaxis_range=[200000, 1800000],
        yaxis_tickformat=",.0f",
    )
    return fig


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