[ Launch: D3 Basics ] 8e0e8350a766a79d97fa by axelson
[ Launch: Jason Test ] 8da7744ab1eb9456929f by axelson
[ Launch: test ] 4653053 by enjalot
[ Launch: test ] 4652017 by enjalot
[ Launch: test ] 4582399 by enjalot
-
-
Save axelson/8e0e8350a766a79d97fa to your computer and use it in GitHub Desktop.
Honolulu Budget 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Department Name | FY 2011 Actual | Object Code Name | |
---|---|---|---|
Services | 2660 | Holiday Overtime Pay | |
Services | 55830 | Non-Holiday Overtime Pay | |
Services | 9753807 | Regular Pay | |
EM | 1101 | Holiday Overtime Pay | |
EM | 505282 | Regular Pay | |
EM | 58495 | Non-Holiday Overtime Pay | |
Enterprise | 245313 | Holiday Overtime Pay | |
Enterprise | 8655365 | Regular Pay | |
Enterprise | 400026 | Non-Holiday Overtime Pay | |
IT | 37088 | Holiday Overtime Pay | |
IT | 6959343 | Regular Pay | |
IT | 163713 | Non-Holiday Overtime Pay | |
Emergency | 17958290 | Regular Pay | |
Emergency | 563386 | Holiday Overtime Pay | |
Emergency | 4897125 | Non-Holiday Overtime Pay | |
Fire | 4638020 | Holiday Overtime Pay | |
Fire | 67427324 | Regular Pay | |
Fire | 6689604 | Non-Holiday Overtime Pay | |
Police | 159931266 | Regular Pay | |
Police | 15120019 | Non-Holiday Overtime Pay | |
Police | 5645372 | Holiday Overtime Pay | |
Maint | 19142508 | Regular Pay | |
Maint | 162292 | Holiday Overtime Pay | |
Maint | 1423334 | Non-Holiday Overtime Pay | |
HR | 0 | Holiday Overtime Pay | |
HR | 4211042 | Regular Pay | |
HR | 37457 | Non-Holiday Overtime Pay | |
Planning | 12873542 | Regular Pay | |
Planning | 59777 | Non-Holiday Overtime Pay | |
Parks & Rec | 300606 | Holiday Overtime Pay | |
Parks & Rec | 27100762 | Regular Pay | |
Parks & Rec | 591983 | Non-Holiday Overtime Pay |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"Honolulu Budget 1","endpoint":"","display":"svg","public":true,"require":[{"name":"d3","url":"http://d3js.org/d3.v3.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"budget.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/tOHI3Vs.png","fullscreen":false,"ajax-caching":true} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data = tributary.budget; | |
var margin = {top: 23, right: 20, bottom: 123, left: 74}, | |
width = 1178 - margin.left - margin.right, | |
height = 670 - margin.top - margin.bottom; | |
var x0 = d3.scale.ordinal() | |
.rangeRoundBands([0, width], 0.1); | |
var x1 = d3.scale.ordinal(); | |
var y = d3.scale.linear() | |
.range([height, 0]); | |
var color = d3.scale.ordinal() | |
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); | |
var xAxis = d3.svg.axis() | |
.scale(x0) | |
.orient("bottom"); | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left") | |
.tickFormat(d3.format("$.2s")); | |
var svg = d3.select("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
function get_division(d) { return d['Department Name']; } | |
var divisions = d3.nest() | |
.key(get_division) | |
.key(function(d) { return d['Object Code Name']; }) | |
.rollup(function(leaves) { | |
return {amount: d3.sum(leaves, function(d) { return d['FY 2011 Actual'] }) } | |
}) | |
.entries(data); | |
var max_y_val = d3.max(divisions, function(d) { | |
return d3.max(d.values, function(d2) { return d2.values.amount; }); | |
}); | |
// Possible improvement: read this from the data | |
var divisions_list = ["Holiday Overtime Pay", "Non-Holiday Overtime Pay", "Regular Pay"]; | |
x0.domain(data.map(get_division)); | |
x1.domain(divisions_list).rangeRoundBands([0, x0.rangeBand()]); | |
y.domain([0, max_y_val]); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis) | |
// Rotate x-axis label | |
.selectAll("text") | |
.style("text-anchor", "start") | |
.attr("dx", ".8em") | |
.attr("dy", ".15em") | |
.attr("transform", "rotate(65)"); | |
svg.append("g") | |
.attr("class", "y axis") | |
.call(yAxis) | |
.append("text") | |
.attr("transform", "rotate(-90)") | |
.attr("y", 6) | |
.attr("dy", ".71em") | |
.style("text-anchor", "end") | |
.text("Pay"); | |
var division = svg.selectAll(".division") | |
.data(divisions) | |
.enter().append("g") | |
.attr("class", "g") | |
.attr("transform", function(d) { return "translate(" + x0(d.key) + ",0)"; }); | |
division.selectAll("rect") | |
.data(function(d) { return d.values; }) | |
.enter().append("rect") | |
.attr("width", x1.rangeBand()) | |
.attr("x", function(d) { return x1(d.key); }) | |
.attr("y", function(d) { return y(d.values.amount); }) | |
.attr("height", function(d) { return height - y(d.values.amount); }) | |
.style("fill", function(d) { return color(d.key); }); | |
var legend = svg.selectAll(".legend") | |
.data(divisions_list.slice().reverse()) | |
.enter().append("g") | |
.attr("class", "legend") | |
.attr("transform", function(d, i) { return "translate(0," + i * 20 + ")"; }); | |
legend.append("rect") | |
.attr("x", width - 18) | |
.attr("width", 18) | |
.attr("height", 18) | |
.style("fill", color); | |
legend.append("text") | |
.attr("x", width - 24) | |
.attr("y", 9) | |
.attr("dy", ".35em") | |
.style("text-anchor", "end") | |
.text(function(d) { return d; }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment