Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 1 #100

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MizzouSENG
Mizzou Software Engineering Course
# CS4320 Exercise 1

## This project uses an API from the Huffington Post that provides polling information for primaries, elections, and various topics. It focuses on the Republican (GOP) candidates for the 2016 Presidential Election.

### List of used resources. https://jquery.com/ http://d3js.org/ http://elections.huffingtonpost.com/pollster/api
23 changes: 22 additions & 1 deletion app.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,25 @@ body {
content: "";
display: table;
clear: both;
}
}

#graph2 .choice {
float: left;
font-family: arial;
font-size: 1.5em;
min-width: 200px;
text-align: right;
margin: 8px 5px;
}
#graph2 .bar {
width: 0;
height: 35px;
background-color: coral;
margin: 5px;
float: left;
}
.group2:after {
content: "";
display: table;
clear: both;
}
31 changes: 29 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>

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

<div id="graph2"></div>
<script>

var url = "http://elections.huffingtonpost.com/pollster/api/charts/2016-national-gop-primary";
Expand Down Expand Up @@ -39,6 +39,33 @@

}
});
var url2 = "http://elections.huffingtonpost.com/pollster/api/charts/2016-national-democratic-primary";

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

var candidateBar = d3.select("#graph2").selectAll("div").data(data.estimates),
candidateWrapper = candidateBar.enter().append("div").classed("group2", 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";
});

}
});
</script>
</body>
</html>
</html>