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

View File

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