Skip to content

Commit 9463d72

Browse files
committed
🎉 🔧 ✨ exports heatmap, improved styling and formatting
1 parent 142556f commit 9463d72

File tree

4 files changed

+172
-72
lines changed

4 files changed

+172
-72
lines changed

locales/de-global.json5

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@
139139
description: 'Aktuelle Auswahl als PDF-Bericht exportieren.',
140140
button: 'PDF exportieren',
141141
info: {
142-
selectedDistrict: 'Ausgewählter Landkreis',
143-
selectedScenario: 'Ausgewähltes Szenario',
144-
referenceDate: 'Referenzdatum',
145-
selectedDate: 'Ausgewähltes Datum',
142+
'selected-district': 'Ausgewählter Landkreis',
143+
'selected-scenario': 'Ausgewähltes Szenario',
144+
'reference-date': 'Referenzdatum',
145+
'selected-date': 'Ausgewähltes Datum',
146146
},
147147
images: {
148-
lineChartLabel: 'Liniendiagramm',
149-
mapLabel: 'Karte',
148+
'line-chart-label': 'Liniendiagramm',
149+
'map-label': 'Karte',
150150
},
151151
table: {
152152
compartment: 'Zustand',
153-
referenceValue: 'Referenzwert',
154-
selectedValue: 'Ausgewählter Wert',
153+
'reference-value': 'Referenzwert',
154+
'selected-value': 'Ausgewählter Wert',
155155
},
156156
},
157157
}

locales/en-global.json5

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,19 @@
154154
description: 'Export the current selection as a PDF report.',
155155
button: 'Export PDF',
156156
info: {
157-
selectedDistrict: 'Selected District',
158-
selectedScenario: 'Selected Scenario',
159-
referenceDate: 'Reference Date',
160-
selectedDate: 'Selected Date',
157+
'selected-district': 'Selected District',
158+
'selected-scenario': 'Selected Scenario',
159+
'reference-date': 'Reference Date',
160+
'selected-date': 'Selected Date',
161161
},
162162
images: {
163-
lineChartLabel: 'Line chart',
164-
mapLabel: 'Map',
163+
'line-chart-label': 'Line chart',
164+
'map-label': 'Map',
165165
},
166166
table: {
167167
compartment: 'Compartment',
168-
referenceValue: 'Reference Value',
169-
selectedValue: 'Selected Value',
168+
'reference-value': 'Reference Value',
169+
'selected-value': 'Selected Value',
170170
},
171171
},
172172
}

src/components/Sidebar/MapComponents/HeatLegend.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR)
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import React, {useCallback, useLayoutEffect, useMemo} from 'react';
4+
import React, {useCallback, useEffect, useLayoutEffect, useMemo} from 'react';
55
import * as am5 from '@amcharts/amcharts5';
66
import Box from '@mui/material/Box';
77
import {HeatmapLegend} from 'types/heatmapLegend';
@@ -10,6 +10,9 @@ import {Localization} from 'types/localization';
1010
import useRoot from 'components/shared/Root';
1111
import useHeatLegend from 'components/shared/HeatMap/Legend';
1212

13+
// export
14+
import {useExportingRegistry} from 'context/ExportContext';
15+
import useExporting from '@/components/shared/Exporting';
1316
interface HeatProps {
1417
/**
1518
* Object defining the legend for the heatmap.
@@ -76,6 +79,8 @@ export default function HeatLegend({
7679
const unique_id = useMemo(() => id + String(Date.now() + Math.random()), [id]);
7780
const theme = useTheme();
7881

82+
const {register} = useExportingRegistry();
83+
7984
const root = useRoot(unique_id);
8085

8186
const memoizedLocalization = useMemo(() => {
@@ -137,5 +142,19 @@ export default function HeatLegend({
137142
// This effect should only run when the legend object changes
138143
}, [heatLegend, legend, min, max, exposeLegend]);
139144

145+
const exportSettings = useMemo(() => {
146+
return {
147+
filePrefix: 'map',
148+
};
149+
}, []);
150+
151+
const exporting = useExporting(root, exportSettings);
152+
153+
useEffect(() => {
154+
if (exporting) {
155+
register('legend', exporting);
156+
}
157+
}, [exporting, register]);
158+
140159
return <Box id={unique_id} sx={style} />;
141160
}

0 commit comments

Comments
 (0)