Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Undefined observations in map circle legend #292

Merged
merged 1 commit into from
Jan 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 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,27 +210,24 @@ const CircleLegend = () => {
>
{dataDomain.map((d, i) => {
const observation = domainObservations[i];
const label = getLabel(observation);
const radius = radiusScale(d);

return (
observation && (
<>
{
<Circle
value={formatNumber(d)}
label={label}
fill="none"
stroke={axisLabelColor}
radius={radius}
maxRadius={maxRadius}
fontSize={legendFontSize}
showLine={!interaction.visible}
/>
}
</>
)
);
if (observation) {
const label = getLabel(observation);
const radius = radiusScale(d);

return (
<Circle
value={formatNumber(d)}
label={label}
fill="none"
stroke={axisLabelColor}
radius={radius}
maxRadius={maxRadius}
fontSize={legendFontSize}
showLine={!interaction.visible}
/>
);
}
})}

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