Client - workaround to display data on chart + minor fixes

This commit is contained in:
Sam 2021-09-21 14:49:49 +02:00
parent 2c61b7605a
commit 7dc45cb254
3 changed files with 15 additions and 15 deletions

View File

@ -48,7 +48,8 @@
}
let chartData: ComputedRef<ChartData<'bar'>> = computed(() => ({
labels: props.labels,
datasets: props.datasets,
// workaround to avoid dataset modification
datasets: JSON.parse(JSON.stringify(props.datasets)),
}))
const options = computed<ChartOptions<'bar'>>(() => ({
responsive: true,

View File

@ -18,7 +18,9 @@ export interface IStatisticsDateParams {
export type TDatasetKeys = 'nb_workouts' | 'total_duration' | 'total_distance'
export type TStatistics = Record<TDatasetKeys, number>
export type TStatistics = {
[key in TDatasetKeys]: number
}
export type TSportStatistics = {
[key in number]: TStatistics
@ -34,10 +36,9 @@ export interface IStatisticsChartDataset {
data: number[]
}
export type TStatisticsDatasets = Record<
TDatasetKeys,
IStatisticsChartDataset[]
>
export type TStatisticsDatasets = {
[key in TDatasetKeys]: IStatisticsChartDataset[]
}
export interface IStatisticsChartData {
labels: unknown[]

View File

@ -44,15 +44,13 @@ export const getDateKeys = (
const getStatisticsChartDataset = (
sportLabel: string,
color: string
): IStatisticsChartDataset =>
Object.assign(
{},
{
label: sportLabel,
backgroundColor: [color],
data: [],
}
)
): IStatisticsChartDataset => {
return {
label: sportLabel,
backgroundColor: [color],
data: [],
}
}
export const getDatasets = (displayedSports: ISport[]): TStatisticsDatasets => {
const datasets: TStatisticsDatasets = {