Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaellaude committed Nov 17, 2024
1 parent 6cc42e9 commit 3b6044a
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions app/src/app/components/sidebar/Evaluation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import {
stdDevArray,
stdDevColors,
sumArray,
} from '@/app/utils/summaryStats';
import { interpolateBlues, interpolateGreys } from 'd3-scale-chromatic';
} from '@utils/summaryStats';
import {interpolateBlues, interpolateGreys} from 'd3-scale-chromatic';

type EvalModes = 'share' | 'count' | 'totpop';
type ColumnConfiguration<T extends Record<string, any>> = Array<{label: string; column: keyof T}>;
Expand Down Expand Up @@ -127,27 +127,27 @@ const Evaluation: React.FC<EvaluationProps> = ({columnConfig = defaultColumnConf
);

const {
unassigned,
maxValues
// averages,
unassigned,
maxValues,
// averages,
// stdDevs
} = useMemo(() => {
if (!data?.results || !totPop) {
return {};
}
let maxValues: Record<string, number> = {}
let maxValues: Record<string, number> = {};

let unassigned: Record<string, number> = {
...totPop,
zone: -999,
total: getEntryTotal(totPop),
};
P1ZoneSummaryStatsKeys.forEach(key => {
let total = unassigned[key];
maxValues[key] = -Math.pow(10,12)
maxValues[key] = -Math.pow(10, 12);
data.results.forEach(row => {
total -= row[key];
maxValues[key] = Math.max(row[key], maxValues[key])
maxValues[key] = Math.max(row[key], maxValues[key]);
});
unassigned[`${key}_pct`] = total / unassigned[key];
unassigned[key] = total;
Expand All @@ -160,9 +160,9 @@ const Evaluation: React.FC<EvaluationProps> = ({columnConfig = defaultColumnConf
// stdDevs[key] = stdDevArray(values);
// });
return {
unassigned,
maxValues
// averages,
unassigned,
maxValues,
// averages,
// stdDevs
};
}, [data?.results, totPop]);
Expand Down Expand Up @@ -292,10 +292,14 @@ const Evaluation: React.FC<EvaluationProps> = ({columnConfig = defaultColumnConf
</td>
{columnConfig.map((f, i) => {
const column = columnGetter(f.column);
const colorValue = evalMode === 'count' ? row[column]/maxValues[column] : row[column]
const backgroundColor = (colorBg && !isUnassigned)
? interpolateGreys(colorValue).replace('rgb', 'rgba').replace(')', ",0.5)")
: 'initial'
const colorValue =
evalMode === 'count' ? row[column] / maxValues[column] : row[column];
const backgroundColor =
colorBg && !isUnassigned
? interpolateGreys(colorValue)
.replace('rgb', 'rgba')
.replace(')', ',0.5)')
: 'initial';
return (
<td
className="py-2 px-4 text-right"
Expand Down

0 comments on commit 3b6044a

Please sign in to comment.