import plotly.graph_objects as go


def load_data():
    return [
        ("Reported estimate", 3.8, 5.8),
        ("Conference Board", 4.2, 5.5),
        ("Data Resources", 4.5, 5.2),
        ("Wharton", 4.5, 4.8),
        ("Chase Econometrics", 2.8, 1.9),
    ]


def value_table(data):
    return {
        "columns": ["Forecaster", "Real GNP growth (%)", "Industrial production growth (%)"],
        "rows": [list(row) for row in data],
    }


def make_before(data) -> go.Figure:
    fig = go.Figure(
        go.Table(
            header={"values": ["Forecaster", "Real GNP (%)", "Industrial production (%)"]},
            cells={
                "values": list(zip(*data, strict=True)),
                "align": ["left", "right", "right"],
                "format": ["", ".1f", ".1f"],
            },
            columnwidth=[2, 1, 1],
        )
    )
    fig.update_layout(template="simple_white", height=260, margin={"l": 0, "r": 0, "t": 16, "b": 8})
    return fig


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