Skip to content

Show ACS margins of error in the charts and tables - #179

Merged
duaneatat merged 7 commits into
mainfrom
db/acs-moe-frontend
Nov 11, 2026
Merged

duaneatat merged 7 commits into
mainfrom
db/acs-moe-frontend

Conversation

@duaneatat

@duaneatat duaneatat commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Third of three PRs for Census margins of error, after #177 (collection) and #178 (cleaning), both merged. The API now serves the margins and reliability labels, and the charts and tables show them: a shaded band around each line, a whisker on each bar, and "68,854 ± 4,182" in tooltips and tables. Low-reliability estimates get a hollow dot on charts and a "*" in tables, with a short note explaining both. Charts with no margins look as they did.

  • API: the tidy endpoints add Value_MOE, Value_Reliability, Percent_MOE and Percent_Reliability, and the time-series endpoints add <Field>_MOE and <Field>_Reliability. Both leave them out on a warehouse built before margins were collected, so the API can deploy before the ETL rerun.
  • Trend charts: bands, hollow dots for low reliability, and "±" in tooltips. Summed series such as 65+ combine their parts' margins by root sum of squares.
  • Bar charts: whiskers, plus error bars in the PDF version.
  • Comparison pages: the variable explorer's map tooltips read "65.2 ± 33.9" and its scatter shows hollow dots for low reliability; the DP explorer's trend chart gets bands and its value cards a "±" line; the county comparison's ranked bars get whiskers, with the labels moved above them.
  • Tables, including the demographics table and the PDF report's summary table: "value ± margin" cells, "*" for low reliability, and the margins in the Excel export.
  • Verified locally against a scratch 2009–2024 warehouse: Burlington's 2023 median household income reads $68,854 ± $4,182, and Granby's unemployment rate reads 0.0% ± 32.1%, flagged low. The comparison pages were checked against a warehouse copy with made-up margins.
  • Rollout: margins appear once just run-etl 2009 2024 (from Carry ACS margins of error through cleaning, with reliability labels #178) has run; until then everything looks as it does today.
image image image image image image image image image

The tidy endpoints add Value_MOE, Value_Reliability, Percent_MOE and
Percent_Reliability; the timeseries endpoints add <Field>_MOE and
<Field>_Reliability for the series that have margins. The frontend
doesn't read them yet.
Trend lines get a shaded band for the 90% margin of error, with hollow dots
on low-reliability estimates; the age and education distribution bars get
whiskers (error bars in the PDF version). Tooltips and table cells read
"value ± margin", with low reliability flagged, and the Excel exports carry
the margins. Intervals are clamped to 0 and, for shares, to 100%.
The tidy query now selects every column and keeps the margin fields only
where the warehouse has them, as the timeseries query already did, so the
API can deploy before the ETL rerun. The PDF report's summary table shows
margins, the low-reliability asterisk and the footnote, sharing the
on-screen table's cell formatting. Table footnotes explain only the cells
on screen, not hidden comparison values. Bar whisker headroom follows the
visible series, the PDF bar chart draws comparison whiskers when only the
comparison has margins, and a single-year trend keeps its dot.
Base automatically changed from db/acs-moe-cleaning to main November 3, 2026 13:50
The variable explorer's map tooltips and scatter, the DP explorer's trend
chart and value cards, and the county comparison's ranked bars now carry
margins and reliability labels. Each query adds the margin columns only where
the warehouse has them, so an older warehouse serves these pages as before.

@iansargent iansargent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frontend implementation of these values were exactly what I imagined. Bar graphs get error bars and time series charts get the shaded error bands.

The only thing I might request is if you think a show/hide toggle for margins of error (when applicable) would help the user from overcrowding the plot. The default could be switched on, but the user could have the ability to toggle MOEs off the chart/table.

What do you think about the feature? Would it be too many bells and whistles? Or good UI?

Lmk

@duaneatat

Copy link
Copy Markdown
Collaborator Author

I think it's a good idea! I noticed some charts the bands overlap and cover most of the chart. we can just default it enabled like you suggest.

A "Margins of error" switch on each chart card with margins, saved as one
setting for every chart and on by default. Hidden, charts drop their bands and
whiskers and tables their "± margin", but low-reliability estimates keep their
hollow dots and asterisks.
CI's fresh environment doesn't have it, so the test failed to load it.
@duaneatat
duaneatat requested a review from iansargent November 6, 2026 17:19

@iansargent iansargent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@duaneatat
duaneatat merged commit e58f7ab into main Nov 11, 2026
4 checks passed
@duaneatat
duaneatat deleted the db/acs-moe-frontend branch November 11, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants