US Election 2020
US PRESIDENTIAL ELECTIONS 2020
2016 result
- 2000
- 2004
- 2008
- 2012
- 2016
Senate
Seats
House of
Representatives
Seats
$(".vis-nav button").on("click", function(){ $(".vis-nav button").removeClass("active") $(this).addClass("active") var getid = $(this).attr("id") if(getid === "chloropleth"){ mapfunction("#usa", "ca") }else if(getid === "hexmap"){ hexmapfunction("#usa", "ca") }
});
// $("#senatebtn").on("click", function(){
// // $(".senatetable").css("display", "block") // }) var senateTable = false; var repTable = false; function senateBtn(){ if(senateTable === false){ senateTable = true; $(".senatetable").css("display", "block") }else{ senateTable = false; $(".senatetable").css("display", "none") } } function repBtn(){ if(repTable === false){ repTable = true; $(".houseofreptable").css("display", "block") }else{ repTable = false; $(".houseofreptable").css("display", "none") } }
var defaultData = "CA";
var currLeadData, prevLeadCand, senatedata, houseofrepsdata, metadata;
var data2020 = (function () { var data2020 = null; jQuery.ajax({ 'async': false, 'global': false, 'url': 'https://thefederal.com/api/data.php?v=12345', 'dataType': "json", 'success': function (data) { data2020 = data; currLeadData = data["current-lead-candidate"]; prevLeadCand = data["prev-lead-candidate"]; senatedata = data["senate"]; houseofrepsdata = data["houseofreps"]; metadata = data["metadata"]; } }); return data2020; })();
console.log(data2020)
$("#senateseatcount span").text(metadata[0].value) $("#houserepseatcount span").text(metadata[1].value)
drawHorizontalStackChart("#current-leading-cand", currLeadData, { width: 800, height: 60, margin: { top: 25, bottom: 25, left: 0, right: 0 }, cutoff: 20, type: "CurrentLeadCand", textLabel: 'party', numberLabel: 'lead%', displayLabel: 'lead' }); drawHorizontalStackChart("#prev-leading-cand", prevLeadCand, { width: 800, height: 60, margin: { top: 25, bottom: 25, left: 0, right: 0 }, cutoff: 20, type: "PrevLeadCand", textLabel: 'party', numberLabel: 'lead%', displayLabel: 'lead' }); drawHorizontalStackChart("#senatechart", senatedata, { width: 800, height: 60, margin: { top: 25, bottom: 25, left: 0, right: 0 }, cutoff: 20, type: "CurrentLeadCand", textLabel: 'party', numberLabel: 'incoming%', displayLabel: 'incoming' }); drawHorizontalStackChart("#houseofrepschart", houseofrepsdata, { width: 800, height: 60, margin: { top: 25, bottom: 25, left: 0, right: 0 }, cutoff: 20, type: "houseofreps", textLabel: 'party', numberLabel: 'incoming%', displayLabel: 'incoming' });
// Display default map data feedData(defaultData, 0)
// Create the US map mapfunction("#usa", "ca") // hexmapfunction("#usa", "ca")
tabulate(".senatetable", senatedata, ["party", "outgoing", "incoming", "won"]); tabulate(".houseofreptable", houseofrepsdata, ["party", "outgoing", "incoming"]);