Client - workaround to display data on chart + minor fixes
This commit is contained in:
parent
2c61b7605a
commit
7dc45cb254
@ -48,7 +48,8 @@
|
|||||||
}
|
}
|
||||||
let chartData: ComputedRef<ChartData<'bar'>> = computed(() => ({
|
let chartData: ComputedRef<ChartData<'bar'>> = computed(() => ({
|
||||||
labels: props.labels,
|
labels: props.labels,
|
||||||
datasets: props.datasets,
|
// workaround to avoid dataset modification
|
||||||
|
datasets: JSON.parse(JSON.stringify(props.datasets)),
|
||||||
}))
|
}))
|
||||||
const options = computed<ChartOptions<'bar'>>(() => ({
|
const options = computed<ChartOptions<'bar'>>(() => ({
|
||||||
responsive: true,
|
responsive: true,
|
||||||
|
@ -18,7 +18,9 @@ export interface IStatisticsDateParams {
|
|||||||
|
|
||||||
export type TDatasetKeys = 'nb_workouts' | 'total_duration' | 'total_distance'
|
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 = {
|
export type TSportStatistics = {
|
||||||
[key in number]: TStatistics
|
[key in number]: TStatistics
|
||||||
@ -34,10 +36,9 @@ export interface IStatisticsChartDataset {
|
|||||||
data: number[]
|
data: number[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TStatisticsDatasets = Record<
|
export type TStatisticsDatasets = {
|
||||||
TDatasetKeys,
|
[key in TDatasetKeys]: IStatisticsChartDataset[]
|
||||||
IStatisticsChartDataset[]
|
}
|
||||||
>
|
|
||||||
|
|
||||||
export interface IStatisticsChartData {
|
export interface IStatisticsChartData {
|
||||||
labels: unknown[]
|
labels: unknown[]
|
||||||
|
@ -44,15 +44,13 @@ export const getDateKeys = (
|
|||||||
const getStatisticsChartDataset = (
|
const getStatisticsChartDataset = (
|
||||||
sportLabel: string,
|
sportLabel: string,
|
||||||
color: string
|
color: string
|
||||||
): IStatisticsChartDataset =>
|
): IStatisticsChartDataset => {
|
||||||
Object.assign(
|
return {
|
||||||
{},
|
label: sportLabel,
|
||||||
{
|
backgroundColor: [color],
|
||||||
label: sportLabel,
|
data: [],
|
||||||
backgroundColor: [color],
|
}
|
||||||
data: [],
|
}
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const getDatasets = (displayedSports: ISport[]): TStatisticsDatasets => {
|
export const getDatasets = (displayedSports: ISport[]): TStatisticsDatasets => {
|
||||||
const datasets: TStatisticsDatasets = {
|
const datasets: TStatisticsDatasets = {
|
||||||
|
Loading…
Reference in New Issue
Block a user