Add D3 and new ridgeline chart matching R aesthetic
Deploy to git-pages / deploy (push) Successful in 19s
Deploy to git-pages / deploy (push) Successful in 19s
- Install d3@7 - Add fetchDistrictDraws API function (for future use with raw draws) - Create RateDensityRidgeline component using D3.js - Density ridges showing posterior distributions per race group - Diamond markers for observed rates (matching R design) - Dropdown to switch between model specifications - Matches Civilytics color palette (navy fill, danger diamonds)
This commit is contained in:
@@ -134,3 +134,15 @@ export async function fetchDrawLocation(state, race, sex, year, model) {
|
||||
|
||||
return apiFetch(`/draws?${params}`)
|
||||
}
|
||||
|
||||
/** GET /estimates/{leaid}/draws?model=X&year=Y — fetch posterior draws for a district */
|
||||
export async function fetchDistrictDraws(leaid, options = {}) {
|
||||
const params = new URLSearchParams()
|
||||
if (options.model) params.set('model', options.model)
|
||||
if (options.year) params.set('year', options.year)
|
||||
if (options.race) params.set('race', options.race)
|
||||
if (options.sex) params.set('sex', options.sex)
|
||||
|
||||
const qs = params.toString()
|
||||
return apiFetch(`/estimates/${leaid}/draws${qs ? `?${qs}` : ''}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user