Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# MizzouSEG


## Project Description

This project utalizes a Huffington Post API to gather polling information for elections and other various topics. It then takes the informaion and visulizes it using the D3.js javascript library.

### Links to Resources

* [jQuery](https://jquery.com/)
* [D3](http://d3js.org/)
* [Huffington Post API](http://elections.huffingtonpost.com/pollster/api/)










26 changes: 23 additions & 3 deletions app.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
body {
background-color: #EEE;
}
#graph .choice {

#gopGraph .choice {
float: left;
font-family: arial;
font-size: 1.5em;
min-width: 200px;
text-align: right;
margin: 8px 5px;
}
#graph .bar {

#gopGraph .bar {
width: 0;
height: 35px;
background-color: coral;
margin: 5px;
float: left;
}

#demGraph .choice {
float: left;
font-family: arial;
font-size: 1.5em;
min-width: 200px;
text-align: right;
margin: 8px 5px;
}

#demGraph .bar {
width: 0;
height: 35px;
background-color: cornflowerblue;
margin: 5px;
float: left;
}

.group:after {
content: "";
display: table;
clear: both;
}
}
57 changes: 52 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,63 @@
</head>
<body>

<div id="graph"></div>

<h1>GOP Polls</h1>
<div id="gopGraph"></div>

<hr>

<h1>Democratic Polls</h1>
<div id="demGraph"></div>

<script>

var url = "http://elections.huffingtonpost.com/pollster/api/charts/2016-national-gop-primary";
function pollsterCallback(data) {
}

$(document).ready(function(){



var GOPurl = "http://elections.huffingtonpost.com/pollster/api/charts/2016-national-gop-primary";

$.ajax(GOPurl, {
dataType: "jsonp",
jsonpCallback: "pollsterCallback",
cache: true,
success: function(data) {

var candidateBar = d3.select("#gopGraph").selectAll("div").data(data.estimates),
candidateWrapper = candidateBar.enter().append("div").classed("group", true);

candidateWrapper.append("div")
.classed("choice", true)
.text(function(candidate) {
return candidate.choice + " " + candidate.value + "%";
});

candidateWrapper.append("div")
.classed("bar", true)
.transition()
.duration(1000)
.style("width", function(candidate) {
return candidate.value * 10 + "px";
});

}
});



var DEMurl = "http://elections.huffingtonpost.com/pollster/api/charts/2016-national-democratic-promary";

$.ajax(url, {
$.ajax(DEMurl, {
dataType: "jsonp",
jsonpCallback: "pollsterCallback",
cache: true,
success: function(data) {

var candidateBar = d3.select("#graph").selectAll("div").data(data.estimates),
var candidateBar = d3.select("#demGraph").selectAll("div").data(data.estimates),
candidateWrapper = candidateBar.enter().append("div").classed("group", true);

candidateWrapper.append("div")
Expand All @@ -39,6 +83,9 @@

}
});
}


</script>
</body>
</html>
</html>