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
11 changes: 11 additions & 0 deletions README.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#MizzouSEG

##Description

This project uses an API form the Huffington Post that provides polling information for primaries, elections, and various topics. this project has the polling numbers in bar graph form for the Republican and Democratic parties. This is my fork for the first exercise for the software engineering course at Mizzou where I added the Democratic party

##Links to tools used

[jQuery](https://jquery.com)
[D3.js](http://d3js.org)
[Huffington Post API](http://elections.huffingtonpost.com/pollster/api)
18 changes: 17 additions & 1 deletion app.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ body {
#graph .bar {
width: 0;
height: 35px;
background-color: coral;
background-color: red;
margin: 5px;
float: left;
}

#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: royalblue;
margin: 5px;
float: left;
}
Expand Down
35 changes: 33 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
<script src="d3.v3.min.js"></script>
</head>
<body>

<h1>Republican Candidates</h1>
<div id="graph"></div>

<h1>Democratic Candidates</h1>
<div id="graph2"></div>
<script>

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

$.ajax(url, {
dataType: "jsonp",
jsonpCallback: "pollsterCallback",
Expand All @@ -39,6 +41,35 @@

}
});

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

$.ajax(url, {
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("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";
});

}
});

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