+ {allStates.length > 0 && statePerformance[year] !== undefined ? (
+
+
+ {({ geographies }) => (
+ <>
+ {geographies.map((geo) => {
+ const record = statePerformance[year].filter(
+ (v) => v.state === geo.properties.name
+ )[0];
+ if (record === undefined || record.length === 0) {
+ return null;
+ }
+ const totalPaymentInDollars = record.programs[0].assistancePaymentInDollars;
+ const assistancePaymentInPercentageNationwide =
+ record.programs[0].assistancePaymentInPercentageNationwide;
+ const hoverContent = (
+
+
+ {geo.properties.name}
+
+
+ {Number(totalPaymentInDollars) < 1000000
+ ? `$${Number(
+ Number(totalPaymentInDollars) / 1000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}K`
+ : `$${Number(
+ Number(totalPaymentInDollars) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
+
+
+
+ {assistancePaymentInPercentageNationwide
+ ? `${assistancePaymentInPercentageNationwide} %`
+ : "0%"}
+
+
+
+
+ );
+ const fillColour = () => {
+ if (totalPaymentInDollars) {
+ if (totalPaymentInDollars !== 0) return colorScale(totalPaymentInDollars);
+ return "#D2D2D2";
+ }
+ return "#D2D2D2";
+ };
+ return (
+ {
+ setTooltipContent(hoverContent);
+ }}
+ onMouseLeave={() => {
+ setTooltipContent("");
+ }}
+ fill={fillColour()}
+ stroke="#FFF"
+ style={{
+ default: { stroke: "#FFFFFF", strokeWidth: 0.75, outline: "none" },
+ hover: {
+ stroke: "#232323",
+ strokeWidth: 2,
+ outline: "none"
+ },
+ pressed: {
+ fill: "#345feb",
+ outline: "none"
+ }
+ }}
+ />
+ );
+ })}
+ {geographies.map((geo) => {
+ const centroid = geoCentroid(geo);
+ const cur = allStates.find((s) => s.val === geo.id);
+ return (
+
+ {cur &&
+ centroid[0] > -160 &&
+ centroid[0] < -67 &&
+ (Object.keys(offsets).indexOf(cur.id) === -1 ? (
+
+
+ {cur.id}
+
+
+ ) : (
+
+
+ {cur.id}
+
+
+ ))}
+
+ );
+ })}
+ >
+ )}
+
+
+ ) : (
+
+ Loading Map Data...
+
+ )}
+
+ );
+};
+
+MapChart.propTypes = {
+ setTooltipContent: PropTypes.func
+};
+
+const ACEPTotalMap = ({
+ program,
+ attribute,
+ year,
+ statePerformance,
+ stateCodes,
+ allStates
+}: {
+ program: string;
+ attribute: any;
+ year: string;
+ statePerformance: any;
+ stateCodes: any;
+ allStates: any;
+}): JSX.Element => {
+ const [content, setContent] = useState("");
+ const quantizeArray: number[] = [];
+ const zeroPoints = [];
+ statePerformance[year].forEach((value) => {
+ const programRecord = value.programs;
+ const ACur = programRecord.find((s) => s.programName === program);
+ const key = "assistancePaymentInDollars";
+ quantizeArray.push(ACur[key]);
+ ACur[key] === 0 && zeroPoints.push(value.state);
+ return null;
+ });
+ const category = "Total ACEP";
+ const years = "2018-2022";
+ const maxValue = Math.max(...quantizeArray);
+ const mapColor = ["#F0F9E8", "#BAE4BC", "#7BCCC4", "#43A2CA", "#0868AC"];
+ const customScale = legendConfig[category];
+ const colorScale = d3.scaleThreshold(customScale, mapColor);
+ return (
+