diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx index 6e8f14a9..3bb958e1 100644 --- a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx +++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx @@ -13,6 +13,7 @@ class ActivityCharts extends React.Component { super(props, context) this.state = { displayDistance: true, + dataToHide: [] } } @@ -40,6 +41,22 @@ class ActivityCharts extends React.Component { }) } + handleLegendChange (e) { + const { dataToHide } = this.state + const name = e.target.name // eslint-disable-line prefer-destructuring + if (dataToHide.find(d => d === name)) { + dataToHide.splice(dataToHide.indexOf(name), 1) + } else { + dataToHide.push(name) + } + this.setState({ dataToHide }) + } + + displayData (name) { + const { dataToHide } = this.state + return !dataToHide.find(d => d === name) + } + render() { const { chartData } = this.props const { displayDistance } = this.state @@ -54,28 +71,50 @@ class ActivityCharts extends React.Component { } return (