Client - init workout chart (WIP)
This commit is contained in:
@ -5,7 +5,7 @@ import { ISport } from '@/types/sports'
|
||||
import {
|
||||
IStatisticsChartData,
|
||||
IStatisticsDateParams,
|
||||
TDatasetKeys,
|
||||
TStatisticsDatasetKeys,
|
||||
TStatisticsDatasets,
|
||||
TStatisticsFromApi,
|
||||
} from '@/types/statistics'
|
||||
@ -19,7 +19,7 @@ const dateFormats: Record<string, string> = {
|
||||
year: 'yyyy',
|
||||
}
|
||||
|
||||
export const datasetKeys: TDatasetKeys[] = [
|
||||
export const datasetKeys: TStatisticsDatasetKeys[] = [
|
||||
'nb_workouts',
|
||||
'total_duration',
|
||||
'total_distance',
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { TDatasetKeys } from '@/types/statistics'
|
||||
import { TStatisticsDatasetKeys } from '@/types/statistics'
|
||||
import { formatDuration } from '@/utils/duration'
|
||||
|
||||
export const formatTooltipValue = (
|
||||
displayedData: TDatasetKeys,
|
||||
displayedData: TStatisticsDatasetKeys,
|
||||
value: number,
|
||||
formatWithUnits = true
|
||||
): string => {
|
||||
|
41
fittrackee_client/src/utils/workouts.ts
Normal file
41
fittrackee_client/src/utils/workouts.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import {
|
||||
IWorkoutApiChartData,
|
||||
IWorkoutChartData,
|
||||
TWorkoutDatasets,
|
||||
} from '@/types/workouts'
|
||||
|
||||
export const getDatasets = (
|
||||
chartData: IWorkoutApiChartData[],
|
||||
t: CallableFunction
|
||||
): IWorkoutChartData => {
|
||||
const datasets: TWorkoutDatasets = {
|
||||
speed: {
|
||||
label: t('workouts.SPEED'),
|
||||
backgroundColor: ['#FFFFFF'],
|
||||
borderColor: ['#8884d8'],
|
||||
borderWidth: 2,
|
||||
data: [],
|
||||
yAxisID: 'ySpeed',
|
||||
},
|
||||
elevation: {
|
||||
label: t('workouts.ELEVATION'),
|
||||
backgroundColor: ['#e5e5e5'],
|
||||
borderColor: ['#cccccc'],
|
||||
borderWidth: 1,
|
||||
fill: true,
|
||||
data: [],
|
||||
yAxisID: 'yElevation',
|
||||
},
|
||||
}
|
||||
const distance_labels: unknown[] = []
|
||||
const duration_labels: unknown[] = []
|
||||
|
||||
chartData.map((data) => {
|
||||
distance_labels.push(data.distance)
|
||||
duration_labels.push(data.duration)
|
||||
datasets.speed.data.push(data.speed)
|
||||
datasets.elevation.data.push(data.elevation)
|
||||
})
|
||||
|
||||
return { distance_labels, duration_labels, datasets }
|
||||
}
|
Reference in New Issue
Block a user