|
componentWillMount() {
this.tick();
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),
100
);
}
componentWillUnmount() {
clearInterval(this.timerID);
}
tick() {
if (this.value < 25) {
this.value += Math.random() * 2.0;
} else {
this.value -= 2.0;
}
this.series1.push({ x: this.i, y: this.value });
this.i++;
this.series1.shift();
this.setState({ title: 'akdsjajf'+ this.i, series1: this.series1 });
if (this.chart) {
this.chart.refresh();
}
} |