show only last 500 entries
This commit is contained in:
parent
02678fd8e6
commit
119d80a936
@ -34,9 +34,16 @@ class RPlot extends Component<{}, PlotState> {
|
|||||||
})
|
})
|
||||||
|
|
||||||
socket.on("new_tick", (data: NewTickData) => {
|
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({
|
this.setState({
|
||||||
x: [...this.state.x, data.tick],
|
x: x,
|
||||||
y: [...this.state.y, data.price],
|
y: y,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user