data insertion v2 electric boogaloo

This commit is contained in:
slice 2018-07-16 18:15:51 -07:00
parent 7cd549c46b
commit 637a06e985
No known key found for this signature in database
GPG Key ID: 1508C19D7436A26D
1 changed files with 6 additions and 2 deletions

View File

@ -72,11 +72,15 @@ export default class App extends Component {
handleLatency (name, data) {
const { metrics } = this.state
const graph = metrics.graph[name].slice(1)
const newGraph = [data, ...graph]
log('adding latency entry:', data)
// latency entries come in newest to oldest, so remove the oldest entry
const graph = metrics.graph[name].slice(0, metrics.graph[name].length - 1)
// make new data come in first
const newGraph = [data, ...graph]
this.setState(({ metrics: old }, _props) => {
const metrics = { ...old }
metrics.graph[name] = newGraph