Keep chart item when switching dates
This commit is contained in:
@@ -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);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user