Skip to content

Commit

Permalink
fix: Undefined observations in legend domain
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Jan 25, 2022
1 parent 07c9659 commit 56f5557
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/charts/map/map-legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const CircleLegend = () => {
const domainObservations = useMemo(
() => dataDomain.map((d) => data.find((x) => getValue(x) === d)),
[data, dataDomain, getValue]
) as [Observation, Observation];
) as [Observation | undefined, Observation | undefined];

return (
<svg width={width} height={HEIGHT}>
Expand All @@ -210,11 +210,12 @@ const CircleLegend = () => {
>
{dataDomain.map((d, i) => {
const observation = domainObservations[i];
const label = getLabel(observation);
const radius = radiusScale(d);

return (
observation && (
if (observation) {
const label = getLabel(observation);
const radius = radiusScale(d);

return (
<>
{
<Circle
Expand All @@ -229,8 +230,8 @@ const CircleLegend = () => {
/>
}
</>
)
);
);
}
})}

{/* Hovered data point indicator */}
Expand Down

0 comments on commit 56f5557

Please sign in to comment.