-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add choropleth map for disadvantaged communities
- Loading branch information
1 parent
aa81341
commit 337940d
Showing
9 changed files
with
134 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useCallback } from 'react'; | ||
import StatesLayer from '../StatesLayer'; | ||
import { | ||
StateFeature, | ||
StatesLayer as StatesLayerType, | ||
} from '../../types/states'; | ||
|
||
import MapLegend from '../MapLegend'; | ||
import UsaMapContainer from '../UsaMapContainer'; | ||
import * as disadvantagedTractsJson from '../../data/disadvantagedTracts.json'; | ||
import { QUARTILE_CATEGORIES, STATE_STYLE_BASE } from '../../constants'; | ||
import { getAmountCategory } from '../../util'; | ||
|
||
const disadvantagedTracts = Array.from(disadvantagedTractsJson); | ||
|
||
export function EquityMap() { | ||
const onEachFeature = useCallback( | ||
(feature: StateFeature, layer: StatesLayerType) => { | ||
const disadvantagedPopulationSums = disadvantagedTracts.find( | ||
datum => datum['State'] === feature.properties.NAME | ||
); | ||
if (disadvantagedPopulationSums === undefined) { | ||
return; | ||
} | ||
const proportionDisadvantaged = | ||
Number.parseInt(disadvantagedPopulationSums.Disadvantaged) / | ||
Number.parseInt(disadvantagedPopulationSums.Total); | ||
layer.setStyle({ | ||
fillColor: getAmountCategory( | ||
proportionDisadvantaged, | ||
QUARTILE_CATEGORIES | ||
).color, | ||
}); | ||
layer.on('mouseover', () => { | ||
layer.setStyle({ weight: 2 }); | ||
}); | ||
layer.on('mouseout', () => { | ||
layer.setStyle({ | ||
weight: STATE_STYLE_BASE.weight, | ||
}); | ||
}); | ||
}, | ||
[] | ||
); | ||
|
||
return ( | ||
<> | ||
<div style={{ height: 125 }} /> | ||
<UsaMapContainer negativeMargin> | ||
<StatesLayer onEachFeature={onEachFeature} /> | ||
</UsaMapContainer> | ||
<MapLegend | ||
categories={QUARTILE_CATEGORIES} | ||
label='Population in disadvantaged communities' | ||
monetary={false} | ||
/> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EquityMap } from './EquityMap'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters