From a811494d3030fdbbda38ea3e2c73df45a016330c Mon Sep 17 00:00:00 2001 From: Peter Bull Hove Date: Thu, 4 Apr 2024 14:55:00 +0200 Subject: [PATCH] fix: particle offset bug --- web/src/Components/Bridging/Graphs/BridgeGraph.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx index d26211b..2a62cda 100644 --- a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx +++ b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx @@ -13,8 +13,8 @@ type BridgeGraphProps = { } export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: BridgeGraphProps) { - const [particleFromPercentage, setParticleFromPercentage] = useState('') - const [particleToPercentage, setParticleToPercentage] = useState('') + const [particleFromPercentage, setParticleFromPercentage] = useState('30%') + const [particleToPercentage, setParticleToPercentage] = useState('100%') const particleRange = useContext(ParticleSizeContext) useEffect(() => { @@ -28,8 +28,8 @@ export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: Bridge function particleSizeOffsetPercentage(offsetSize: number) { const index = sizeFractions.findIndex(size => size > offsetSize) - if (index === -1) return '' - const percentage = Math.round(index / sizeFractions.length) * 100 + if (index === -1) return '0%' + let percentage = (index / sizeFractions.length) * 100 return `${percentage}%` }