Skip to content

Commit 24ccf06

Browse files
committed
better y axis legend for the charts
1 parent 36d78a2 commit 24ccf06

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

packages/client/src/pages/results/components/CategoriesBarChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Box } from '@chakra-ui/react'
22
import { EventWithResults, RatingResultWithJoins, StageWithResults } from '@pontozo/common'
33
import { Bar, BarChart, CartesianGrid, Legend, Text, Tooltip, XAxis, YAxis } from 'recharts'
44
import { useResultTableContext } from 'src/api/contexts/useResultTableContext'
5-
import { chartColors } from 'src/util/chartColors'
5+
import { chartColors, yAxisTickFormatter } from 'src/util/chartHelpers'
66
import { getScore } from 'src/util/resultItemHelpers'
77
import { BarChartData } from '../types/BarChartData'
88

@@ -81,7 +81,7 @@ export const CategoriesBarChart = ({ event, setSelectedCategoryId }: Props) => {
8181
</Text>
8282
)}
8383
/>
84-
<YAxis type="number" domain={[0, 3]} tickCount={4} />
84+
<YAxis width={100} tickFormatter={yAxisTickFormatter} type="number" domain={[0, 3]} tickCount={4} />
8585
<Legend />
8686
{!isMobile && <Tooltip cursor={{ fillOpacity: 0.4 }} />}
8787
<Bar name="Teljes verseny" dataKey="event" fill={chartColors[0]} onClick={(e) => onChartClick(e.categoryId)} />

packages/client/src/pages/results/components/CriteriaBarChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EventWithResults, Rank } from '@pontozo/common'
33
import { useEffect, useState } from 'react'
44
import { Bar, BarChart, CartesianGrid, Legend, Text, Tooltip, XAxis, YAxis } from 'recharts'
55
import { useResultTableContext } from 'src/api/contexts/useResultTableContext'
6-
import { chartColors } from 'src/util/chartColors'
6+
import { chartColors, yAxisTickFormatter } from 'src/util/chartHelpers'
77
import { getScore } from 'src/util/resultItemHelpers'
88
import { BarChartData } from '../types/BarChartData'
99

@@ -68,7 +68,7 @@ export const CriteriaBarChart = ({ event, selectedCategoryId }: Props) => {
6868
</Text>
6969
)}
7070
/>
71-
<YAxis type="number" domain={[0, 3]} tickCount={4} />
71+
<YAxis type="number" width={100} tickFormatter={yAxisTickFormatter} domain={[0, 3]} tickCount={4} />
7272
{!isMobile && <Tooltip cursor={{ fillOpacity: 0.4 }} />}
7373
<Legend />
7474
<Bar name="Teljes verseny" dataKey="event" fill={chartColors[0]} />

packages/client/src/util/chartColors.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const chartColors = [
2+
'#0a723a',
3+
'#F8AB10', // mezo sarga
4+
'#B04191', // felulnyomas
5+
'#D07500', // szintvonal barna
6+
'#009FE3', // viz
7+
'#EAB983', // aszfalt
8+
'#f76d1c', // bolya
9+
'#9D9D9C', // epulet
10+
]
11+
12+
export const yAxisTickFormatter = (value: number) => {
13+
switch (value) {
14+
case 0:
15+
return '0 (rossz)'
16+
case 1:
17+
return '1 (gyenge)'
18+
case 2:
19+
return '2 (megfelelő)'
20+
default:
21+
return '3 (kiváló)'
22+
}
23+
}

0 commit comments

Comments
 (0)