1
0
Fork 0

Use consistent function definition order

This commit is contained in:
Gregory Eremin 2015-03-12 03:21:28 +07:00
parent 790156f28d
commit e29c2ed1b7
2 changed files with 13 additions and 13 deletions

View File

@ -20,12 +20,6 @@ var BarChart = React.createClass({
}; };
}, },
calculateViewBoxWidth: function() {
this.setState({
canvasWidth: this.refs.svg.getDOMNode().offsetWidth
});
},
componentDidMount: function() { componentDidMount: function() {
this.calculateViewBoxWidth(); this.calculateViewBoxWidth();
window.addEventListener('resize', this.calculateViewBoxWidth); window.addEventListener('resize', this.calculateViewBoxWidth);
@ -38,6 +32,12 @@ var BarChart = React.createClass({
}, this.fetchData); }, this.fetchData);
}, },
calculateViewBoxWidth: function() {
this.setState({
canvasWidth: this.refs.svg.getDOMNode().offsetWidth
});
},
handleFilter: function(thing, i) { handleFilter: function(thing, i) {
if (thing === 'item' && this.props.items[i] !== this.state.item) { if (thing === 'item' && this.props.items[i] !== this.state.item) {
this.setState({ this.setState({
@ -198,7 +198,7 @@ var Bar = React.createClass({
anim.setAttributeNS(null, 'attributeName', 'width'); anim.setAttributeNS(null, 'attributeName', 'width');
anim.setAttributeNS(null, 'from', this.state.lastw); anim.setAttributeNS(null, 'from', this.state.lastw);
anim.setAttributeNS(null, 'to', this.props.width); anim.setAttributeNS(null, 'to', this.props.width);
anim.setAttributeNS(null, 'dur', '300ms'); anim.setAttributeNS(null, 'dur', '250ms');
anim.setAttributeNS(null, 'repeatCount', '1'); anim.setAttributeNS(null, 'repeatCount', '1');
bar.appendChild(anim); bar.appendChild(anim);
anim.beginElement(); anim.beginElement();

View File

@ -15,6 +15,12 @@ var StackedAreaChart = React.createClass({
}; };
}, },
componentDidMount: function() {
this.fetchData();
this.calculateViewBoxWidth();
window.addEventListener('resize', this.calculateViewBoxWidth);
},
componentWillReceiveProps: function(newProps) { componentWillReceiveProps: function(newProps) {
this.setState({ this.setState({
'item': newProps.items[0], 'item': newProps.items[0],
@ -28,12 +34,6 @@ var StackedAreaChart = React.createClass({
}); });
}, },
componentDidMount: function() {
this.fetchData();
this.calculateViewBoxWidth();
window.addEventListener('resize', this.calculateViewBoxWidth);
},
handleFilter: function(thing, i) { handleFilter: function(thing, i) {
if (this.props.items[i] !== this.state.item) { if (this.props.items[i] !== this.state.item) {
this.setState({ this.setState({