From 5c21cf1fc36d4ef5c48161f31bd4f55f90b36d77 Mon Sep 17 00:00:00 2001 From: julius Date: Mon, 24 Feb 2025 18:04:20 +0100 Subject: [PATCH] feat: add vertical BarChart --- src/BarChart.tsx | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/BarChart.tsx diff --git a/src/BarChart.tsx b/src/BarChart.tsx new file mode 100644 index 0000000..e09e40b --- /dev/null +++ b/src/BarChart.tsx @@ -0,0 +1,95 @@ +import { FC } from 'react'; +import { PlayerRanking } from './types'; + +interface BarChartProps { + players: PlayerRanking[]; + width: number; + height: number; + std: boolean; +} + +const BarChart: FC = ({ players, width, height, std }) => { + const padding = 24; + const maxValue = Math.max(...players.map((player) => player.rank)) + 1; + const barWidth = (width - 2 * padding) / players.length; + + return ( + + + {players.map((player, index) => ( + + ))} + + {players.map((player, index) => ( + + {player.name} + + ))} + + {players.map((player, index) => ( + + {player.rank} + + ))} + + {std && players.map((player, index) => ( + + ))} + {std && players.map((player, index) => ( + + ))} + {std && players.map((player, index) => ( + + ))} + + ); +}; + +export default BarChart;