Client - [PR84/93] display elevation on statistics

This commit is contained in:
Sam
2021-11-03 20:39:14 +01:00
parent c25f30fb2f
commit 07fb64c8f5
6 changed files with 259 additions and 19 deletions

View File

@ -45,6 +45,8 @@ export const datasetKeys: TStatisticsDatasetKeys[] = [
'nb_workouts',
'total_duration',
'total_distance',
'total_ascent',
'total_descent',
]
export const getDateKeys = (
@ -78,12 +80,16 @@ export const getDatasets = (displayedSports: ISport[]): TStatisticsDatasets => {
nb_workouts: [],
total_distance: [],
total_duration: [],
total_ascent: [],
total_descent: [],
}
displayedSports.map((sport) => {
const color = sportColors[sport.label]
datasets.nb_workouts.push(getStatisticsChartDataset(sport.label, color))
datasets.total_distance.push(getStatisticsChartDataset(sport.label, color))
datasets.total_duration.push(getStatisticsChartDataset(sport.label, color))
datasets.total_ascent.push(getStatisticsChartDataset(sport.label, color))
datasets.total_descent.push(getStatisticsChartDataset(sport.label, color))
})
return datasets
}

View File

@ -6,9 +6,15 @@ export const formatTooltipValue = (
value: number,
formatWithUnits = true
): string => {
return displayedData === 'total_duration'
? formatDuration(value, formatWithUnits)
: displayedData === 'total_distance'
? value.toFixed(2) + ' km'
: value.toString()
switch (displayedData) {
case 'total_duration':
return formatDuration(value, formatWithUnits)
case 'total_distance':
return value.toFixed(2) + ' km'
case 'total_ascent':
case 'total_descent':
return (value / 1000).toFixed(2) + ' km'
default:
return value.toString()
}
}