Swapped ascent/descent from km/mi to m/ft

This commit is contained in:
Fmstrat 2022-07-18 14:24:41 -04:00
parent 721937e425
commit 8c5e3cf2e4
2 changed files with 8 additions and 5 deletions

View File

@ -137,13 +137,17 @@
const total: number = context.chart.data.datasets
.map((d) => d.data[context.dataIndex])
.reduce((total, value) => getSum(total, value), 0)
let unitFrom = 'km'
if (props.displayedData === 'total_ascent' || props.displayedData === 'total_descent')
unitFrom = 'm'
return context.datasetIndex ===
props.displayedSportIds.length - 1 && total > 0
? formatTooltipValue(
props.displayedData,
total,
props.useImperialUnits,
false
false,
unitFrom
)
: null
}

View File

@ -6,9 +6,9 @@ export const formatTooltipValue = (
displayedData: TStatisticsDatasetKeys,
value: number,
useImperialUnits: boolean,
formatWithUnits = true
formatWithUnits = true,
unitFrom = 'km'
): string => {
const unitFrom = 'km'
const unitTo = useImperialUnits ? units[unitFrom].defaultTarget : unitFrom
switch (displayedData) {
case 'average_speed':
@ -16,10 +16,9 @@ export const formatTooltipValue = (
case 'total_duration':
return formatDuration(value, formatWithUnits)
case 'total_distance':
return `${value.toFixed(2)} ${unitTo}`
case 'total_ascent':
case 'total_descent':
return `${(value / 1000).toFixed(2)} ${unitTo}`
return `${value.toFixed(2)} ${unitTo}`
default:
return value.toString()
}