Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Federal to Tax revenues when budgetary impacts are split out #672

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/api/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export function percent(number) {
);
}

export function formatPercentageChange(number) {
const changePercentage = (number * 100).toFixed(6);
const roundedPercentage = parseFloat(changePercentage);
const significantDigits = roundedPercentage.toPrecision(1);
return `${significantDigits}%`;
}

export function cardinal(number) {
// E.g. 1 -> 'first', 2 -> 'second', 3 -> 'third'
const suffixes = ["th", "st", "nd", "rd"];
Expand Down
2 changes: 1 addition & 1 deletion src/pages/policy/output/BudgetaryImpact.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function BudgetaryImpact(props) {
"Net impact",
];
let mobileLabels = ["Federal taxes", "State taxes", "Benefits", "Net"];
if (region !== "us" && region !== "ca") {
if (region == "us" || region == "ca") {
desktopLabels[0] = "Tax revenues";
mobileLabels[0] = "Taxes";
}
Expand Down
13 changes: 5 additions & 8 deletions src/pages/policy/output/InequalityImpact.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext } from "react";
import Plot from "react-plotly.js";
import { ChartLogo } from "../../../api/charts";
import { percent } from "../../../api/language";
import { percent, formatPercentageChange } from "../../../api/language";
import HoverCard, {HoverCardContext} from "../../../layout/HoverCard";
import useMobile from "../../../layout/Responsive";
import DownloadableScreenshottable from "./DownloadableScreenshottable";
Expand Down Expand Up @@ -39,12 +39,9 @@ export default function InequalityImpact(props) {
value < 0 ? style.colors.DARK_GREEN : style.colors.DARK_GRAY
),
},
text: metricChanges.map(
(value) =>
(value >= 0 ? "+" : "") +
(value * 100).toFixed(1).toString() +
"%"
),
text: metricChanges.map((value) => {
return formatPercentageChange(value);
}),
textangle: 0,
hoverinfo: "none",
},
Expand All @@ -58,7 +55,7 @@ export default function InequalityImpact(props) {
tickformat: ",.1%",
},
uniformtext: {
mode: "hide",
mode: "show",
minsize: 12,
},
...ChartLogo(mobile ? 0.97 : 0.97, mobile ? -0.25 : -0.15),
Expand Down
13 changes: 5 additions & 8 deletions src/pages/policy/output/PovertyImpact.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useEffect } from 'react';
import Plot from "react-plotly.js";
import { ChartLogo } from "../../../api/charts";
import { percent } from "../../../api/language";
import { percent, formatPercentageChange } from "../../../api/language";
import HoverCard, {HoverCardContext} from "../../../layout/HoverCard";
import useMobile from "../../../layout/Responsive";
import DownloadableScreenshottable from "./DownloadableScreenshottable";
Expand Down Expand Up @@ -61,12 +61,9 @@ export default function PovertyImpact(props) {
value < 0 ? style.colors.DARK_GREEN : style.colors.DARK_GRAY
),
},
text: povertyChanges.map(
(value) =>
(value >= 0 ? "+" : "") +
(value * 100).toFixed(1).toString() +
"%"
),
text: povertyChanges.map((value) => {
return formatPercentageChange(value);
}),
textangle: 0,
hoverinfo: "none",
},
Expand Down Expand Up @@ -134,7 +131,7 @@ export default function PovertyImpact(props) {
);
}

const povertyRateChange = percent(Math.abs(totalPovertyChange));
const povertyRateChange = formatPercentageChange(Math.abs(totalPovertyChange));
const percentagePointChange =
Math.round(
Math.abs(
Expand Down
Loading