Skip to content

Commit

Permalink
Fix clicks not working on highlighted countries
Browse files Browse the repository at this point in the history
  • Loading branch information
rbardini committed Oct 13, 2024
1 parent 3f5f96f commit 25e5c78
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions hooks/use-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,6 @@ export default function useChart(
}),
)

const data: Record<string, number> = {}
;(await readWishedCountriesData()).forEach(
({ id }) => (data[id] = Value.Wish),
)
;(await readVisitedCountriesData()).forEach(
({ id }) => (data[id] = Value.Visit),
)

const series = chart.series.push(
MapPolygonSeries.new(root, {
geoJSON: geodata,
Expand All @@ -127,9 +119,6 @@ export default function useChart(
key: 'fill',
},
])
series.data.setAll(
Object.entries(data).map(([id, value]) => ({ id, value })),
)

const { template } = series.mapPolygons
template.setAll({
Expand All @@ -147,6 +136,15 @@ export default function useChart(
setVisits({ action: isVisited ? 'remove' : 'add', id })
})

const data: { id: string; value: number }[] = []
;(await readWishedCountriesData()).forEach(({ id }) =>
data.push({ id, value: Value.Wish }),
)
;(await readVisitedCountriesData()).forEach(({ id }) =>
data.push({ id, value: Value.Visit }),
)
series.data.setAll(data)

chartRef.current = { root, chart, series }
})()

Expand Down

0 comments on commit 25e5c78

Please sign in to comment.