Skip to content

Commit

Permalink
feat: hide bridge in relative graph
Browse files Browse the repository at this point in the history
  • Loading branch information
pbullhove committed Apr 5, 2024
1 parent ebc7bb5 commit bd7ee81
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
10 changes: 8 additions & 2 deletions web/src/Components/Bridging/BridgeContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,17 @@ export default ({ bridges, mode, setMode, bridgeValue, setValue }: BridgeContain
/>
<BridgeGraph
graphData={cumulativeVolumeData}
yAxis={'Cumulative Volume (%)'}
yAxis={'Cumulative Frequency (Volume %)'}
sizeFractions={sizeFractions}
bridges={bridges}
/>
<BridgeGraph graphData={volumeData} yAxis={'Volume (%)'} sizeFractions={sizeFractions} bridges={bridges} />
<BridgeGraph
graphData={volumeData}
yAxis={'Relative Frequency (Volume %)'}
sizeFractions={sizeFractions}
bridges={bridges}
showBridge={false}
/>
</div>
</div>
)
Expand Down
15 changes: 11 additions & 4 deletions web/src/Components/Bridging/Graphs/BridgeGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import React, { useContext, useEffect, useState } from 'react'
import { Area, AreaChart, CartesianGrid, Legend, ResponsiveContainer, Tooltip, XAxis, YAxis } from 'recharts'
import { ParticleSizeContext } from '../../../Context'
import { findGraphData } from '../../../Utils'
import { graphColors } from '../styles'
import { bridgeColor, graphColors } from '../styles'
import { Bridge, GraphData } from '../../../Types'

type BridgeGraphProps = {
yAxis: string
graphData: GraphData[]
sizeFractions: number[]
bridges: Bridge
bridges: Bridge | undefined
showBridge?: boolean
}

export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: BridgeGraphProps) {
export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges, showBridge = true }: BridgeGraphProps) {
const [particleFromPercentage, setParticleFromPercentage] = useState<string>('0%')
const [particleToPercentage, setParticleToPercentage] = useState<string>('100%')
const particleRange = useContext(ParticleSizeContext)
Expand All @@ -32,6 +33,10 @@ export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: Bridge
let percentage = (index / sizeFractions.length) * 100
return `${percentage}%`
}
if (!showBridge) {
const { Bridge, ...withoutBridge } = bridges
bridges = withoutBridge
}

return (
<div style={{ backgroundColor: 'white', borderRadius: '0.5rem', width: '100%', height: '100%' }}>
Expand Down Expand Up @@ -63,7 +68,9 @@ export function BridgeGraph({ yAxis, graphData, sizeFractions, bridges }: Bridge
<Area
type='monotone'
dataKey={name}
stroke={graphColors[index % graphColors.length]}
stroke={
name === 'Bridge' ? bridgeColor : graphColors[(index - (showBridge ? 1 : 0)) % graphColors.length]
}
key={name}
fill={(name === 'Bridge' && 'url(#particleArea)') || 'transparent'}
name={name}
Expand Down
18 changes: 6 additions & 12 deletions web/src/Components/Bridging/InputContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,12 @@ const InputContainer = ({
>
<Typography variant='h3'>Optimal Bridge:</Typography>
<div style={{ marginInlineStart: '0.5rem' }}>
<p>
D10: {findDValue(optimalBridgeGraphData, 10, 'Bridge')}
{'\u00B5m'}
</p>
<p>
D50: {findDValue(optimalBridgeGraphData, 50, 'Bridge')}
{'\u00B5m'}
</p>
<p>
D90: {findDValue(optimalBridgeGraphData, 90, 'Bridge')}
{'\u00B5m'}
</p>
{[10, 50, 90].map(d => (
<p>
D{d}: {findDValue(optimalBridgeGraphData, d, 'Bridge')}
{'\u00B5m'}
</p>
))}
</div>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion web/src/Components/Bridging/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ export const StyledSelect = styled.select`
background-color: #ffffff;
`

export const bridgeColor = '#000000'

export const graphColors = [
'#000000',
'#ee2e89',
'#21d0bb',
'#2077d9',
Expand Down

0 comments on commit bd7ee81

Please sign in to comment.