Skip to content

Commit

Permalink
prettier EFP tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiewaese committed Jan 4, 2024
1 parent e123d6e commit f19e002
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 69 deletions.
1 change: 1 addition & 0 deletions Eplant/View/viewData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function useViewData<T, S, A>(
const id = (view?.id ?? 'generic-view') + '-' + useViewID()
const [viewData, setViewData] = useAtom(getViewAtom(key))
const [viewState, setViewState] = useAtom(getViewStateAtom(id))
// console.log(viewData)

// If there is no cached viewData then load it using the view's loader
React.useEffect(() => {
Expand Down
103 changes: 34 additions & 69 deletions Eplant/views/eFP/Tooltips/EFPTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ export const setStroke = (
}
}

function KeyValueRow(props: {
label: string,
value: string | number
}) {

return <TableRow>
<TableCell
sx={theme => ({
color: theme.palette.text.secondary,
textAlign: 'left',
border: 'none',
})}
>
{props.label}
</TableCell>
<TableCell
sx={theme => ({
color: theme.palette.text.primary,
textAlign: 'right',
border: 'none'
})}>{props.value}</TableCell>
</TableRow>
}

function SVGTooltip(props: {
el: SVGElement | null
group: EFPGroup
Expand Down Expand Up @@ -75,78 +99,19 @@ function SVGTooltip(props: {
>
<Table size="small">
<TableBody>
<TableRow>
<TableCell
sx={{
color: theme.palette.secondary.main,
textAlign: 'right',
}}
>
Sample name
</TableCell>
<TableCell>{props.tissue.name}</TableCell>
</TableRow>
<TableRow>
<TableCell
sx={{
color: theme.palette.secondary.main,
textAlign: 'right',
}}
>
Level
</TableCell>
<TableCell>
{props.tissue.mean.toFixed(2)}±{props.tissue.std.toFixed(2)}
<TableRow>
<TableCell colSpan={2} sx={{
fontSize: 'medium',
fontWeight: '500',
border: 'none'
}}>
{props.tissue.name}
</TableCell>
</TableRow>
{props.state.colorMode == 'relative' ? (
<>
<TableRow>
<TableCell
sx={{
color: theme.palette.secondary.main,
textAlign: 'right',
}}
>
Samples
</TableCell>
<TableCell>{props.tissue.samples}</TableCell>
</TableRow>
<TableRow>
<TableCell
sx={{
color: theme.palette.secondary.main,
textAlign: 'right',
borderBottom: 'none',
}}
>
Log2 fold change vs control
</TableCell>
<TableCell sx={{ borderBottom: 'none' }}>
{Math.log2(
<KeyValueRow label="Level" value={`${props.tissue.mean.toFixed(2)}±${props.tissue.std.toFixed(2)}`}/>
<KeyValueRow label="Log2 fold change vs control" value={Math.log2(
props.tissue.mean / (props.data.control ?? 1),
).toFixed(2)}
</TableCell>
</TableRow>
</>
) : (
<>
<TableRow>
<TableCell
sx={{
color: theme.palette.secondary.main,
textAlign: 'right',
borderBottom: 'none',
}}
>
Samples
</TableCell>
<TableCell sx={{ borderBottom: 'none' }}>
{props.tissue.samples}
</TableCell>
</TableRow>
</>
)}
).toFixed(2)}/>
</TableBody>
</Table>
</Box>
Expand Down

0 comments on commit f19e002

Please sign in to comment.