/* Member profile ("bio") view. Route: #m-. Data: bios.json (one record per member), cd116/cd118/cd119.json (district outlines). Shares helpers defined in index.html: $, esc, pct, usdS, tit, SHORT, PTEXT, KIND, ABBR, topo. */ let BIOS = null, BIO_CUR = null, BIO_C = null; const SHAPES = {}; const PARTY = {D: "Democrat", R: "Republican", I: "Independent"}; const STATE_NAME = {AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"}; const ORD = n => { n = +n; const s = ["th","st","nd","rd"], v = n % 100; return n + (s[(v - 20) % 10] || s[v] || s[0]); }; const posLabel = id => SHORT[id] || (PTEXT[id] ? PTEXT[id][0] : id); const loadBios = () => BIOS ? Promise.resolve(BIOS) : fetch("bios.json").then(r => r.json()).then(d => (BIOS = d)); const shapeFile = c => (+c >= 119 ? "cd119" : +c === 118 ? "cd118" : +c === 115 ? "cd115" : "cd116"); const loadShape = n => SHAPES[n] ? Promise.resolve(SHAPES[n]) : fetch(n + ".json").then(r => r.json()).then(d => (SHAPES[n] = d)); function seatLabel(c) { if (c.chamber === "Senate") return "Senator, " + (STATE_NAME[c.state] || c.state); const d = +c.district; return (STATE_NAME[c.state] || c.state) + (d === 0 || (c.geo || "").endsWith("00") ? " at-large" : "'s " + ORD(d) + " district"); } const seatShort = c => c.chamber === "Senate" ? c.state + " Senate" : c.state + "-" + ((c.geo || "").endsWith("00") ? "AL" : +c.district); function routeBio() { const h = location.hash.slice(1); const on = h.startsWith("m-"); $("#bio").hidden = !on; document.querySelector(".app").classList.toggle("bio-on", on); if (!on) { if (typeof layout === "function" && topo) requestAnimationFrame(layout); return; } const id = h.slice(2); $("#bio").innerHTML = '

Loading the profile

'; loadBios().then(() => { if (!BIOS.members[id]) { $("#bio").innerHTML = '
← Back to the map

No scored record for this member.

'; return; } BIO_CUR = id; const cs = Object.keys(BIOS.members[id].congresses).sort(); BIO_C = cs[cs.length - 1]; renderBio(); $("#bio").scrollTop = 0; window.scrollTo(0, 0); }).catch(() => { $("#bio").innerHTML = '
← Back to the map

Could not load the profile data. Reload to try again.

'; }); } window.addEventListener("hashchange", routeBio); function renderBio() { const R = BIOS.members[BIO_CUR], cs = Object.keys(R.congresses).sort(), C = R.congresses[BIO_C]; const first = (R.terms || []).filter(t => t[0] === "rep" || t[0] === "sen").map(t => t[1]).sort()[0]; const avgKey = C.chamber + "-" + C.party, avg = (BIOS.party_avg[BIO_C] || {})[avgKey]; const o = R.outside, tr = R.trades, ct = R.courts; const nCases = ct ? ct.cases.length : null; let h = '
'; h += ''; h += '

' + esc(R.name || BIO_CUR) + '

'; h += '

' + PARTY[C.party] + ', ' + esc(seatLabel(C)) + (first ? '. In Congress since ' + first.slice(0, 4) : '') + (R.born ? '. Born ' + R.born : '') + '.

'; h += '
' + cs.map(c => { const x = R.congresses[c]; return ''; }).join("") + '
'; h += '
'; // tiles const tile = (k, v, cap, cls) => '
' + k + '' + v + '' + cap + '
'; h += '
' + tile(C.chamber === "Senate" ? "Against their state" : "Against their district", pct(C.gap), C.against + " of " + C.n + " counted votes (narrower or bundled bills count half; averaged by issue), " + ORD(BIO_C) + " Congress", "hot") + tile("Their party's average", avg == null ? "n/a" : pct(avg), PARTY[C.party] + "s in the " + C.chamber + ", same votes") + tile("Outside money", o ? usdS(o.sup) + ' for' : "none", o ? usdS(o.opp) + " against, 2018 to 2026" : "no independent spending reported") + tile("Stock trades", tr ? tr.trades.toLocaleString("en-US") : "0", tr ? (tr.late ? tr.late + " filed late (estimate)" : "since 2019") : "no reports found since 2019") + tile("Federal court records", ct ? String(nCases) : "pending", ct ? "name matches in their state, D.C. or appeals courts" : "search still running (" + BIOS.courts_searched + " members done)") + '
'; // sections h += sec("gap", "Against their district, Congress by Congress", "Share of counted votes that went against what most of their constituents are estimated to want, with a 95% range. Ticks show each party's average in the same chamber.", '
'); h += sec("votes", "Every scored vote", "Each dot is one counted vote, placed by date and by how much of their " + (C.chamber === "Senate" ? "state" : "district") + " is estimated to support the position. Filled dots went against that majority.", '
'); h += sec("opinion", "What their " + (C.chamber === "Senate" ? "state" : "district") + " thinks", "Cooperative Election Study estimates for the area they represented in the " + ORD(BIO_C) + " Congress, next to the national figure. Estimates lean toward the state average, so treat gaps of a few points as noise.", '
'); h += sec("money", "Money around them", "Independent spending by super PACs, parties and outside groups in their races, by election cycle, and the political action committees that gave to them directly.", '
'); h += sec("trades", "Stock trades they disclosed", "Transactions on periodic transaction reports filed with the House Clerk or Senate since 2019. Scanned paper reports are not counted.", '
'); h += sec("courts", "Federal court records naming them", "Dockets from CourtListener's RECAP archive where a party's name matches theirs, in their state, D.C. or an appeals court, placed against their time in office.", '
'); if (R.signed || BIO_C === "119") h += sec("signed", "Bills they signed", "Positions with majority support that have a matching 119th Congress bill in their chamber, and whether they sponsored or cosponsored one.", '
'); h += '
Behind the numbers
' + '

Votes count when a roll call matches a position at least 66% of adults support nationally, in a survey close in time to the vote, under written selection rules (screen logs and reasons are public in the project folder). Each vote is compared with the estimated majority in the member\'s own district or state; votes where the estimate is within 3 points of 50% are skipped. Partial matches count half. Positions are averaged so one issue cannot dominate.

' + '

District estimates shift the national figure by how the place differs from the nation on a matching Cooperative Election Study question, or else by its mix of Democrats, Republicans and others. Outside money: FEC independent expenditures, amendments applied, approximate. Stock trades: parsed electronic filings; "late" means the trade was reported more than 45 days after it happened. Court records are name matches, not verified identities; criminal and bankruptcy matches are held back for review.

' + '

Every vote match was re-checked by a second reviewer who did not see the vote counts; the two agreed on 95% of decisions. Votes the reviewer could not settle are marked for review. All figures are a draft until the first public release.

'; h += '
'; $("#bio").innerHTML = h; document.querySelectorAll("#bio .bchips button").forEach(b => b.onclick = () => { BIO_C = b.dataset.bc; renderBio(); }); miniMap(R, C); chGap(R); chVotes(R, C); chOpinion(R, C); chMoney(R); chTrades(R); chCourts(R); tbSigned(R, C); } const sec = (id, title, sub, body) => '

' + title + '

' + sub + '

' + body + '
'; const W_ = el => Math.max(300, Math.min(1080, el.getBoundingClientRect().width || 900)); const svgEl = (el, w, h, label) => d3.select(el).append("svg").attr("viewBox", "0 0 " + w + " " + h).attr("role", "img").attr("aria-label", label).attr("class", "bchart"); function miniMap(R, C) { const svg = d3.select("#bmap"), W = 260, H = 200; svg.attr("viewBox", "0 0 " + W + " " + H); const f = stFips[C.state]; if (!f || !topo) return; const stateF = topojson.feature(topo, topo.objects.states).features.find(s => s.id === f); const proj = d3.geoAlbersUsa(), p = d3.geoPath(proj); if (C.chamber === "Senate") { proj.fitExtent([[8, 8], [W - 8, H - 8]], stateF); svg.append("path").attr("d", p(stateF)).attr("class", "mm-on"); $("#bmapcap").textContent = STATE_NAME[C.state] || C.state; return; } const n = shapeFile(BIO_C); loadShape(n).then(t => { const fs = topojson.feature(t, t.objects[n]).features.filter(x => x.properties.g.slice(0, 2) === f); const me = fs.find(x => x.properties.g === C.geo) || fs.find(x => x.properties.g.endsWith(String(C.district).padStart(2, "0"))); proj.fitExtent([[8, 8], [W - 8, H - 8]], stateF || {type: "FeatureCollection", features: fs}); svg.selectAll("path.mm").data(fs).join("path").attr("class", d => d === me ? "mm mm-on" : "mm").attr("d", p); if (stateF) svg.append("path").attr("d", p(stateF)).attr("class", "mm-st"); $("#bmapcap").textContent = seatShort(C) + ", district lines used in the " + ORD(BIO_C) + " Congress"; }).catch(() => { $("#bmapcap").textContent = seatShort(C); }); } function chGap(R) { const el = $("#ch-gap"), w = W_(el), h = 240, m = {l: 44, r: 16, t: 14, b: 34}; const cs = ["116", "117", "118", "119"]; const x = d3.scaleBand().domain(cs).range([m.l, w - m.r]).padding(.38), y = d3.scaleLinear().domain([0, 1]).range([h - m.b, m.t]); const s = svgEl(el, w, h, "Share of votes against their district by Congress"); [0, .25, .5, .75, 1].forEach(v => { s.append("line").attr("x1", m.l).attr("x2", w - m.r).attr("y1", y(v)).attr("y2", y(v)).attr("class", "grid"); s.append("text").attr("x", m.l - 6).attr("y", y(v) + 3.5).attr("text-anchor", "end").attr("class", "ax").text(v * 100 + "%"); }); cs.forEach(c => { const C = R.congresses[c], cx = x(c), bw = x.bandwidth(); s.append("text").attr("x", cx + bw / 2).attr("y", h - 12).attr("text-anchor", "middle").attr("class", "ax").text(ORD(c)); const av = BIOS.party_avg[c] || {}; if (!C) { s.append("text").attr("x", cx + bw / 2).attr("y", y(.06)).attr("text-anchor", "middle").attr("class", "ax dim").text("not scored"); return; } s.append("rect").attr("x", cx).attr("width", bw).attr("y", y(C.gap)).attr("height", Math.max(1, y(0) - y(C.gap))).attr("class", c === BIO_C ? "bar on" : "bar").append("title").text(ORD(c) + " Congress: " + pct(C.gap) + " against (" + C.against + " of " + C.n + " votes)"); s.append("line").attr("x1", cx + bw / 2).attr("x2", cx + bw / 2).attr("y1", y(C.lo)).attr("y2", y(C.hi)).attr("class", "whisk"); s.append("text").attr("x", cx + bw + 4).attr("y", y(C.gap) + 4).attr("text-anchor", "start").attr("class", "val").text(pct(C.gap)); ["D", "R"].forEach(p => { const v = av[C.chamber + "-" + p]; if (v == null) return; s.append("line").attr("x1", cx - 6).attr("x2", cx + bw + 6).attr("y1", y(v)).attr("y2", y(v)).attr("class", "tick " + p).append("title").text(PARTY[p] + "s' average, " + C.chamber + ": " + pct(v)); }); }); el.insertAdjacentHTML("beforeend", '
This memberDemocrats\' averageRepublicans\' averageLine: 95% range from the number of votes
'); } function allVotes(R) { const out = []; Object.entries(R.congresses).forEach(([c, C]) => C.votes.forEach(v => { const t = (BIOS.tests[c] || {})[v[0]]; if (!t) return; out.push({c, ch: C.chamber, key: v[0], vote: v[1], against: !!v[2], est: v[3], review: !!v[4], date: t[0], bill: t[1], q: t[2], pos: t[3], match: t[4], side: t[5], anchor: t[6], aligned: t[7], url: t[10], oroll: t[11], sess: t[12]}); })); return out.sort((a, b) => a.date < b.date ? 1 : -1); } function chVotes(R, C) { const V = allVotes(R), el = $("#ch-votes"); if (!V.length) { el.innerHTML = '

No counted votes.

'; return; } const w = W_(el), h = 300, m = {l: 48, r: 16, t: 16, b: 34}; const pd = d3.timeParse("%Y-%m-%d"); const x = d3.scaleTime().domain([pd("2017-01-03"), pd("2027-01-03")]).range([m.l, w - m.r]); const y = d3.scaleLinear().domain([.45, 1]).range([h - m.b, m.t]); const s = svgEl(el, w, h, "Counted votes by date and estimated local support"); [.5, .6, .7, .8, .9, 1].forEach(v => { s.append("line").attr("x1", m.l).attr("x2", w - m.r).attr("y1", y(v)).attr("y2", y(v)).attr("class", v === .5 ? "grid mid" : "grid"); s.append("text").attr("x", m.l - 6).attr("y", y(v) + 3.5).attr("text-anchor", "end").attr("class", "ax").text(v * 100 + "%"); }); const CST = {"115": ["2017-01-03", "2019-01-03"], "116": ["2019-01-03", "2021-01-03"], "117": ["2021-01-03", "2023-01-03"], "118": ["2023-01-03", "2025-01-03"], "119": ["2025-01-03", "2027-01-03"]}[BIO_C]; if (CST) s.append("rect").attr("x", x(pd(CST[0]))).attr("width", x(pd(CST[1])) - x(pd(CST[0]))).attr("y", m.t).attr("height", h - m.b - m.t).attr("class", "term"); [["2017-01-03", "115th"], ["2019-01-03", "116th"], ["2021-01-03", "117th"], ["2023-01-03", "118th"], ["2025-01-03", "119th"]].forEach(([d, l]) => { s.append("line").attr("x1", x(pd(d))).attr("x2", x(pd(d))).attr("y1", m.t).attr("y2", h - m.b).attr("class", "grid"); s.append("text").attr("x", x(pd(d)) + 4).attr("y", h - 12).attr("class", "ax").text(l + " Congress"); }); s.append("text").attr("x", m.l).attr("y", m.t - 4).attr("class", "ax").text("estimated local support for the position"); const seen = {}; V.forEach(v => { const d = pd(v.date); if (!d) return; const k = v.date + (v.est || 0).toFixed(2); const j = (seen[k] = (seen[k] || 0) + 1) - 1; const cy = y(v.est == null ? .47 : v.est) - j * 7; const g = s.append("circle").attr("cx", x(d)).attr("cy", cy).attr("r", 5.5).attr("class", "vd" + (v.review ? " rv" : v.against ? " ag" : " ok") + (v.c === BIO_C ? "" : " other")); g.append("title").text(v.date + " \u00b7 " + v.bill + ": " + v.q + "\nPosition: " + posLabel(v.pos) + "\nVoted " + v.vote + (v.review ? " (held for review, not scored)" : v.against ? " \u2014 against the local majority" : " \u2014 with the local majority") + (v.est != null ? "\nEstimated local support: " + pct(v.est) : "")); }); el.insertAdjacentHTML("beforeend", '
Against the local majorityWith itHeld for review, not scored
'); const sideL = {D: "Democratic-backed", R: "Republican-backed", X: "both parties"}; const VC = V.filter(v => v.c === BIO_C); $("#tb-votes").innerHTML = '

' + ORD(BIO_C) + ' Congress: ' + VC.length + ' counted vote' + (VC.length === 1 ? '' : 's') + '

' + (VC.length ? '' : '

No counted votes in this Congress.

') + '
' + VC.map(v => '').join("") + '
DateMeasurePositionVoteLocal supportResult
' + v.date + '' + esc(v.bill) + ' ' + esc(v.q) + '
' + ORD(v.c) + ' ' + v.ch + ' ' + (v.url ? 'roll ' + v.oroll + (v.sess ? ', session ' + v.sess : '') + '' : 'roll ' + esc(v.key.split("-")[0].slice(1))) + ' · ' + (v.match === "partial" ? "partial match" : "direct match") + ' · ' + sideL[v.side] + '
' + esc(posLabel(v.pos)) + '' + v.vote + '' + (v.est == null ? "n/a" : pct(v.est)) + '' + (v.review ? 'held for review' : v.against ? 'against' : 'with') + '
'; } function chOpinion(R, C) { const el = $("#ch-op"), items = BIOS.op_items[BIO_C] || [], rows = (C.opinion || []).map(([k, v]) => ({it: items[k], v})).filter(r => r.it); if (!rows.length) { el.innerHTML = '

No survey estimates for this area in this Congress.

'; return; } const w = W_(el), rh = 34, m = {l: Math.min(330, w * .42), r: 50, t: 22, b: 26}, h = m.t + m.b + rows.length * rh; const x = d3.scaleLinear().domain([0, 1]).range([m.l, w - m.r]); const s = svgEl(el, w, h, "Local versus national support on survey questions"); [0, .25, .5, .75, 1].forEach(v => { s.append("line").attr("x1", x(v)).attr("x2", x(v)).attr("y1", m.t - 6).attr("y2", h - m.b).attr("class", v === .5 ? "grid mid" : "grid"); s.append("text").attr("x", x(v)).attr("y", h - 8).attr("text-anchor", "middle").attr("class", "ax").text(v * 100 + "%"); }); rows.forEach((r, i) => { const cy = m.t + i * rh + rh / 2; s.append("text").attr("x", m.l - 10).attr("y", cy + 4).attr("text-anchor", "end").attr("class", "lab").text(r.it[0].length > 58 ? r.it[0].slice(0, 56) + "\u2026" : r.it[0]).append("title").text(r.it[0] + (r.it[1] === "proxy" ? " (proxy for a related position)" : "")); s.append("line").attr("x1", x(Math.min(r.v, r.it[2]))).attr("x2", x(Math.max(r.v, r.it[2]))).attr("y1", cy).attr("y2", cy).attr("class", "dumb"); s.append("circle").attr("cx", x(r.it[2])).attr("cy", cy).attr("r", 5).attr("class", "nat").append("title").text("Nation: " + pct(r.it[2])); s.append("circle").attr("cx", x(r.v)).attr("cy", cy).attr("r", 6).attr("class", "loc").append("title").text((C.chamber === "Senate" ? "State" : "District") + ": " + pct(r.v)); s.append("text").attr("x", w - m.r + 8).attr("y", cy + 4).attr("class", "val").text(pct(r.v)); }); el.insertAdjacentHTML("beforeend", '
' + (C.chamber === "Senate" ? "State" : "District") + 'Nation
'); } const PIEK = {superpac: ["Super PACs", 1], hybrid: ["Hybrid PACs", 2], single: ["Single-candidate PACs", 7], party: ["Party committees", 4], pac: ["Other PACs", 6], nondisclosing: ["Groups not naming donors", 5], corp: ["Corporations", 1], trade: ["Trade associations", 2], labor: ["Labor unions", 3], member: ["Membership groups", 4], ideol: ["Issue and ideological PACs", 6], coop: ["Cooperatives", 7], lead: ["Other politicians' PACs", 5], other: ["Other", 6]}; function donut(title, parts, note) { const tot = d3.sum(parts, p => p[1]); if (!tot) return ""; parts = parts.filter(p => p[1] > 0).sort((a, b) => b[1] - a[1]); const r = 78, ar = d3.arc().innerRadius(r * .62).outerRadius(r), pie = d3.pie().sort(null).value(p => p[1]).padAngle(.012); const col = k => "var(--k" + ((PIEK[k] || [k, 6])[1]) + ")", lab = k => (PIEK[k] || [k])[0]; const svg = '' + pie(parts).map(a => '' + esc(lab(a.data[0])) + ': ' + usdS(a.data[1]) + '').join("") + '' + usdS(tot) + 'total'; return '

' + esc(title) + '

' + svg + '
' + parts.map(p => '
' + esc(lab(p[0])) + '' + usdS(p[1]) + '' + (p[1] / tot * 100 < 1 ? "<1" : Math.round(p[1] / tot * 100)) + '%
').join("") + '
' + (note ? '

' + note + '

' : '') + '
'; } function chPies(R) { const o = R.outside, p = R.pac, k = (o && o.kinds) || {}, h = []; if (o) { h.push(donut("Spent to help them", Object.keys(k).map(x => [x, k[x][0]]))); h.push(donut("Spent to defeat them", Object.keys(k).map(x => [x, k[x][1]]))); } if (p && p.by_type) h.push(donut("Direct PAC gifts by donor type", Object.keys(p.by_type).map(x => [x, p.by_type[x]]).concat(p.lead ? [["lead", p.lead]] : []), p.lead ? "Includes " + usdS(p.lead) + " from other politicians\u2019 leadership PACs, which the PAC total below leaves out." : "")); $("#pies").innerHTML = h.join(""); } function chMoney(R) { chPies(R); const o = R.outside, el = $("#ch-out"); if (!o) el.innerHTML = '

No independent spending reported in their races, 2018 to 2026.

'; else { const cyc = Object.keys(o.cycles).sort(), w = W_(el), h = 260, m = {l: 64, r: 16, t: 18, b: 30}; const mx = d3.max(cyc, c => Math.max(o.cycles[c][0], o.cycles[c][1])) || 1; const x = d3.scaleBand().domain(cyc).range([m.l, Math.min(w - m.r, m.l + 150 * cyc.length)]).padding(.35), y = d3.scaleLinear().domain([-mx, mx]).nice().range([h - m.b, m.t]); const s = svgEl(el, w, h, "Outside spending for and against them by cycle"); y.ticks(5).forEach(v => { s.append("line").attr("x1", m.l).attr("x2", w - m.r).attr("y1", y(v)).attr("y2", y(v)).attr("class", v === 0 ? "grid mid" : "grid"); s.append("text").attr("x", m.l - 6).attr("y", y(v) + 3.5).attr("text-anchor", "end").attr("class", "ax").text(usdS(Math.abs(v))); }); cyc.forEach(c => { const [a, b] = o.cycles[c]; s.append("rect").attr("x", x(c)).attr("width", x.bandwidth()).attr("y", y(a)).attr("height", y(0) - y(a)).attr("class", "bar for").append("title").text(c + ": " + usdS(a) + " supporting"); s.append("rect").attr("x", x(c)).attr("width", x.bandwidth()).attr("y", y(0)).attr("height", y(-b) - y(0)).attr("class", "bar opp").append("title").text(c + ": " + usdS(b) + " opposing"); s.append("text").attr("x", x(c) + x.bandwidth() / 2).attr("y", h - 10).attr("text-anchor", "middle").attr("class", "ax").text(c); }); s.append("text").attr("x", m.l + 4).attr("y", m.t + 10).attr("class", "ax").text("supporting them"); s.append("text").attr("x", m.l + 4).attr("y", h - m.b - 6).attr("class", "ax").text("opposing them"); $("#tb-out").innerHTML = '

Biggest outside spenders

' + o.top.map(t => '').join("") + '
' + esc(/^[A-Z0-9&]{2,6}$/.test(t[0].trim()) ? t[0].trim() : tit(t[0])) + ' ' + KIND[t[1]] + '' + (t[2] ? usdS(t[2]) + " for" : "") + (t[2] && t[3] ? "
" : "") + (t[3] ? usdS(t[3]) + " against" : "") + '
' + ((o.dark_sup + o.dark_opp) > 0 ? '

From groups that need not name their donors: ' + usdS(o.dark_sup) + ' for, ' + usdS(o.dark_opp) + ' against.

' : '') + '

Covers all their races in these cycles, including runs for other offices.

'; } const p = R.pac; $("#tb-pac").innerHTML = '

Direct PAC gifts' + (p ? ', ' + usdS(p.total) + ' in total' : '') + '

' + (p ? '
' + p.top.map(t => { const mx = p.top[0][1] || 1; return '
' + esc(tit(t[0])) + '' + usdS(t[1]) + '
'; }).join("") + '

FEC, ' + (p.cycles || []).join(", ") + ' cycles; party, leadership and conduit committees left out.

' : '

No PAC gifts matched.

'); } function chTrades(R) { const t = R.trades, el = $("#ch-tr"); if (!t) { el.innerHTML = '

No periodic transaction reports found since 2019.

'; return; } const ys = Object.keys(t.by_year).filter(y => +y >= 2018).sort(), w = W_(el), h = 220, m = {l: 48, r: 16, t: 16, b: 30}; const x = d3.scaleBand().domain(ys).range([m.l, w - m.r]).padding(.3), y = d3.scaleLinear().domain([0, d3.max(ys, k => t.by_year[k][0]) || 1]).nice().range([h - m.b, m.t]); const s = svgEl(el, w, h, "Stock trades disclosed per year"); y.ticks(4).forEach(v => { s.append("line").attr("x1", m.l).attr("x2", w - m.r).attr("y1", y(v)).attr("y2", y(v)).attr("class", "grid"); s.append("text").attr("x", m.l - 6).attr("y", y(v) + 3.5).attr("text-anchor", "end").attr("class", "ax").text(v); }); ys.forEach(k => { const [n, lo, hi] = t.by_year[k]; s.append("rect").attr("x", x(k)).attr("width", x.bandwidth()).attr("y", y(n)).attr("height", y(0) - y(n)).attr("class", "bar").append("title").text(k + ": " + n + " trades, between " + usdS(lo) + " and " + usdS(hi)); s.append("text").attr("x", x(k) + x.bandwidth() / 2).attr("y", h - 10).attr("text-anchor", "middle").attr("class", "ax").text(k); }); $("#tb-tr").innerHTML = '
' + '
Reports' + t.filings + '' + (t.unparsed ? t.unparsed + " scanned, not counted" : "all read") + '
' + '
Filed late' + t.late + 'trades reported 45+ days after (estimate)
' + '
Most traded' + t.top.slice(0, 3).map(a => esc(a[0])).join(", ") + 'by number of trades
'; } function chCourts(R) { const c = R.courts, el = $("#ch-ct"); if (!c) { el.innerHTML = '

Not searched yet. The court search is still running (' + BIOS.courts_searched + ' members done).

'; return; } const cases = c.cases.filter(k => k[2]); const pd = d3.timeParse("%Y-%m-%d"), terms = (R.terms || []).filter(t => t[0] === "rep" || t[0] === "sen"); if (!cases.length) { el.innerHTML = '

No matching dockets found' + (c.possible ? '; ' + c.possible + ' same-name matches in other states are not shown' : '') + '.

'; return; } const yrs = cases.map(k => +k[2].slice(0, 4)).concat(terms.map(t => +t[1].slice(0, 4))); const x0 = pd(Math.max(1990, d3.min(yrs) - 1) + "-01-01"), x1 = pd("2027-01-01"); const w = W_(el), h = 150, m = {l: 16, r: 16, t: 26, b: 30}; const x = d3.scaleTime().domain([x0, x1]).range([m.l, w - m.r]); const s = svgEl(el, w, h, "Court records over time against their years in office"); terms.forEach(t => s.append("rect").attr("x", x(pd(t[1]))).attr("width", Math.max(1, x(pd(t[2])) - x(pd(t[1])))).attr("y", m.t).attr("height", h - m.t - m.b).attr("class", "term")); s.append("text").attr("x", m.l).attr("y", m.t - 8).attr("class", "ax").text("shaded: years in office"); x.ticks(8).forEach(d => s.append("text").attr("x", x(d)).attr("y", h - 10).attr("text-anchor", "middle").attr("class", "ax").text(d.getFullYear())); cases.forEach((k, i) => s.append("circle").attr("cx", x(pd(k[2]))).attr("cy", m.t + 12 + (i % 5) * ((h - m.t - m.b - 24) / 4)).attr("r", 5).attr("class", "vd " + (k[4] ? "rv" : "ag")).append("title").text(k[2] + " \u00b7 " + k[0] + " (" + k[1] + ")")); el.insertAdjacentHTML("beforeend", '
Docket naming themSuit naming many officials at once
'); $("#tb-ct").innerHTML = '
' + c.cases.map(k => '').join("") + '
' + esc(k[2] || "") + '' + esc(k[0]) + '
' + esc(k[1]) + '
' + esc(k[3]) + ' office' + (k[4] ? '
named with many officials
' : '') + '

Name matches only, not verified to be the same person. Includes suits against them as officials and amicus listings.' + (c.possible ? ' ' + c.possible + ' same-name matches in other states are not shown.' : '') + '

'; } function tbSigned(R, C) { const el = $("#tb-sig"); if (!el) return; const sen = C.chamber === "Senate", mine = new Set(Object.values(R.signed || {}).flat()); const rows = (BIOS.cosp || []).map(p => ({p, bills: p.bills.filter(b => /^S\d/.test(b[0]) === sen)})).filter(r => r.bills.length); if (!rows.length) { el.innerHTML = '

No tracked bills in their chamber.

'; return; } const got = rows.filter(r => r.bills.some(b => mine.has(b[0]))).length; el.innerHTML = '

' + got + ' of ' + rows.length + ' tracked positions

' + rows.map(r => { const g = r.bills.filter(b => mine.has(b[0])); return '
' + esc(posLabel(r.p.id)) + '' + (g.length ? g.map(b => esc(b[0])).join(", ") : "none signed") + '
'; }).join("") + '

Sponsor or cosponsor of a matching bill; not signing is not opposing. Titles matched by hand, unreviewed.

'; }