diff --git a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx index 40be3af..62a28a8 100644 --- a/web/src/Components/Bridging/Graphs/BridgeGraph.tsx +++ b/web/src/Components/Bridging/Graphs/BridgeGraph.tsx @@ -3,22 +3,30 @@ import { Area, AreaChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, X import { ParticleSizeContext } from '../../../Context' import { findGraphData } from '../../../Utils' import { graphColors } from '../styles' +import { Bridge, GraphData } from '../../../Types' -export function BridgeGraph({ graphData, sizeFractions, bridges }) { - const [particleFromPercentage, setParticleFromPercentage] = useState('') - const [particleToPercentage, setParticleToPercentage] = useState('') +type BridgeGraphProps = { + yAxis: string + graphData: GraphData[] + sizeFractions: number[] + bridges: Bridge +} + +export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: BridgeGraphProps) { + const [particleFromPercentage, setParticleFromPercentage] = useState('') + const [particleToPercentage, setParticleToPercentage] = useState('') const particleRange = useContext(ParticleSizeContext) useEffect(() => { setParticleFromPercentage(particleSizeOffsetPercentage(particleRange.from)) if (particleRange.to > sizeFractions[sizeFractions.length - 1]) { - setParticleToPercentage(sizeFractions[sizeFractions.length - 1]) + setParticleToPercentage(`${sizeFractions[sizeFractions.length - 1]}`) } else { setParticleToPercentage(particleSizeOffsetPercentage(particleRange.to)) } }, [particleRange, sizeFractions]) - function particleSizeOffsetPercentage(offsetSize) { + function particleSizeOffsetPercentage(offsetSize: number) { const index = sizeFractions.findIndex(size => size > offsetSize) if (index === -1) return '' const percentage = Math.round(index / sizeFractions.length) * 100 @@ -47,14 +55,7 @@ export function BridgeGraph({ graphData, sizeFractions, bridges }) { label={{ value: 'particle size (\u00B5m)', position: 'center', offset: 0 }} height={70} /> - + {Object.entries(bridges).map(([name, cumulative], index) => ( diff --git a/web/src/Components/Bridging/Graphs/CumulativeGraph.tsx b/web/src/Components/Bridging/Graphs/CumulativeGraph.tsx index 51852bc..360d3cd 100644 --- a/web/src/Components/Bridging/Graphs/CumulativeGraph.tsx +++ b/web/src/Components/Bridging/Graphs/CumulativeGraph.tsx @@ -11,7 +11,14 @@ export function CumulativeGraph({ bridges, sizeFractions }) { setGraphData(newGraphData) }, [bridges, sizeFractions]) - return + return ( + + ) } export default CumulativeGraph diff --git a/web/src/Components/Bridging/Graphs/DistributionGraph.tsx b/web/src/Components/Bridging/Graphs/DistributionGraph.tsx index bdc8780..6109d77 100644 --- a/web/src/Components/Bridging/Graphs/DistributionGraph.tsx +++ b/web/src/Components/Bridging/Graphs/DistributionGraph.tsx @@ -12,7 +12,7 @@ export function ParticleSizeDistributionGraph({ bridges, sizeFractions }) { setGraphData(diffentiated) }, [bridges, sizeFractions]) - return + return } export default ParticleSizeDistributionGraph diff --git a/web/src/Components/Bridging/InputContainer.tsx b/web/src/Components/Bridging/InputContainer.tsx index 8b479c4..19e4a38 100644 --- a/web/src/Components/Bridging/InputContainer.tsx +++ b/web/src/Components/Bridging/InputContainer.tsx @@ -97,11 +97,20 @@ const InputContainer = ({ {optimalBridgeGraphData.length > 0 && ( -
+
Optimal Bridge: -

D10: {findDValue(optimalBridgeGraphData, 10, 'Bridge')}µ

-

D50: {findDValue(optimalBridgeGraphData, 50, 'Bridge')}µ

-

D90: {findDValue(optimalBridgeGraphData, 90, 'Bridge')}µ

+

+ D10: {findDValue(optimalBridgeGraphData, 10, 'Bridge')} + {'\u00B5'} +

+

+ D50: {findDValue(optimalBridgeGraphData, 50, 'Bridge')} + {'\u00B5'} +

+

+ D90: {findDValue(optimalBridgeGraphData, 90, 'Bridge')} + {'\u00B5'} +

)}