diff --git a/Eplant/views/eFP/Viewer/EFPTooltip.tsx b/Eplant/views/eFP/Viewer/EFPTooltip.tsx index c69945d..72b2fc3 100644 --- a/Eplant/views/eFP/Viewer/EFPTooltip.tsx +++ b/Eplant/views/eFP/Viewer/EFPTooltip.tsx @@ -124,7 +124,8 @@ function SVGTooltip(props: { diff --git a/Eplant/views/eFP/Viewer/legend.tsx b/Eplant/views/eFP/Viewer/legend.tsx index 59837fd..2361f59 100644 --- a/Eplant/views/eFP/Viewer/legend.tsx +++ b/Eplant/views/eFP/Viewer/legend.tsx @@ -1,7 +1,7 @@ import { Box, styled, useTheme } from '@mui/material' import { getColor } from '../svg' -import { ColorMode, EFPData, EFPState } from '../types' +import { ColorMode, EFPData } from '../types' interface ILegendProps { data: EFPData @@ -18,6 +18,11 @@ export default styled(function Legend({ ...rest }: ILegendProps) { const theme = useTheme() + // TODO: legend uses data.control (cross-group average) and data.min/max as a + // global approximation. This can diverge from per-group colours when groups + // have different controls. A per-group legend is out of scope for this fix. + // I.e. The colours may not line up in this commit/PR due to group colours being different + // than the global legend const control = data.control ?? 1 const values = Array(GRADIENT_STEPS) .fill(0) diff --git a/Eplant/views/eFP/svg.tsx b/Eplant/views/eFP/svg.tsx index 03e7ebd..0f572cf 100644 --- a/Eplant/views/eFP/svg.tsx +++ b/Eplant/views/eFP/svg.tsx @@ -96,7 +96,8 @@ export function getColor( colorMode: ColorMode, tissueStd?: number, maskThreshold?: number, - maskingEnabled?: boolean + maskingEnabled?: boolean, + absoluteMax?: number ): string { const extremum = Math.max( Math.abs(Math.log2(group.min / control)), @@ -118,7 +119,7 @@ export function getColor( return mix( theme.palette.neutral.main, theme.palette.hot.main, - value / group.max + value / (absoluteMax ?? group.max) ) } @@ -139,13 +140,14 @@ export function useStyles( tissue.id } { fill: ${getColor( tissue.mean, - data, - control ?? 1, + group, + group.control ?? control ?? 1, theme, colorMode, tissue.std, maskThreshold, - maskingEnabled + maskingEnabled, + data.max )} !important; }` ) )