Animated table doesn't changing

I trying to create animated table which changed with slider. Value at first column must changing from 0 to 100, in second form 100 to 0. I write a flowing code for this purpose:

import plotly.graph_objects as go

fig = go.Figure()

# adding a trace
fig.add_trace(
    go.Table(
        header = dict(
            values = ["col 1","col 2"]
        ),
        cells = dict(
            values = [["0"], ["100"]],
        )
    )
)


# making a animation
frames = []
steps = []

for i in range(101):
    frame = go.Frame(
        data = [
            go.Table(
                header = dict(
                    values = ["col 1","col 2"]
                ),
                cells = dict(
                    values = [[str(i)], [str(100 - i)]],
                )
            )
        ],
        name = str(i)
    )
    
    step = dict(
        method="animate",
        args=[
            [str(i)],
            {
                "frame": {
                    "duration": 1, 
                    "redraw": False
                },
                 "mode": "immediate"
            }
        ],
        label = str(i)
    )
    
    frames.append(frame)
    steps.append(step)


fig.frames = frames

sliders = [dict(
    steps=steps,
    currentvalue = 
    {
        "visible": True
    }
)]

fig.update_layout(
    sliders = sliders,
)

It displays an initial table, but It doesn’t changed with slider moving.

What is my mistake?

redraw needs to be set to True rather than False.

1 Like