Client - use user sports colors in charts
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
v-for="sport in translatedSports"
|
||||
type="checkbox"
|
||||
:key="sport.id"
|
||||
:style="{ color: sportColors[sport.label] }"
|
||||
:style="{ color: sport.color ? sport.color : sportColors[sport.label] }"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
|
@ -18,7 +18,10 @@ export const sportColors: Record<string, string> = {
|
||||
|
||||
export const sportIdColors = (sports: ISport[]): Record<number, string> => {
|
||||
const colors: Record<number, string> = {}
|
||||
sports.map((sport) => (colors[sport.id] = sportColors[sport.label]))
|
||||
sports.map(
|
||||
(sport) =>
|
||||
(colors[sport.id] = sport.color ? sport.color : sportColors[sport.label])
|
||||
)
|
||||
return colors
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ export const getDatasets = (displayedSports: ISport[]): TStatisticsDatasets => {
|
||||
total_descent: [],
|
||||
}
|
||||
displayedSports.map((sport) => {
|
||||
const color = sportColors[sport.label]
|
||||
const color = sport.color ? sport.color : sportColors[sport.label]
|
||||
datasets.nb_workouts.push(getStatisticsChartDataset(sport.label, color))
|
||||
datasets.total_distance.push(getStatisticsChartDataset(sport.label, color))
|
||||
datasets.total_duration.push(getStatisticsChartDataset(sport.label, color))
|
||||
|
@ -175,7 +175,7 @@ describe('getDatasets', () => {
|
||||
},
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
@ -192,7 +192,7 @@ describe('getDatasets', () => {
|
||||
},
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
@ -209,7 +209,7 @@ describe('getDatasets', () => {
|
||||
},
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
@ -226,7 +226,7 @@ describe('getDatasets', () => {
|
||||
},
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
@ -243,7 +243,7 @@ describe('getDatasets', () => {
|
||||
},
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
{
|
||||
@ -260,35 +260,35 @@ describe('getDatasets', () => {
|
||||
nb_workouts: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
total_distance: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
total_duration: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
total_ascent: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
total_descent: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [],
|
||||
},
|
||||
],
|
||||
@ -334,35 +334,35 @@ describe('formatStats', () => {
|
||||
nb_workouts: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [0, 0, 0],
|
||||
},
|
||||
],
|
||||
total_distance: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [0, 0, 0],
|
||||
},
|
||||
],
|
||||
total_duration: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [0, 0, 0],
|
||||
},
|
||||
],
|
||||
total_ascent: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [0, 0, 0],
|
||||
},
|
||||
],
|
||||
total_descent: [
|
||||
{
|
||||
label: 'Cycling (Transport)',
|
||||
backgroundColor: ['#88af98'],
|
||||
backgroundColor: ['#000000'],
|
||||
data: [0, 0, 0],
|
||||
},
|
||||
],
|
||||
|
Reference in New Issue
Block a user