Set ticks on y axis to -£100 instead of £-100 #820
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #148.
Strategy for fix
The Plotly locale en does not have the correct currency symbol "£". Ideally, Plotly should manage locales (in particular, currency) properly. However, since PolicyEngine only supports two locales, I have re-registered the two locales with the correct currency symbols in PolicyEngine.
Tests
I have tested four policy outputs (AverageImpactByDecile, AverageImpactByWealthDecile, BudgetaryImpact, DetailedBudgetaryImpact) for two locales (us, UK) and a couple of policy inputs to check that negative currencies are displayed properly.
🤖 Generated by Copilot at 9391f67
Summary
🌐💰📊
This pull request improves the currency and locale formatting of the Plotly charts in the PolicyEngine app. It adds new functions
currencyString
andlocaleString
to thelanguage.js
module, and uses them in various chart components. It also adds new locale fileslocale-en.js
andlocale-en-us.js
to theplotly_locales
folder, and supports them in thePolicyEngine.jsx
component. Additionally, it fixes some ESLint issues and adds an optional chaining operator to theTextBox.jsx
file.Walkthrough
currencyString
andlocaleString
functions tolanguage.js
module to standardize currency and locale formatting (link)currencyString
function to format text values on chart bars and hover cards inAverageImpactByDecile.jsx
andAverageImpactByWealthDecile.jsx
(link, link, link, link, link, link, link, link, link, link, link, link, link, link)localeString
function to set locale for charts inAverageImpactByDecile.jsx
,AverageImpactByWealthDecile.jsx
,BudgetaryImpact.jsx
, andDetailedBudgetaryImpact.jsx
(link, link, link, link)maximumFractionDigits
parameter informatVariableValue
function calls (link, link, link, link, link, link, link, link, link, link, link, link)tickprefix
property from y-axis configuration of charts (link, link, link, link)aggregateCurrency
function to format text values on chart bars and hover cards inBudgetaryImpact.jsx
andDetailedBudgetaryImpact.jsx
(link, link, link, link)locale-en-us.js
andlocale-en.js
files toplotly_locales
folder to define locale settings for US and UK English (link, link)loc_en
andloc_en_us
modules with Plotly library inPolicyEngine.jsx
(link, link)onChange
prop ofinput
element inTextBox.jsx
(link)