diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c594c73..24596847 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
-## [Unreleased]
+## [0.5.1] - 2023-05-30
+
+### Changed
+
+- Change the format of negative values in landing page maps' tips and legend bar to fit client's request
+- Modify the title of each map's tip to match each program
## [0.5.0] - 2023-05-26
@@ -90,6 +95,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Map data json [#12](https://github.com/policy-design-lab/pdl-frontend/issues/12)
- Final landing page changes for initial milestone [#15](https://github.com/policy-design-lab/pdl-frontend/issues/15)
-[unreleased]: https://github.com/policy-design-lab/pdl-frontend/compare/0.5.0...HEAD
+[0.5.1]: https://github.com/policy-design-lab/pdl-frontend/compare/0.5.0...0.5.1
[0.5.0]: https://github.com/policy-design-lab/pdl-frontend/compare/0.4.0...0.5.0
-[0.4.0]: https://github.com/policy-design-lab/pdl-frontend/tag/0.4.0
+[0.4.0]: https://github.com/policy-design-lab/pdl-frontend/compare/0.3.0...0.4.0
+[0.3.0]: https://github.com/policy-design-lab/pdl-api/releases/tag/0.3.0
diff --git a/package-lock.json b/package-lock.json
index 59da62f3..99ebd067 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "policy-design-lab",
- "version": "0.5.0",
+ "version": "0.5.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
diff --git a/package.json b/package.json
index b86e71a2..3cd05038 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "policy-design-lab",
- "version": "0.5.0",
+ "version": "0.5.1",
"description": "the front end of policy design lab",
"repository": "https://github.com/policy-design-lab/pdl-frontend",
"main": "src/app.tsx",
diff --git a/src/components/LandingPageMap.tsx b/src/components/LandingPageMap.tsx
index 09484026..64e74db0 100644
--- a/src/components/LandingPageMap.tsx
+++ b/src/components/LandingPageMap.tsx
@@ -211,11 +211,17 @@ const MapChart = (props) => {
)}
- $
- {Number(total / 1000000.0).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ {Math.round(Number(total / 1000000.0)) >= 0
+ ? `$${Number(
+ Math.abs(total) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(total) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
{/* Show additional data on hover for SNAP */}
@@ -239,26 +245,62 @@ const MapChart = (props) => {
-
- Payments:
-
- {records.map((record) => (
-
- {record["Fiscal Year"]}: $
- {Number(record.Amount / 1000000.0).toLocaleString(
- undefined,
- { maximumFractionDigits: 2 }
- )}
- M
-
- ))}
-
+ {title ===
+ "Supplemental Nutrition Assistance Program (SNAP)" ? (
+
+ Costs:
+
+ {records.map((record) => (
+
+ {record["Fiscal Year"]}:{" "}
+ {Number(record.Amount / 1000000.0) >= 0
+ ? `$${Number(
+ Math.abs(record.Amount) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(record.Amount) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
+
+ ))}
+
+ ) : (
+
+ {title === "Crop Insurance" ? "Benefits:" : "Payments:"}
+
+ {records.map((record) => (
+
+ {record["Fiscal Year"]}:{" "}
+ {Number(record.Amount / 1000000.0) >= 0
+ ? `$${Number(
+ Math.abs(record.Amount) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(record.Amount) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
+
+ ))}
+
+ )}
) : (
@@ -276,11 +318,17 @@ const MapChart = (props) => {
Total Benefit
- $
- {Number(total / 1000000.0).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ {Math.round(Number(total / 1000000.0)) >= 0
+ ? `$${Number(
+ Math.abs(total) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(total) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
@@ -290,45 +338,90 @@ const MapChart = (props) => {
{records.map((record) => (
- 2018: $
- {Number(
- record["2018 All Programs Total"] / 1000000.0
- ).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ 2018:{" "}
+ {record["2018 All Programs Total"] / 1000000.0 >= 0
+ ? `$${Number(
+ Math.abs(
+ record["2018 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(
+ record["2018 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
- 2019: $
- {Number(
- record["2019 All Programs Total"] / 1000000.0
- ).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ 2019:{" "}
+ {record["2019 All Programs Total"] / 1000000.0 >= 0
+ ? `$${Number(
+ Math.abs(
+ record["2019 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(
+ record["2019 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
- 2020: $
- {Number(
- record["2020 All Programs Total"] / 1000000.0
- ).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ 2020:{" "}
+ {record["2020 All Programs Total"] / 1000000.0 >= 0
+ ? `$${Number(
+ Math.abs(
+ record["2020 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(
+ record["2020 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
- 2021: $
- {Number(
- record["2021 All Programs Total"] / 1000000.0
- ).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ 2021:{" "}
+ {record["2021 All Programs Total"] / 1000000.0 >= 0
+ ? `$${Number(
+ Math.abs(
+ record["2021 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(
+ record["2021 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
- 2022: $
- {Number(
- record["2022 All Programs Total"] / 1000000.0
- ).toLocaleString(undefined, {
- maximumFractionDigits: 2
- })}
- M
+ 2022:{" "}
+ {record["2022 All Programs Total"] / 1000000.0 >= 0
+ ? `$${Number(
+ Math.abs(
+ record["2022 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`
+ : `-$${Number(
+ Math.abs(
+ record["2022 All Programs Total"]
+ ) / 1000000.0
+ ).toLocaleString(undefined, {
+ maximumFractionDigits: 2
+ })}M`}
))}
diff --git a/src/components/shared/DrawLegend.tsx b/src/components/shared/DrawLegend.tsx
index eefb9d39..9df76734 100644
--- a/src/components/shared/DrawLegend.tsx
+++ b/src/components/shared/DrawLegend.tsx
@@ -110,9 +110,11 @@ export default function DrawLegend({
return i === 0 ? d : d - margin / 4;
})
.text((d, i) => {
- return i === 0
- ? `$${ShortFormat(Math.round(cut_points[i]), i)}`
- : ShortFormat(Math.round(cut_points[i]), i);
+ if (i === 0) {
+ const res = ShortFormat(Math.round(cut_points[i]), i);
+ return res.indexOf("-") < 0 ? `${res}` : `-$${res.substring(1)}`;
+ }
+ return ShortFormat(Math.round(cut_points[i]), i);
});
} else {
baseSVG
@@ -129,9 +131,11 @@ export default function DrawLegend({
return i === 0 ? d : d - margin / 4;
})
.text((d, i) => {
- return i === 0
- ? `$${ShortFormat(Math.round(cut_points[i]), i)}`
- : ShortFormat(Math.round(cut_points[i]), i);
+ if (i === 0) {
+ const res = ShortFormat(Math.round(cut_points[i]), i);
+ return res.indexOf("-") < 0 ? `${res}` : `-$${res.substring(1)}`;
+ }
+ return ShortFormat(Math.round(cut_points[i]), i);
});
}
if (emptyState.length !== 0) {