Real time plotting of EKG sensor data not working in small interval < 600ms

hello everyone, i hope you’re safe and healthy.
I’m working on my graduation project and in the last minute the professor required me to do real time plotting of ECG sensor data which is captured at 200Hz frequency (every 5ms) and after some research I found Dash which seemed to be a great tool that’s gonna save me a lot of time that I really don’t have…
the problem I’m having is that whenever I use the update interval to a value <600ms the whole screen starts flickering and redrawing the whole plot instead of updating (adding more values to) the plot.
It seems to work just fine with an update interval that’s >=600ms.

here’s the code I’m working with:

sig = []
with open("test_data7_ms.csv", "r") as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
    for lines in csv_reader:
        sig.append((lines[0]))


# sig is an array created from a file that contains the sensor readings
# just to simulate the work of the sensor without the hassle with cables and everything
sig_iter = iter(sig)
x = deque(maxlen=5)
x.append(1)
Y = deque(maxlen=5)
Y.append(next(sig_iter, 400))
app = dash.Dash()


app.layout = html.Div(
    [
        dcc.Graph(id='ecg-graph',
                  animate=True),
        dcc.Interval(
            id='ecg-graph-update',
            interval=500,
            n_intervals=0
        ),
    ]
)

@app.callback(Output('ecg-graph', 'figure'),
    [Input('ecg-graph-update', 'n_intervals')])
def update_ecg(n):
    x.append(x[-1]+1)
    Y.append(next(sig_iter, 400))

    trace = go.Scatter(
        x=list(x),
        y=list(Y),
        name='Scatter',
        mode='lines'
    )
    return {'data': [trace], 'layout': go.Layout(xaxis=dict(range=[min(x), max(x)]),
                                                 yaxis=dict(range=[100, 900]),)}

if __name__ == "__main__":
    app.run_server(debug=True)

If anyone knows how to solve this problem or have any suggestions concerning Dash or other framwork/library I’d really appreciate the help.