Plotly 如何使用破折号按钮运行go.Scatter的动画图形?

Plotly 如何使用破折号按钮运行go.Scatter的动画图形?,plotly,plotly-dash,plotly-python,Plotly,Plotly Dash,Plotly Python,我想要一个使用dbc.button的按钮,当它被点击时,它应该会启动动画的赛线图。我试过这个,但不起作用。任何线索都会有帮助 x_axis = list(range(df.shape[0])) y_axis = list(df['4. close']) frames = [] for frame in range(1, len(x_axis)+1): x_frame = np.arange(frame) y_frame = list(df.iloc[:frame-1, 4])

我想要一个使用dbc.button的按钮,当它被点击时,它应该会启动动画的赛线图。我试过这个,但不起作用。任何线索都会有帮助

x_axis = list(range(df.shape[0]))
y_axis = list(df['4. close'])
frames = []
for frame in range(1, len(x_axis)+1):
    x_frame = np.arange(frame)
    y_frame = list(df.iloc[:frame-1, 4])
    curr_frame = go.Frame(data = [go.Scatter(x = x_frame, y = y_frame, mode = 'lines')])
    frames.append(curr_frame)
dash_app.layout = html.Div(
        children=[
            html.H1(children="Stock Simulation"),
            html.P(10000, id="acnt_bal", style={"text-align":"center"}),
            dcc.Graph(id="example-graph", animate=True,  style={'display':"None"}),

            dbc.Button('Start', id='example-button2', color='primary',
                       style={'margin-bottom': '1em', 'margin-left': '46%'}),

            html.P(id='para')

        ]
    )
@dash_app.callback(
        [Output('example-graph', 'style'),
        Output('example-graph', 'figure')],
        Input('example-button2', 'n_clicks')
    )
    def start_graph(n_clicks):
        data = go.Scatter(x = np.array([1]), y = np.array([60.10]), mode='lines')
        return {"display":'block'},dict(data = [data], layout = go.Layout(xaxis=dict(range=[0, df.shape[0]]),
                                                                      yaxis=dict(range=[0, max(y_axis)])),
                                    frames = frames,
                                    frame = {'duration': 20, 'redraw':False},
                                    transition = {'duration':0}),