diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx index 561bd62e..3707509b 100644 --- a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx +++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx @@ -9,6 +9,13 @@ import { getActivityChartData } from '../../../actions/activities' class ActivityCharts extends React.Component { + constructor(props, context) { + super(props, context) + this.state = { + displayDistance: true, + } + } + componentDidMount() { this.props.loadActivityData(this.props.activity.id) } @@ -24,49 +31,94 @@ class ActivityCharts extends React.Component { this.props.loadActivityData(null) } + handleRadioChange (changeEvent) { + this.setState({ + displayDistance: + changeEvent.target.name === 'distance' + ? changeEvent.target.value + : !changeEvent.target.value + }) + } + render() { const { chartData } = this.props + const { displayDistance } = this.state + let xDataKey, xScale + if (displayDistance) { + xDataKey = 'distance' + xScale = 'linear' + } else { + xDataKey = 'duration' + xScale = 'time' + } return ( -