Published unlisted
Edited
Feb 17, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function checkSenate(name,state){
const last_name = name.split(' ').slice(-1).join(' ');
for (let i = 0; i < senate_winners.length; i++) {
console.log(senate_winners[i].winner);
if (senate_winners[i].winner.includes(last_name) && senate_winners[i].state == state){
return true;
}
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
whichBranch = ["Both", "Senate", "House"]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
From_Candidate_Senate = dataByState.map(element => getData(element,"From_Candidate", "Senate"));
Insert cell
From_Candidate_House = dataByState.map(element => getData(element,"From_Candidate", "House"));
Insert cell
Insert cell
Debts_owed_by_Senate = dataByState.map(element => getData(element,"Debts_owed_by", "Senate"));
Insert cell
Debts_owed_by_House = dataByState.map(element => getData(element,"Debts_owed_by", "House"));
Insert cell
Insert cell
Total_Receipts_Senate = dataByState.map(element => getData(element,"Total_Receipts", "Senate"));
Insert cell
Total_Receipts_House = dataByState.map(element => getData(element,"Total_Receipts", "House"));
Insert cell
Insert cell
Individual_Contributions_Senate = dataByState.map(element => Object.assign(getData(element,"Individual_Contributions", "Senate"), { bp: element}));
Insert cell
Individual_Contributions_House = dataByState.map(element => Object.assign(getData(element,"Individual_Contributions", "House"), { bp: element}));
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable filtered_senate_or_house = filter_senate_or_house("Both")
Insert cell
mutable selected_senate_or_house = "Both"
Insert cell
function filter_senate_or_house(senate_v_house){
var encoding = selectedEncoding
var filtered_senate_or_house = filtered.filter(function(d){
if (senate_v_house == "Senate"){
return d.District == 0;
}
if (senate_v_house == "House"){
return d.District > 0;
}
return d.District>=0}).sort((a, b) => {
return b[encoding] - a[encoding]})
return filtered_senate_or_house.slice(0,5);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//house_winners = house.map(d => d.WINNER).filter(function(d){return d.length>0});
Insert cell
Insert cell
function getWinners(data){
var winners = [];
for (var i = 0; i < data.length; i++){
if (data[i].WINNER.length>0){
var winner = {winner:data[i].WINNER,state:data[i].state_po};
winners.push(winner);
}
}
return winners;
}

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more