diff --git a/mpwo_api/mpwo_api/activities/utils.py b/mpwo_api/mpwo_api/activities/utils.py index c506420c..d465f959 100644 --- a/mpwo_api/mpwo_api/activities/utils.py +++ b/mpwo_api/mpwo_api/activities/utils.py @@ -202,7 +202,9 @@ def get_chart_data(gpx_file): ) distance = 0 if distance is None else distance distance += previous_distance - speed = round((segment.get_speed(point_idx) / 1000)*3600, 2) + speed = (round((segment.get_speed(point_idx) / 1000)*3600, 2) + if segment.get_speed(point_idx) is not None + else 0) chart_data.append({ 'distance': round(distance / 1000, 2), 'duration': point.time_difference(first_point), diff --git a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx index 3067918c..c8647430 100644 --- a/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx +++ b/mpwo_client/src/components/Activities/ActivityDisplay/ActivityCharts.jsx @@ -43,6 +43,7 @@ class ActivityCharts extends React.Component { render() { const { chartData } = this.props const { displayDistance } = this.state + const xInterval = chartData ? parseInt(chartData.length / 10, 10) : 0 let xDataKey, xScale if (displayDistance) { xDataKey = 'distance' @@ -73,55 +74,66 @@ class ActivityCharts extends React.Component { duration -
- - - displayDistance - ? value - : format(value, 'HH:mm:ss')} - type="number" - /> - - - - - displayDistance - ? `distance: ${value} km` - : `duration: ${format(value, 'HH:mm:ss')}`} - /> - - -
-
data from gpx, without any cleaning
+ {chartData && chartData.length > 0 ? ( +
+
+ + + displayDistance + ? value + : format(value, 'HH:mm:ss')} + type="number" + /> + + + + + displayDistance + ? `distance: ${value} km` + : `duration: ${format(value, 'HH:mm:ss')}`} + /> + + +
+
data from gpx, without any cleaning
+
+ ) : ( + 'No data to display' + )} ) }