Skip to content

Commit 27d8d73

Browse files
committed
[Frontend] Move color lists to theme palette
1 parent 4df339f commit 27d8d73

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

services/frontend/src/components/common/LineGraph.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ import exporting from 'highcharts/modules/exporting'
44
import ReactHighcharts from 'react-highcharts'
55

66
import { Section } from '@/components/Section'
7+
import { theme } from '@/theme'
78
import { GraphStat } from '@/types/graphStat'
89

910
exporting(ReactHighcharts.Highcharts)
1011
exportData(ReactHighcharts.Highcharts)
1112
accessibility(ReactHighcharts.Highcharts)
1213

13-
// TODO: Move to theme
14-
const colors = ['#7cb5ec', '#90ed7d', '#434348', '#f7a35c', '#FFF000', '#2b908f', '#f45b5b', '#91e8e1']
15-
1614
export const LineGraph = ({
1715
cypress,
1816
exportFileName,
@@ -30,7 +28,7 @@ export const LineGraph = ({
3028

3129
const dataWithColors = graphStats.map((series, index) => ({
3230
...series,
33-
color: colors[index],
31+
color: theme.palette.graphColors[index],
3432
type: 'line' as const,
3533
}))
3634

services/frontend/src/components/common/StackedBarChart.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import exporting from 'highcharts/modules/exporting'
66
import ReactHighcharts from 'react-highcharts'
77

88
import { Section } from '@/components/Section'
9+
import { theme } from '@/theme'
910

1011
exporting(ReactHighcharts.Highcharts)
1112
exportData(ReactHighcharts.Highcharts)
1213
accessibility(ReactHighcharts.Highcharts)
1314

14-
// TODO: Move to theme
15-
const colors = ['#7cb5ec', '#90ed7d', '#434348', '#f7a35c', '#FFF000', '#2b908f', '#f45b5b', '#91e8e1']
16-
1715
export const StackedBarChart = ({
1816
cypress,
1917
data,
@@ -29,7 +27,11 @@ export const StackedBarChart = ({
2927
return null
3028
}
3129

32-
const dataWithColors = data?.map((series, index) => ({ ...series, color: colors[index], type: 'column' as const }))
30+
const dataWithColors = data?.map((series, index) => ({
31+
...series,
32+
color: theme.palette.graphColors[index],
33+
type: 'column' as const,
34+
}))
3335

3436
const config: HighCharts.Options = {
3537
series: dataWithColors,

services/frontend/src/pages/Faculties/BasicInformationTab/InteractiveDataTable/CollapsedStackedBar.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import exporting from 'highcharts/modules/exporting'
77
import ReactHighcharts from 'react-highcharts'
88

99
import { useLanguage } from '@/components/LanguagePicker/useLanguage'
10+
import { theme } from '@/theme'
1011
import { NameWithCode } from '@oodikone/shared/types'
1112

1213
exporting(ReactHighcharts.Highcharts)
1314
exportData(ReactHighcharts.Highcharts)
1415
accessibility(ReactHighcharts.Highcharts)
1516

16-
// TODO: Move to theme
17-
const colors = ['#7cb5ec', '#90ed7d', '#434348', '#f7a35c', '#FFF000', '#2b908f', '#f45b5b', '#91e8e1']
18-
1917
export const CollapsedStackedBar = ({
2018
data,
2119
differenceData,
@@ -39,7 +37,12 @@ export const CollapsedStackedBar = ({
3937
names[0] += ' (new in faculty)'
4038
}
4139
const dataTranspose = transpose(data)
42-
.map((obj, index) => ({ name: names[index], data: obj, color: colors[index], type: 'bar' as const }))
40+
.map((obj, index) => ({
41+
name: names[index],
42+
data: obj,
43+
color: theme.palette.graphColors[index],
44+
type: 'bar' as const,
45+
}))
4346
.reverse()
4447

4548
const differenceArray: Record<string, Record<string, number>> = Object.keys(differenceData).reduce(

services/frontend/src/theme/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ const baseTheme = {
8383
doctor: blueGrey[200],
8484
postgrad: blueGrey[300],
8585
},
86+
graphColors: ['#7cb5ec', '#90ed7d', '#434348', '#f7a35c', '#FFF000', '#2b908f', '#f45b5b', '#91e8e1'],
8687
},
8788
} as const
8889

0 commit comments

Comments
 (0)