This commit is contained in:
Andras Schmelczer 2026-05-11 21:38:26 +01:00
parent 9248e26af2
commit f2a2651b8a
95 changed files with 3993 additions and 1471 deletions

View file

@ -159,9 +159,10 @@ export function useDeckLayers({
continue;
}
const c = d.count as number;
total += c;
if (c <= 0) continue;
if (c < min) min = c;
if (c > max) max = c;
total += c;
}
if (min === Infinity) return { min: 0, max: 1, total: 0 };
if (min === max) return { min, max: min + 1, total };
@ -188,9 +189,10 @@ export function useDeckLayers({
continue;
}
const c = d.properties.count;
total += c;
if (c <= 0) continue;
if (c < min) min = c;
if (c > max) max = c;
total += c;
}
if (min === Infinity) return { min: 0, max: 1, total: 0 };
if (min === max) return { min, max: min + 1, total };
@ -296,6 +298,9 @@ export function useDeckLayers({
data,
getHexagon: (d) => d.h3,
getFillColor: (d) => {
if ((d.count as number) <= 0) {
return [0, 0, 0, 0] as [number, number, number, number];
}
const dark = isDarkRef.current;
const vf = viewFeatureRef.current;
const clr = colorRangeRef.current;
@ -400,6 +405,9 @@ export function useDeckLayers({
data: postcodeData as PostcodeFeature[],
getFillColor: (f) => {
const d = f.properties;
if (d.count <= 0) {
return [0, 0, 0, 0] as [number, number, number, number];
}
const dark = isDarkRef.current;
const vf = viewFeatureRef.current;
const clr = colorRangeRef.current;
@ -477,6 +485,7 @@ export function useDeckLayers({
const dark = isDarkRef.current;
if (pc === hoveredPostcodeRef.current)
return [29, 228, 195, 200] as [number, number, number, number];
if (f.properties.count <= 0) return [0, 0, 0, 0] as [number, number, number, number];
return (dark ? [180, 170, 160, 100] : [100, 100, 100, 150]) as [
number,
number,
@ -487,6 +496,7 @@ export function useDeckLayers({
getLineWidth: (f) => {
const pc = f.properties.postcode;
if (pc === hoveredPostcodeRef.current) return 2;
if (f.properties.count <= 0) return 0;
return 1;
},
lineWidthUnits: 'pixels',
@ -504,11 +514,16 @@ export function useDeckLayers({
});
}, [postcodeData, postcodeColorTrigger, handlePostcodeClick, handlePostcodeHoverCallback]);
const labeledPostcodeData = useMemo(
() => postcodeData.filter((feature) => feature.properties.count > 0),
[postcodeData]
);
const postcodeLabelsLayer = useMemo(
() =>
new TextLayer<PostcodeFeature>({
id: 'postcode-labels',
data: postcodeData,
data: labeledPostcodeData,
getPosition: (f) => f.properties.centroid,
getText: (f) => f.properties.postcode,
getSize: 12,
@ -525,7 +540,7 @@ export function useDeckLayers({
billboard: false,
pickable: false,
}),
[postcodeData, theme]
[labeledPostcodeData, theme]
);
// Marching ants highlight layer for selected hexagon or postcode