diff --git a/websrc/components/RPlot.tsx b/websrc/components/RPlot.tsx index 9a01270..83e9af8 100644 --- a/websrc/components/RPlot.tsx +++ b/websrc/components/RPlot.tsx @@ -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, }) }) }