From 531b3953d3c6fea068c517684f91c2466b4f5338 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 25 Oct 2024 18:52:53 +0200 Subject: [PATCH 1/2] fix: Hot-fix remove of invalid deciles in charts --- src/pages/policy/output/decile/AverageImpactByDecile.jsx | 8 ++++++++ src/pages/policy/output/decile/RelativeImpactByDecile.jsx | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/pages/policy/output/decile/AverageImpactByDecile.jsx b/src/pages/policy/output/decile/AverageImpactByDecile.jsx index e95e3b369..f8d54fc85 100644 --- a/src/pages/policy/output/decile/AverageImpactByDecile.jsx +++ b/src/pages/policy/output/decile/AverageImpactByDecile.jsx @@ -135,6 +135,14 @@ export function ImpactPlot(props) { export default function averageImpactByDecile(props) { const { impact, policyLabel, metadata, mobile, useHoverCard = false } = props; const decileAverage = impact.decile.average; + + // Hot fix to be removed to avoid deciles outside of 1-10 + Object.keys(decileAverage).map((key) => { + if (key > 10 || key < 1) { + delete decileAverage[key]; + } + }); + const averageChange = -impact.budget.budgetary_impact / impact.budget.households; const chart = ( diff --git a/src/pages/policy/output/decile/RelativeImpactByDecile.jsx b/src/pages/policy/output/decile/RelativeImpactByDecile.jsx index be46a882e..8967ba5a3 100644 --- a/src/pages/policy/output/decile/RelativeImpactByDecile.jsx +++ b/src/pages/policy/output/decile/RelativeImpactByDecile.jsx @@ -126,6 +126,14 @@ export function ImpactPlot(props) { export default function relativeImpactByDecile(props) { const { impact, policyLabel, metadata, mobile, useHoverCard = false } = props; const decileRelative = impact.decile.relative; + + // Hot fix to be removed to avoid deciles outside of 1-10 + Object.keys(decileRelative).map((key) => { + if (key > 10 || key < 1) { + delete decileRelative[key]; + } + }); + const relativeChange = -impact.budget.budgetary_impact / impact.budget.baseline_net_income; const chart = ( From 9303a1d36b0754be76d3c984e1c23573950b6f6f Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 25 Oct 2024 18:56:49 +0200 Subject: [PATCH 2/2] chore: Lint --- src/pages/policy/output/decile/AverageImpactByDecile.jsx | 2 +- src/pages/policy/output/decile/RelativeImpactByDecile.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/policy/output/decile/AverageImpactByDecile.jsx b/src/pages/policy/output/decile/AverageImpactByDecile.jsx index f8d54fc85..2f7dca330 100644 --- a/src/pages/policy/output/decile/AverageImpactByDecile.jsx +++ b/src/pages/policy/output/decile/AverageImpactByDecile.jsx @@ -137,7 +137,7 @@ export default function averageImpactByDecile(props) { const decileAverage = impact.decile.average; // Hot fix to be removed to avoid deciles outside of 1-10 - Object.keys(decileAverage).map((key) => { + Object.keys(decileAverage).forEach((key) => { if (key > 10 || key < 1) { delete decileAverage[key]; } diff --git a/src/pages/policy/output/decile/RelativeImpactByDecile.jsx b/src/pages/policy/output/decile/RelativeImpactByDecile.jsx index 8967ba5a3..bd873d347 100644 --- a/src/pages/policy/output/decile/RelativeImpactByDecile.jsx +++ b/src/pages/policy/output/decile/RelativeImpactByDecile.jsx @@ -128,7 +128,7 @@ export default function relativeImpactByDecile(props) { const decileRelative = impact.decile.relative; // Hot fix to be removed to avoid deciles outside of 1-10 - Object.keys(decileRelative).map((key) => { + Object.keys(decileRelative).forEach((key) => { if (key > 10 || key < 1) { delete decileRelative[key]; }