Skip to content

Instantly share code, notes, and snippets.

@molliemarie
Last active February 3, 2020 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molliemarie/e80ac392ecc726d601c7f895d922a1d1 to your computer and use it in GitHub Desktop.
Save molliemarie/e80ac392ecc726d601c7f895d922a1d1 to your computer and use it in GitHub Desktop.
CrimeInChicago_BarPlot_Starter
license: mit
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v5.min.js"></script>
<style type="text/css">
/*Add styling here */
</style>
<body>
</body>
<script>
//Define variables that do not need data first:
//Define Margins and svg here:
// var margin =
// var width =
// var height =
// var svg =
//Define xscale, yscale, xaxis, and yaxis here:
// var xScale =
// var yScale =
// var xAxis =
// var yAxis =
// Reading in data here, then calling "ready" function:
d3.csv("https://raw.githubusercontent.com/molliemarie/MSIA-D3Course-2019/master/Projects%26Exercises/FirstCompleteBar/data/ChiCrime.csv", function(d) {
return {
count: +d.count,
year: +d.year,
violation: d['Primary Type']
}
}).then(ready);
// Ready Function
function ready(data) {
// filtering for 2018 data
data2018 = data.filter(function(d) { return d.year == 2018})
console.log(data2018)
// Define xScale and yScale domains here:
// xScale.domain([0, d3.max([fill in appropriate code here])]);
// yScale.domain();
// define xAxisGroup and yAxisGroup here:
// var xAxisGroup =
// var yAxisGroup =
// Create bars here:
// var bars =
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment