feat: adjust formatting slightly
This commit is contained in:
parent
70a4ece5bc
commit
d61bea3c86
@ -34,6 +34,7 @@ const RaceChart: FC<RaceChartProps> = ({ players, std }) => {
|
|||||||
const gap = 8;
|
const gap = 8;
|
||||||
const maxValue = Math.max(...players.map((player) => player.rank)) + 1;
|
const maxValue = Math.max(...players.map((player) => player.rank)) + 1;
|
||||||
const barHeight = (height - 2 * padding) / players.length;
|
const barHeight = (height - 2 * padding) / players.length;
|
||||||
|
const fontSize = Math.min(barHeight - 1.5 * gap, width / 20);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<svg width={width} height={height}>
|
<svg width={width} height={height}>
|
||||||
@ -51,41 +52,43 @@ const RaceChart: FC<RaceChartProps> = ({ players, std }) => {
|
|||||||
{players.map((player, index) => (
|
{players.map((player, index) => (
|
||||||
<g>
|
<g>
|
||||||
<text
|
<text
|
||||||
key={index}
|
key={index + "_name"}
|
||||||
x={4}
|
x={4}
|
||||||
y={index * barHeight + barHeight / 2 + padding + gap / 2}
|
y={index * barHeight + barHeight / 2 + padding + gap / 2}
|
||||||
width={(1 - player.rank / maxValue) * width}
|
width={(1 - player.rank / maxValue) * width}
|
||||||
height={barHeight - 8} // subtract 2 for some spacing between bars
|
height={barHeight - 8} // subtract 2 for some spacing between bars
|
||||||
fontSize={`${barHeight - 1.5 * gap}px`}
|
fontSize={fontSize}
|
||||||
fill="aliceblue"
|
fill="aliceblue"
|
||||||
stroke="#36c"
|
stroke="#36c"
|
||||||
strokeWidth={4}
|
strokeWidth={4}
|
||||||
fontWeight={"bold"}
|
fontWeight={"bold"}
|
||||||
paintOrder={"stroke fill"}
|
paintOrder={"stroke fill"}
|
||||||
fontFamily="monospace"
|
fontFamily="monospace"
|
||||||
|
style={{ whiteSpace: "pre" }}
|
||||||
>
|
>
|
||||||
{index + 1}. {player.name}
|
{`${String(index + 1).padStart(2)}. ${player.name}`}
|
||||||
</text>
|
</text>
|
||||||
<text
|
<text
|
||||||
key={index}
|
key={index + "_value"}
|
||||||
x={
|
x={
|
||||||
4 +
|
4 +
|
||||||
(4 + Math.max(...players.map((p, _) => p.name.length))) *
|
(4 + Math.max(...players.map((p, _) => p.name.length))) *
|
||||||
(barHeight - 1.5 * gap) *
|
fontSize *
|
||||||
0.66
|
0.66
|
||||||
}
|
}
|
||||||
y={index * barHeight + barHeight / 2 + padding + gap / 2}
|
y={index * barHeight + barHeight / 2 + padding + gap / 2}
|
||||||
width={(1 - player.rank / maxValue) * width}
|
width={(1 - player.rank / maxValue) * width}
|
||||||
height={barHeight - 8} // subtract 2 for some spacing between bars
|
height={barHeight - 8} // subtract 2 for some spacing between bars
|
||||||
fontSize={`${0.75 * (barHeight - 1.5 * gap)}px`}
|
fontSize={0.8 * fontSize}
|
||||||
fill="aliceblue"
|
fill="aliceblue"
|
||||||
stroke="#36c"
|
stroke="#36c"
|
||||||
fontWeight={"bold"}
|
fontWeight={"bold"}
|
||||||
|
fontFamily="monospace"
|
||||||
strokeWidth={4}
|
strokeWidth={4}
|
||||||
paintOrder={"stroke fill"}
|
paintOrder={"stroke fill"}
|
||||||
style={{ whiteSpace: "pre" }}
|
style={{ whiteSpace: "pre" }}
|
||||||
>
|
>
|
||||||
{`${player.rank} ± ${player.std} N = ${player.n}`}
|
{`${String(player.rank).padStart(5)} ± ${player.std} N = ${player.n}`}
|
||||||
</text>
|
</text>
|
||||||
</g>
|
</g>
|
||||||
))}
|
))}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user