// Alternate atlas views — Bar chart (descending) + Treemap (population-weighted).
// Each component receives the same props as the choropleth so the control bar
// can swap them without dragging different prop shapes.
{
const { LENSES, STATES, STATE_POPULATION, scoreFor, lensMetaFor } = window.PL_DATA;
const NAME_FOR = Object.fromEntries(STATES.map(s => [s[0], s[1]]));
// ============================================================================
// BAR CHART VIEW — sorted descending, all scored states
// ============================================================================
function BarChartView({ lensId, mode = "passed", onSelect, activeState }) {
// Only states with actual data for this lens
const rows = STATES
.map(s => s[0])
.filter(code => {
const meta = lensMetaFor && lensMetaFor(code, lensId);
return meta && meta.bill_count > 0;
})
.map(code => {
const meta = lensMetaFor(code, lensId);
return {
code,
name: NAME_FOR[code] || code,
score: scoreFor(code, lensId, mode),
bills: meta?.bill_count || 0,
passed: meta?.n_passed || 0,
};
})
.sort((a, b) => b.score - a.score);
if (rows.length === 0) {
return ;
}
return (
Sorted descending — {rows.length} states with data