tailwind #9
@ -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,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user