-
Notifications
You must be signed in to change notification settings - Fork 11
/
RadarVivus.js
34 lines (32 loc) · 1 KB
/
RadarVivus.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';
import ReactDOM from 'react-dom';
import Vivus from 'vivus';
import RadarChart from './Radar.js';
export default class RadarVivusChart extends RadarChart {
constructor(props){
super(props);
this.state = { finished: false };
}
componentWillReceiveProps(nextProps){
if (nextProps.replay !== this.props.replay) this.setState({finished:false});
}
componentDidMount() {
this.run();
}
componentDidUpdate(prevProps,prevState){
if (!this.state.finished) this.run()
}
run(){
if (this.refs.vivus === undefined) return;
var animate = this.props.options && this.props.options.animate || {};
new Vivus(ReactDOM.findDOMNode(this.refs.vivus), {
type: animate.type || 'delayed',
duration: animate.duration || 'delayed',
start: 'autostart',
selfDestroy: true
}, this.finish.bind(this));
}
finish() {
this.setState({ finished: true });
}
}