show only last 500 entries

This commit is contained in:
Giulio De Pasquale 2020-12-14 13:14:32 +00:00
parent 02678fd8e6
commit 119d80a936

View File

@ -34,9 +34,16 @@ class RPlot extends Component<{}, PlotState> {
})
socket.on("new_tick", (data: NewTickData) => {
var new_x = [...this.state.x, data.tick]
var new_y = [...this.state.y, data.price]
// cutting to up to 500 entries (last 500)
var x = new_x.slice(Math.max(new_x.length - 500, 0))
var y = new_y.slice(Math.max(new_y.length - 500, 0))
this.setState({
x: [...this.state.x, data.tick],
y: [...this.state.y, data.price],
x: x,
y: y,
})
})
}