Skip to content

Commit

Permalink
fix: run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pbullhove committed Apr 2, 2024
1 parent e617585 commit 553636b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 41 deletions.
8 changes: 7 additions & 1 deletion web/src/Components/Bridging/BridgeGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ export function BridgeGraph({ bridges, sizeFractions }) {
label={{ value: 'particle size (\u00B5m)', position: 'center', offset: 0 }}
height={70}
/>
<YAxis type='number' domain={[0, 100]} ticks={[20, 40, 60, 80, 100]} allowDataOverflow label={{value: 'Cumulative Volume (%)', angle: '270' }} />
<YAxis
type='number'
domain={[0, 100]}
ticks={[20, 40, 60, 80, 100]}
allowDataOverflow
label={{ value: 'Cumulative Volume (%)', angle: '270' }}
/>
<Tooltip />
<Legend verticalAlign='bottom' align='center' />
{Object.entries(bridges).map(([name, cumulative], index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function ParticleSizeDistributionGraph({ bridges, sizeFractions }) {
label={{ value: 'particle size (\u00B5m)', position: 'center', offset: 0 }}
height={70}
/>
<YAxis type='number' label={{value: 'Volume (%)', angle: '270' }} allowDataOverflow />
<YAxis type='number' label={{ value: 'Volume (%)', angle: '270' }} allowDataOverflow />
<Tooltip />
<Legend verticalAlign='bottom' align='center' />
{Object.entries(bridges).map(([name, cumulative], index) => (
Expand Down
27 changes: 13 additions & 14 deletions web/src/Components/Bridging/styles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { styled } from "styled-components"
import { styled } from 'styled-components'

export const InputWrapper = styled.div`
display: flex;
flex-direction: column;
gap: 10px 5px;
gap: 10px 5px;
`

export const RadioWrapper = styled.div`
Expand All @@ -22,15 +22,14 @@ export const StyledSelect = styled.select`
`

export const graphColors = [
'#000000',
'#ee2e89',
'#21d0bb',
'#2077d9',
'#a1022f',
'#2bcb95',
'#64b3ec',
'#ef7895',
'#02953d',
'#044f78',
]

'#000000',
'#ee2e89',
'#21d0bb',
'#2077d9',
'#a1022f',
'#2bcb95',
'#64b3ec',
'#ef7895',
'#02953d',
'#044f78',
]
50 changes: 25 additions & 25 deletions web/src/Components/Bridging/utils.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { GraphData } from "../../Types";
import { GraphData } from '../../Types'

export function differentiateArrayObjects(arr: GraphData[]): GraphData[] {
return arr.map((currentObj, index, array) => {
// Handling for the last element since it has no successor
if (index === array.length - 1) {
const lastObj: GraphData = { size: currentObj.size }; // Preserving the size property
// Set all other properties to NaN or 0 to indicate no difference can be calculated
Object.keys(currentObj).forEach((key) => {
if (key !== 'size') {
lastObj[key] = NaN; // or set to 0 as per requirement
}
});
return lastObj;
return arr.map((currentObj, index, array) => {
// Handling for the last element since it has no successor
if (index === array.length - 1) {
const lastObj: GraphData = { size: currentObj.size } // Preserving the size property
// Set all other properties to NaN or 0 to indicate no difference can be calculated
Object.keys(currentObj).forEach(key => {
if (key !== 'size') {
lastObj[key] = NaN // or set to 0 as per requirement
}
})
return lastObj
}

const nextObj = array[index + 1];
const differentiatedObj: GraphData = { size: currentObj.size }; // Preserve the size property
const nextObj = array[index + 1]
const differentiatedObj: GraphData = { size: currentObj.size } // Preserve the size property

// Iterate over the properties of the current object
Object.keys(currentObj).forEach((key) => {
if (key !== 'size' && typeof currentObj[key] === 'number') {
// Calculate the difference with the next object's corresponding property
const difference = (nextObj[key] || 0) - currentObj[key];
differentiatedObj[key] = parseFloat(difference.toFixed(3));
}
});
// Iterate over the properties of the current object
Object.keys(currentObj).forEach(key => {
if (key !== 'size' && typeof currentObj[key] === 'number') {
// Calculate the difference with the next object's corresponding property
const difference = (nextObj[key] || 0) - currentObj[key]
differentiatedObj[key] = parseFloat(difference.toFixed(3))
}
})

return differentiatedObj;
});
}
return differentiatedObj
})
}

0 comments on commit 553636b

Please sign in to comment.