Would the numbers be more relatable if displayed in terms of dollars per paycheck?
I wonder if the percentages and dollar amounts would be more relatable if displayed in terms of dollars out of the user's paycheck. We could add a quick to add a way for users to enter the amount they make, or the taxes they pay, then adjust the numbers accordingly. Showing someone that a particular budget item translates to $50 out of their paycheck is much more relatable than numbers in the billions.
I threw together the following so I could see those numbers for myself. To use it:
- Load any
/explorerurl (ex: by budget function) - Copy/paste the following code the browser console and hit enter
- Change the new dropdown to the left of the "show results" buttons to "Tax Dollars Paid"
- Enter the amount of taxes you pay (likely per paycheck, but you could do per month or year)
- See the updated numbers below
const buttons = document.querySelector('.view-buttons')
const container = document.createElement('div')
container.style = 'display: inline-block; margin-right: 30px'
container.innerHTML = `
<label>See amounts by: </label>
<select id='amount-type'>
<option value='percentage'>Percentage</option>
<option value='dollars'>Tax Dollars Paid</option>
</select>
`
container.addEventListener('change', (event) => {
const mode = event.target.value
let dollars
if(mode === 'dollars'){
dollars = prompt('Enter the amount in dollars that you pay in taxes that you would like to see broken down (ex: per month or year):')
// String non-numeric chars
dollars = dollars.replace(/\D/g,'')
}
document.querySelectorAll('.explorer-cell-value').forEach((element) => {
const attributeName = 'data-percent'
let percent = element.getAttribute(attributeName)
if(percent === null){
percent = element.innerHTML.slice(0, -1)
element.setAttribute(attributeName, percent)
}
let value
if(mode === 'dollars'){
value = '$' + (dollars*percent/100)
}
else{
value = percent + '%'
}
element.innerHTML = value
})
})
buttons.prepend(container)
What are your thoughts?
Very cool stuff! Thanks for your interest (and for teaching me a new way to add elements to a page at runtime). I'll pass this around to the rest of the team to see what ideas/concerns it might spark, but personally I see no problems with the concept.
Right now the USAspending team is hard at work bringing users data related to the new spending from things like the CARES act, so if you really want to see this on the website one day and have the time to dedicate to it, a full pull request would greatly increase your chances of success.
Update: we found a bug in the math: because the percentages are from the total spending of that page rather than of the government itself, this will result in values too high once a user actually dives in to one of the budget functions or agencies or whatever. This logic would need to change to always base off of the government's total (which I'm sure is in the store somewhere, since we show it on the page).
Thanks very much for the quick feedback. I started down the road of a PR before making the above hack, but npm start is failing for me with a compilation issue that I'm not sure if I can justify the time to troubleshoot. Since it seems like you like the idea in general, I'll see if I can devote a little more time to it.
Hello -- seems that this is the only active thread of 2020!
I was wondering how to get attention on a query/topic I posted 10 days ago "Mapping FPDS Set-Asides to USA Spending Set-Asides #1730". Are there other means to get a response, besides posting an issue? Thanks!
@lisaam "We can suggest this are story for the Data Lab to look at." -- yes, can you please?