Animated Graph bugs after a while

Hey all,
I’m just learning how to use Dash. I was working with an animated graph, with a code like this:

html.Div([
        dcc.Graph(id='live-graph', animate=True),
        dcc.Interval(
            id='graph-update',
            interval=1.5*1000
        ),
    ]),

@app.callback(Output('live-graph', 'figure'),
              [Input('graph-update', 'n_intervals')])
def update_graph_scatter(n):
    X.append(X[-1]+1)
    Y.append(Y[-1]+Y[-1]*0.1)
    if n is None:
        n=X[-1]
    data = go.Scatter(
            x=list(X),
            y=list(Y),
            name='Scatter',
            mode='lines+markers',

            )
    fig = ({'data':[data],
            'layout': go.Layout(xaxis=dict(range=[min(X),max(X)]),
                                yaxis=dict(range=[min(Y),max(Y)]),
                                title='Serie de tiempo de algo')
            })

    return fig

When I run it, it works perfectly, but after a while it starts to sttuter. My guess it’s trying to plot simultaneously more than one plot (in a second the Y-axis scale goes from thousands, to millions, to thousands, to millions).

What could be the issue?
Thanks

Edit: I tested a little bit and it seems the issue has to do with changing tabs, and the adaptive Y and X axis. If I exit the tab and enter it after a few seconds, the plot will try to rapidly catch up with the updates and that seems to bug it

Moved to the “Dash” forum category,
-Jon