Skip to content

Commit

Permalink
fix(locationMap): colorpalette max index + infinite loading
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored and Mehdi-BOUYAHIA committed Jul 2, 2024
1 parent 416171c commit 4faf1fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/Dashboard/Preview/LocationMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
_explodeBoundsIntoMesh,
colorize,
computeNearFilter,
explodeBoundsIntoMesh,
isBoundCovered,
parseShape,
uncoveredBoundMeshUnits
Expand Down Expand Up @@ -162,6 +161,9 @@ const IrisZones = (props: IrisZonesProps) => {
)
// update the loaded bounds
setLoadedBounds((prevLoadedBounds) => {
if (prevLoadedBounds.some((b) => b.equals(bounds))) {
return prevLoadedBounds
}
return prevLoadedBounds.concat(bounds)
})

Expand Down
3 changes: 1 addition & 2 deletions src/components/Dashboard/Preview/LocationMap/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import L, { LatLngBounds, LatLngTuple } from 'leaflet'
import { map } from 'lodash'

/**
* Transform the string polygon description retrieved by FHIR (POLYGON((lat lng, lat lng, ...))) into an array of LatLngTuple
Expand Down Expand Up @@ -99,7 +98,7 @@ export const uncoveredBoundMeshUnits = (map: L.Map, bounds: LatLngBounds, loaded
export const colorize = (colorPalette: string[], count: number, maxCount: number): string => {
const step = maxCount / colorPalette.length
const colorIndex = Math.floor(count / step)
if (colorIndex > colorPalette.length) {
if (colorIndex >= colorPalette.length) {
return colorPalette[colorPalette.length - 1]
}
return colorPalette[colorIndex]
Expand Down

0 comments on commit 4faf1fc

Please sign in to comment.