Skip to content

Commit 7e5eadf

Browse files
committed
🎉 add population data to context and heatmap tooltip
1 parent 1b423f7 commit 7e5eadf

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

locales/de-global.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
edit: 'Farblegende bearbeiten',
9696
lock: 'Maximalwert feststellen',
9797
select: 'Farblegende auswählen',
98+
population: 'Bevölkerung',
9899
},
99100
bottomTabs: {
100101
timeSeries: 'Zeitreihe',

locales/en-global.json5

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
edit: 'Edit heatmap colors',
104104
lock: 'Lock maximum value',
105105
select: 'Select heatmap preset',
106+
population: 'Population',
106107
},
107108
bottomTabs: {
108109
timeSeries: 'Time Series',

src/components/Sidebar/SidebarContainer.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function MapContainer() {
3333
const theme = useTheme();
3434
const dispatch = useAppDispatch();
3535

36-
const {geoData, mapData, searchBarData, nodes, compartments} = useContext(DataContext)!;
36+
const {geoData, mapData, searchBarData, nodes, compartments, populationByNuts} = useContext(DataContext)!;
3737

3838
const storeSelectedArea = useAppSelector((state) => state.dataSelection.district);
3939
const selectedCompartment = useAppSelector((state) => state.dataSelection.compartment);
@@ -130,11 +130,13 @@ export default function MapContainer() {
130130
const compartmentName = tBackend(
131131
`infection-states.${compartments?.find((c) => c.id === selectedCompartment)?.name}`
132132
);
133+
const population = populationByNuts?.[String(regionData?.RS)] as number | undefined;
134+
const populationLine = population ? `${t('heatlegend.population')}: ${formatNumber(population)}` : '';
133135
return selectedScenario !== null && selectedCompartment
134-
? `${bez} {GEN}\n${compartmentName}: ${formatNumber(Number(regionData?.value))}`
135-
: `${bez} {GEN}`;
136+
? `${bez} {GEN}\n${populationLine}\n${compartmentName}: ${formatNumber(Number(regionData?.value))}`
137+
: `${bez} {GEN}${populationLine}`;
136138
},
137-
[compartments, formatNumber, selectedCompartment, selectedScenario, t, tBackend]
139+
[compartments, formatNumber, populationByNuts, selectedCompartment, selectedScenario, t, tBackend]
138140
);
139141

140142
const calculateToolTipFetching = useCallback(

src/context/SelectedDataContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ interface DataContextType {
5353
npis: InterventionTemplates;
5454
nodeLists: NodeLists;
5555
nodes: Nodes;
56+
populationByNuts: Record<string, number>;
5657
}
5758

5859
export const DataContext = createContext<DataContextType | null>(null);
@@ -334,6 +335,7 @@ export default function SelectedDataContext(props: {baseData: BaseData; children
334335
selectedScenarioData: selectedScenarioData!,
335336
selectedSimulationModel: selectedSimulationModel!,
336337
parameterDefinitions: parameterDefinitions ?? {},
338+
populationByNuts: props.baseData.populationByNuts,
337339
}),
338340
[
339341
props.baseData,

0 commit comments

Comments
 (0)