Black Lives Matter. Please consider donating to Black Girls Code today.

Trimming traces

I am doing long-lived streaming plots. I’m successfully adding new data points using Plotly.extendTraces().

But, how do I trim old points off the front of the traces?

1 Like

You can set the forth argument of Plotly.extendTraces for this purpose,

For example,

var maxNumberOfPointToKeep = 10;

Plotly.extendTraces('graph', {
  x: [[1]],
  y: [[2]],
}, [0], maxNumberOfPointToKeep);

keeps a maximum of 10 points on the graph.

Thanks. That’s what I needed to know.

Is this documented anywhere? If so, I never found it.