Keep chart item when switching dates
This commit is contained in:
parent
2495b3e539
commit
58a9713bf2
|
@ -25,7 +25,9 @@ var BarChart = React.createClass({
|
||||||
|
|
||||||
componentWillReceiveProps: function(newProps) {
|
componentWillReceiveProps: function(newProps) {
|
||||||
this.setState({
|
this.setState({
|
||||||
item: newProps.items[0],
|
item: (_.isEqual(newProps.items, this.props.items)
|
||||||
|
? this.state.item
|
||||||
|
: newProps.items[0]),
|
||||||
state: 'newProps'
|
state: 'newProps'
|
||||||
}, this.fetchData);
|
}, this.fetchData);
|
||||||
},
|
},
|
||||||
|
|
|
@ -38,7 +38,9 @@ var StackedAreaChart = React.createClass({
|
||||||
|
|
||||||
componentWillReceiveProps: function(newProps) {
|
componentWillReceiveProps: function(newProps) {
|
||||||
this.setState({
|
this.setState({
|
||||||
item: newProps.items[0],
|
item: (_.isEqual(newProps.items, this.props.items)
|
||||||
|
? this.state.item
|
||||||
|
: newProps.items[0]),
|
||||||
state: 'newProps'
|
state: 'newProps'
|
||||||
}, this.fetchData);
|
}, this.fetchData);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue