Skip to content

Instantly share code, notes, and snippets.

@cpudney
Last active August 29, 2015 14:01
Show Gist options
  • Save cpudney/d372d3158b1dd82aaecd to your computer and use it in GitHub Desktop.
Save cpudney/d372d3158b1dd82aaecd to your computer and use it in GitHub Desktop.
Visualize changes in Australian Federal Government department staffing levels using a Treemap

Australian Federal Budget 2014/15: Changes to Public Service Staffing Levels

A treemap is used to display the hierarchy of Federal Government ministries and departments. The size and colour of the rectangles encode the number of staff (2013/14 or 2014/15) and the change in staffing levels (absolute or percentage), respectively.

Source data comes from Budget Paper 4 Table 2.2 Average Staffing Table.

The treemap was implemented using D3.js, and borrowed heavily from a couple of excellent examples:

The source-code is available on Github and is licensed under a Creative Commons Attribution 4.0 International License.

For more information see this Vislives! blog post.

TODO

  • add a colour legend
  • auto-range the colour scales
{
"name": "Public Service",
"children": [
{
"name": "Agriculture",
"children": [
{
"name": "Department of Agriculture",
"asl": [4258, 4397, 4165]
},
{
"name": "Australian Fisheries Management Authority",
"asl": [189, 185, 185]
},
{
"name": "Australian Grape and Wine Authority",
"asl": [0, 0, 55]
},
{
"name": "Australian Pesticides and Veterinary Medicines Authority",
"asl": [183, 166, 176]
},
{
"name": "Cotton Research and Development Corporation",
"asl": [14, 13, 14]
},
{
"name": "Fisheries Research and Development Corporation",
"asl": [13, 12, 13]
},
{
"name": "Grains Research and Development Corporation",
"asl": [61, 66, 76]
},
{
"name": "Grape and Wine Research and Development Corporation",
"asl": [11, 11, 0]
},
{
"name": "Rural Industries Research and Development Corporation",
"asl": [27, 27, 23]
},
{
"name": "Sugar Research and Development Corporation",
"asl": [8, 2, 0]
},
{
"name": "Wine Australia Corporation",
"asl": [49, 45, 0]
}
]
},
{
"name": "Attorney-General",
"children": [
{
"name": "Attorney-General's Department",
"asl": [1461, 1552, 1614]
},
{
"name": "Australia Business Arts Foundation Limited",
"asl": [33, 30, 18]
},
{
"name": "Australia Council",
"asl": [124, 128, 127]
},
{
"name": "Australian Film, Television and Radio School",
"asl": [150, 150, 150]
},
{
"name": "Australian National Maritime Museum",
"asl": [115, 113, 108]
},
{
"name": "Administrative Appeals Tribunal",
"asl": [170, 170, 163]
},
{
"name": "Australian Commission for Law Enforcement Integrity",
"asl": [34, 36, 38]
},
{
"name": "Australian Crime Commission",
"asl": [504, 536, 515]
},
{
"name": "Australian Federal Police",
"asl": [6416, 6586, 6239]
},
{
"name": "Australian Financial Security Authority",
"asl": [420, 450, 450]
},
{
"name": "Australian Human Rights Commission",
"asl": [125, 123, 142]
},
{
"name": "Australian Institute of Criminology",
"asl": [47, 47, 47]
},
{
"name": "Australian Law Reform Commission",
"asl": [16, 14, 13]
},
{
"name": "Australian Security Intelligence Organisation",
"asl": [1778, 1750, 1720]
},
{
"name": "Australian Transaction Reports and Analysis Centre",
"asl": [274, 268, 259]
},
{
"name": "Bundanon Trust",
"asl": [19, 19, 20]
},
{
"name": "CrimTrac Agency",
"asl": [228, 231, 229]
},
{
"name": "Family Court and Federal Circuit Court",
"asl": [789, 789, 766]
},
{
"name": "Federal Court of Australia",
"asl": [425, 418, 406]
},
{
"name": "High Court of Australia",
"asl": [82, 82, 79]
},
{
"name": "National Archives of Australia",
"asl": [429, 416, 412]
},
{
"name": "National Film & Sound Archive",
"asl": [211, 206, 178]
},
{
"name": "National Gallery of Australia",
"asl": [245, 257, 245]
},
{
"name": "National Library of Australia",
"asl": [434, 423, 412]
},
{
"name": "National Museum of Australia",
"asl": [221, 221, 218]
},
{
"name": "National Portrait Gallery of Australia",
"asl": [59, 53, 52]
},
{
"name": "Office of Parliamentary Counsel",
"asl": [113, 105, 99]
},
{
"name": "Office of the Australian Information Commissioner",
"asl": [80, 77, 39]
},
{
"name": "Office of the Director of Public Prosecutions",
"asl": [423, 452, 412]
},
{
"name": "Old Parliament House",
"asl": [72, 72, 68]
},
{
"name": "Screen Australia",
"asl": [112, 115, 108]
}
]
},
{
"name": "Communications",
"children": [
{
"name": "Department of Communications",
"asl": [585, 530, 430]
},
{
"name": "Australian Broadcasting Corporation",
"asl": [4619, 4650, 4642]
},
{
"name": "Australian Communications and Media Authority",
"asl": [523, 512, 468]
},
{
"name": "Special Broadcasting Service Corporation",
"asl": [1058, 1081, 1081]
},
{
"name": "Telecommunications Universal Service Management Agency",
"asl": [17, 15, 0]
}
]
},
{
"name": "Defence",
"children": [
{
"name": "Department of Defence – Civilian",
"asl": [15547, 15268, 14883]
},
{
"name": "Australian War Memorial",
"asl": [339, 329, 333]
},
{
"name": "Defence Housing Australia",
"asl": [614, 679, 673]
},
{
"name": "Defence Materiel Organisation",
"asl": [5670, 5243, 5209]
},
{
"name": "Department of Defence – Military",
"asl": [58235, 56395, 58839]
},
{
"name": "Department of Defence – Reserves",
"asl": [20450, 20200, 20500]
},
{
"name": "Department of Veterans' Affairs",
"asl": [1924, 1924, 1870]
}
]
},
{
"name": "Departments of the Parliament",
"children": [
{
"name": "Department of Parliamentary Services",
"asl": [705, 711, 708
]
},
{
"name": "Department of the House of Representatives",
"asl": [158, 155, 154]
},
{
"name": "Department of the Senate",
"asl": [155, 147, 150]
},
{
"name": "Parliamentary Budget Office",
"asl": [39, 35, 39]
}
]
},
{
"name": "Education",
"children": [
{
"name": "Department of Education, Employment and Workplace Relations",
"asl": [3740, 779, 0]
},
{
"name": "Department of Education",
"asl": [0, 1417, 1823]
},
{
"name": "Australian Curriculum Assessment and Reporting Authority",
"asl": [118, 116, 95]
},
{
"name": "Australian Institute of Aboriginal and Torres Strait Islander Studies",
"asl": [118, 134, 134]
},
{
"name": "Australian Institute for Teaching and School Leadership Limited",
"asl": [68, 62, 62]
},
{
"name": "Australian Research Council",
"asl": [120, 120, 120]
},
{
"name": "Tertiary Education Quality and Standards Agency",
"asl": [99, 90, 74]
}
]
},
{
"name": "Employment",
"children": [
{
"name": "Department of Employment",
"asl": [0, 1627, 1716]
},
{
"name": "Asbestos Safety and Eradication Agency",
"asl": [0, 7, 7]
},
{
"name": "Comcare",
"asl": [637, 675, 674]
},
{
"name": "Fair Work Commission",
"asl": [353, 330, 336]
},
{
"name": "Office of the Fair Work Building Industry Inspectorate",
"asl": [100, 131, 155]
},
{
"name": "Office of the Fair Work Ombudsman",
"asl": [693, 723, 709]
},
{
"name": "Safe Work Australia",
"asl": [104, 101, 101]
},
{
"name": "Workplace Gender Equality Agency",
"asl": [33, 32, 29]
}
]
},
{
"name": "Environment",
"children": [
{
"name": "Department of the Environment",
"asl": [2151, 2177, 1993]
},
{
"name": "Bureau of Meteorology",
"asl": [1536, 1508, 1450]
},
{
"name": "Director of National Parks",
"asl": [275, 270, 275]
},
{
"name": "Climate Change Authority",
"asl": [35, 29, 0]
},
{
"name": "Clean Energy Regulator",
"asl": [360, 338, 339]
},
{
"name": "Great Barrier Reef Marine Park Authority",
"asl": [205, 218, 210]
},
{
"name": "Low Carbon Australia Limited",
"asl": [0, 0, 0]
},
{
"name": "Murray-Darling Basin Authority",
"asl": [295, 295, 290]
},
{
"name": "National Water Commission",
"asl": [40, 37, 11]
},
{
"name": "Sydney Harbour Federation Trust",
"asl": [57, 53, 58]
}
]
},
{
"name": "Finance",
"children": [
{
"name": "Department of Finance",
"asl": [1468, 1395, 1369]
},
{
"name": "Australian Electoral Commission",
"asl": [878, 1084, 858]
},
{
"name": "Commonwealth Superannuation Corporation",
"asl": [72, 70, 81]
},
{
"name": "ComSuper",
"asl": [445, 452, 410]
},
{
"name": "Future Fund Management Agency",
"asl": [104, 89, 120]
}
]
},
{
"name": "Foreign Affairs and Trade",
"children": [
{
"name": "Department of Foreign Affairs and Trade",
"asl": [3981, 6175, 5640]
},
{
"name": "AusAID (Australian Agency for International Development)",
"asl": [1982, 0, 0]
},
{
"name": "Australian Centre for International Agriculture Research",
"asl": [73, 70, 70]
},
{
"name": "Australian Trade Commission (Austrade)",
"asl": [930, 1013, 996]
},
{
"name": "Export Finance Insurance Corporation - National Interest Account",
"asl": [7, 5, 5]
},
{
"name": "Tourism Australia",
"asl": [198, 204, 204]
}
]
},
{
"name": "Health",
"children": [
{
"name": "Department of Health",
"asl": [4567, 3731, 3405]
},
{
"name": "Australian Commission on Safety and Quality in Health Care",
"asl": [58, 68, 77]
},
{
"name": "Australian Institute of Health and Welfare",
"asl": [315, 306, 294]
},
{
"name": "Australian National Preventive Health Agency",
"asl": [40, 33, 0]
},
{
"name": "Australian Organ and Tissue Donation and Transplantation Authority",
"asl": [28, 28, 28]
},
{
"name": "Australian Radiation Protection and Nuclear Safety Agency",
"asl": [153, 135, 130]
},
{
"name": "Australian Sports Anti-Doping Authority",
"asl": [74, 78, 62]
},
{
"name": "Australian Sports Commission (includes Australian Sports Foundation Limited)",
"asl": [696, 642, 505]
},
{
"name": "Cancer Australia",
"asl": [72, 66, 72]
},
{
"name": "Food Standards Australia and New Zealand",
"asl": [118, 115, 107]
},
{
"name": "General Practice Education and Training Limited",
"asl": [61, 62, 31]
},
{
"name": "Health Workforce Australia",
"asl": [140, 129, 0]
},
{
"name": "Independent Hospital Pricing Authority",
"asl": [59, 55, 59]
},
{
"name": "National Blood Authority",
"asl": [53, 54, 53]
},
{
"name": "National Health and Medical Research Council",
"asl": [217, 217, 208]
},
{
"name": "National Health Funding Body",
"asl": [21, 19, 19]
},
{
"name": "National Health Performance Authority",
"asl": [53, 53, 54]
},
{
"name": "National Mental Health Commission",
"asl": [13, 13, 13]
},
{
"name": "Private Health Insurance Administration Council",
"asl": [35, 33, 32]
},
{
"name": "Private Health Insurance Ombudsman",
"asl": [12, 12, 12]
},
{
"name": "Professional Services Review",
"asl": [23, 17, 17]
}
]
},
{
"name": "Immigration and Border Protection",
"children": [
{
"name": "Department of Immigration and Border Protection",
"asl": [9080, 9304, 8904]
},
{
"name": "Australian Customs and Border Protection Service",
"asl": [5000, 5000, 4920]
},
{
"name": "Migration Review Tribunal and Refugee Review Tribunal",
"asl": [420, 420, 420]
}
]
},
{
"name": "Industry",
"children": [
{
"name": "Department of Resources, Energy and Tourism",
"asl": [655, 0, 0]
},
{
"name": "Department of Industry",
"asl": [3630, 3715, 2983]
},
{
"name": "Australian Institute of Marine Science",
"asl": [202, 204, 202]
},
{
"name": "Australian Nuclear Science and Technology Organisation",
"asl": [1276, 1267, 1204]
},
{
"name": "Australian Renewable Energy Agency",
"asl": [2, 2, 0]
},
{
"name": "Australian Skills Quality Authority",
"asl": [211, 197, 197]
},
{
"name": "Commonwealth Scientific and Industrial Research Organisation",
"asl": [5550, 5523, 5034]
},
{
"name": "Geoscience Australia",
"asl": [720, 716, 620]
},
{
"name": "IP Australia",
"asl": [1067, 1066, 1048]
},
{
"name": "National Offshore Petroleum Safety and Environmental Management Authority",
"asl": [121, 111, 135]
}
]
},
{
"name": "Infrastructure and Regional Development",
"children": [
{
"name": "Department of Regional Australia, Local Government, Arts and Sport",
"asl": [482, 100, 0]
},
{
"name": "Department of Infrastructure and Regional Development",
"asl": [994, 1110, 1164]
},
{
"name": "Australian Maritime Safety Authority",
"asl": [358, 358, 367]
},
{
"name": "Australian Transport Safety Bureau",
"asl": [118, 110, 104]
},
{
"name": "Civil Aviation Safety Authority",
"asl": [855, 855, 833]
},
{
"name": "National Capital Authority",
"asl": [56, 54, 56]
},
{
"name": "National Transport Commission",
"asl": [45, 43, 40]
}
]
},
{
"name": "Prime Minister and Cabinet",
"children": [
{
"name": "Department of the Prime Minister and Cabinet",
"asl": [771, 1720, 2314]
},
{
"name": "Aboriginal Hostels Limited",
"asl": [445, 406, 396]
},
{
"name": "Anindilyakwa Land Council",
"asl": [48, 38, 21]
},
{
"name": "Australian National Audit Office",
"asl": [348, 349, 349]
},
{
"name": "Australian Public Service Commission",
"asl": [254, 248, 226]
},
{
"name": "Central Land Council",
"asl": [231, 231, 228]
},
{
"name": "Indigenous Business Australia",
"asl": [227, 232, 236]
},
{
"name": "Indigenous Land Corporation",
"asl": [265, 265, 265]
},
{
"name": "National Australia Day Council Limited",
"asl": [11, 12, 13]
},
{
"name": "Northern Land Council",
"asl": [329, 226, 226]
},
{
"name": "Office of National Assessments",
"asl": [148, 135, 130]
},
{
"name": "Office of the Commonwealth Ombudsman",
"asl": [136, 136, 129]
},
{
"name": "Office of the Inspector-General of Intelligence and Security",
"asl": [12, 12, 11]
},
{
"name": "Office of the Official Secretary to the Governor-General",
"asl": [86, 82, 80]
},
{
"name": "Outback Stores Pty Ltd",
"asl": [150, 143, 152]
},
{
"name": "Tiwi Land Council",
"asl": [11, 5, 5]
},
{
"name": "Torres Strait Regional Authority",
"asl": [139, 137, 146]
},
{
"name": "Wreck Bay Aboriginal Community Council",
"asl": [32, 30, 30]
}
]
},
{
"name": "Social Services",
"children": [
{
"name": "Department of Human Services",
"asl": [30707, 29989, 30150]
},
{
"name": "Department of Social Services",
"asl": [3278, 3467, 3305]
},
{
"name": "Australian Aged Care Quality Agency",
"asl": [220, 208, 236]
},
{
"name": "Australian Institute of Family Studies",
"asl": [81, 81, 83]
},
{
"name": "National Disability Insurance Agency",
"asl": [0, 489, 798]
}
]
},
{
"name": "Treasury",
"children": [
{
"name": "Department of the Treasury",
"asl": [886, 899, 884]
},
{
"name": "Australian Bureau of Statistics",
"asl": [2685, 2600, 2500]
},
{
"name": "Australian Competition and Consumer Commission",
"asl": [802, 790, 735]
},
{
"name": "Australian Office of Financial Management",
"asl": [45, 42, 43]
},
{
"name": "Australian Prudential Regulation Authority",
"asl": [609, 600, 590]
},
{
"name": "Australian Securities and Investments Commission",
"asl": [1834, 1782, 1573]
},
{
"name": "Australian Taxation Office",
"asl": [22022, 21397, 19068]
},
{
"name": "Clean Energy Finance Corporation",
"asl": [50, 48, 0]
},
{
"name": "Commonwealth Grants Commission",
"asl": [40, 40, 40]
},
{
"name": "Corporations and Markets Advisory Committee",
"asl": [3, 3, 3]
},
{
"name": "Inspector-General of Taxation",
"asl": [10, 9, 14]
},
{
"name": "National Competition Council",
"asl": [12, 12, 4]
},
{
"name": "Office of the Auditing and Assurance Standards Board",
"asl": [8, 7, 7]
},
{
"name": "Office of the Australian Accounting Standards Board",
"asl": [24, 23, 22]
},
{
"name": "Productivity Commission",
"asl": [193, 185, 170]
},
{
"name": "Royal Australian Mint",
"asl": [241, 241, 228]
}
]
}
]
}
// Chart dimensions.
var CHART_WIDTH = 1000;
var CHART_HEIGHT = 750;
// Header.
var HEADER_HEIGHT = 20;
var TEXT_WIDTH_FACTOR = 0.15;
// Scales.
var X_SCALE = d3.scale.linear().range([0, CHART_WIDTH]);
var Y_SCALE = d3.scale.linear().range([0, CHART_HEIGHT]);
var CLR_ABS_SCALE = d3.scale.linear()
.domain([-3740, 0, 1659])
.range(["red", "white", "green"]);
var CLR_PCT_SCALE = d3.scale.linear()
.domain([-100, 0, 200])
.range(["red", "white", "green"]);
// Transition (ms).
var TRANSITION_DURATION = 500;
var node;
// Treemap layout.
var treemap = d3.layout.treemap()
.round(false)
.size([CHART_WIDTH, CHART_HEIGHT])
.sticky(true)
.value(function (d) {
return d.asl[0];
});
// Chart element.
var chart = d3.select("#chart")
.append("svg:svg")
.attr("width", CHART_WIDTH)
.attr("height", CHART_HEIGHT)
.append("svg:g");
var mouseMove = function (d) {
var x = d3.event.pageX + 5;
var y = d3.event.pageY + 5;
d3.select("#tooltip")
.style("left", x + "px")
.style("top", y + "px");
d3.select("#tooltip #heading")
.text(d.name);
d3.select("#tooltip #asl1314")
.text("2013-14: " + d.asl[0]);
d3.select("#tooltip #asl1415")
.text("2014-15: " + d.asl[2]);
var change = d.asl[2] - d.asl[0];
var pct = d.asl[0] == 0 ? "∞" : (change / d.asl[0] * 100).toFixed(1) + "%";
d3.select("#tooltip #change")
.text("Change: " + change + " (" + pct + ")");
d3.select("#tooltip").classed("hidden", false);
};
var mouseOut = function () {
d3.select("#tooltip").classed("hidden", true);
};
var absChange = function (d) {
return CLR_ABS_SCALE(d.asl[2] - d.asl[0]);
};
var pctChange = function (d) {
return d.asl[0] == 0 ? CLR_PCT_SCALE.range()[2] : CLR_PCT_SCALE(100 * (d.asl[2] - d.asl[0]) / d.asl[0]);
};
function asl1314(d) {
return d.asl[0];
}
function asl1415(d) {
return d.asl[2];
}
var fillColour = absChange;
// Read data.
d3.json("asl.json", function (data) {
var root = node = data;
// Initial layout.
enterTransition(root);
zoom(node);
// Handle change to select control.
d3.select("select").on("change", function () {
treemap.value(this.value == "1314" ? asl1314 : asl1415)
.nodes(root);
zoom(node);
});
d3.select("#clr").on("change", function () {
fillColour = this.value == "abs" ? absChange : pctChange;
zoom(node);
});
});
function enterTransition(root) {
// Treemap nodes.
var nodes = treemap.nodes(root);
// Create parent cells.
var parents = nodes.filter(function (d) {
return d.children;
});
var parentCells = chart.selectAll("g.cell.parent")
.data(parents, function (d) {
return "p-" + d.name;
});
// Parent enter transition.
var parentEnterTransition = parentCells.enter()
.append("g")
.attr("class", "cell parent")
.on("click", function (d) {
zoom(d);
})
.append("svg")
.attr("class", "clip")
.attr("width", function (d) {
return Math.max(0.01, d.dx);
})
.attr("height", HEADER_HEIGHT);
parentEnterTransition.append("rect")
.attr("class", "head")
.attr("width", function (d) {
return Math.max(0.01, d.dx);
})
.attr("height", HEADER_HEIGHT);
parentEnterTransition.append('text')
.attr("class", "label")
.attr("transform", "translate(3, 13)")
.attr("width", function (d) {
return Math.max(0.01, d.dx);
})
.attr("height", HEADER_HEIGHT)
.text(function (d) {
return d.name;
});
// Create children cells
var children = nodes.filter(function (d) {
return !d.children;
});
var childCells = chart.selectAll("g.cell.child")
.data(children, function (d) {
return "c-" + d.name;
});
// Child enter transition.
var childEnterTransition = childCells.enter()
.append("g")
.attr("class", "cell child")
.on("click", function (d) {
zoom(node === d.parent ? root : d.parent);
})
.on("mousemove", mouseMove)
.on("mouseout", mouseOut)
.append("svg")
.attr("class", "clip");
childEnterTransition.append("rect")
.classed("background", true)
.attr("width", function (d) {
return Math.max(0.01, d.dx);
})
.attr("height", function (d) {
return d.dy;
})
.style("fill", function (d) {
return fillColour(d);
});
childEnterTransition.append('text')
.attr("class", "label")
.attr('x', function (d) {
return d.dx / 2;
})
.attr('y', function (d) {
return d.dy / 2;
})
.attr("dy", ".35em")
.style("display", "none")
.text(function (d) {
return d.name;
});
// Parent transition.
parentCells.transition()
.duration(TRANSITION_DURATION).select(".cell")
.attr("transform", function (d) {
return "translate(" + d.dx + "," + d.y + ")";
});
// Child transition.
childCells.transition()
.duration(TRANSITION_DURATION).select(".cell")
.attr("transform", function (d) {
return "translate(" + d.x + "," + d.y + ")";
});
// Remove exit transition.
parentCells.exit()
.remove();
childCells.exit()
.remove();
}
function idealTextColor(bgColor) {
var red = parseInt(bgColor.substring(1, 3), 16);
var green = parseInt(bgColor.substring(3, 5), 16);
var blue = parseInt(bgColor.substring(5, 7), 16);
var bgDelta = (red * 0.299) + (green * 0.587) + (blue * 0.114);
return ((255 - bgDelta) < 105) ? "#000000" : "#ffffff";
}
function zoom(d) {
treemap.padding([HEADER_HEIGHT / (CHART_HEIGHT / d.dy), 0, 0, 0])
.nodes(d);
var kx = CHART_WIDTH / d.dx;
var ky = CHART_HEIGHT / d.dy;
var level = d;
X_SCALE.domain([d.x, d.x + d.dx]);
Y_SCALE.domain([d.y, d.y + d.dy]);
if (node != level) {
chart.selectAll(".cell.child .label")
.style("display", "none");
}
// Define the transition.
var transition = chart.selectAll("g.cell").transition()
.duration(TRANSITION_DURATION)
.attr("transform", function (d) {
return "translate(" + X_SCALE(d.x) + "," + Y_SCALE(d.y) + ")";
})
.each("start", function () {
d3.select(this).select("label")
.style("display", "none");
})
.each("end", function (d, i) {
if (!i && (level !== self.root)) {
chart.selectAll(".cell.child")
.filter(function (d) {
return d.parent === self.node; // only get the children for selected group.
})
.select(".label")
.style("display", "")
.style("fill", function (d) {
return idealTextColor(fillColour(d));
});
}
});
transition.select("text")
.text(function(d) {
var len = Math.round(TEXT_WIDTH_FACTOR * Math.max(0.01, (kx * d.dx)));
return d.name.length <= len ? d.name : (d.name.substr(0, len) + "...");
});
transition.select(".clip")
.attr("width", function (d) {
return Math.max(0.01, (kx * d.dx));
})
.attr("height", function (d) {
return d.children ? HEADER_HEIGHT : Math.max(0.01, (ky * d.dy));
});
transition.select(".child .label")
.attr("x", function (d) {
return kx * d.dx / 2;
})
.attr("y", function (d) {
return ky * d.dy / 2;
});
transition.select("rect")
.attr("width", function (d) {
return Math.max(0.01, (kx * d.dx));
})
.attr("height", function (d) {
return d.children ? HEADER_HEIGHT : Math.max(0.01, (ky * d.dy));
})
.style("fill", function (d) {
return d.children ? null : fillColour(d);
});
node = d;
if (d3.event) {
d3.event.stopPropagation();
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Australian Federal Government Budget: Public Service Staffing Levels</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
<link href="style.css" media="screen" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="chart"></div>
<div>
<label>Size:
<select id="size">
<option value="1314" selected>2013-14</option>
<option value="1415">2014-15</option>
</select>
</label>
<label>Colour:
<select id="clr">
<option value="abs" selected>absolute</option>
<option value="pct">relative (%)</option>
</select>
</label>
</div>
<p><a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License"
style="border-width:0"
src="http://i.creativecommons.org/l/by/4.0/80x15.png"/></a>
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons
Attribution 4.0 International License</a>.</p>
<div id="tooltip" class="hidden">
<p><strong id="heading"></strong></p>
<p><span id="asl1314"></span></p>
<p><span id="asl1415"></span></p>
<p><span id="change"></span></p>
</div>
</body>
<script src="chart.js" type="text/javascript"></script>
</html>
body {
overflow: hidden;
margin: 0;
font-size: 12px;
font-family: "Helvetica Neue", Helvetica;
}
svg {
overflow: hidden;
}
rect {
pointer-events: all;
cursor: pointer;
stroke: #EEEEEE;
}
.chart {
display: block;
margin: auto;
}
.label {
stroke: #000000;
fill: #000000;
stroke-width: 0;
margin: 2px;
overflow: hidden;
text-overflow: ellipsis;
}
.parent .label {
font-size: 12px;
stroke: #FFFFFF;
fill: #FFFFFF;
}
.child .label {
font-size: 11px;
text-anchor: middle;
}
.cell {
font-size: 11px;
cursor: pointer
}
.head {
fill: #555555;
}
#tooltip {
position: absolute;
width: auto;
height: auto;
padding: 10px;
background-color: white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
pointer-events: none;
}
#tooltip.hidden {
display: none;
}
#tooltip p {
margin: 0;
font-family: sans-serif;
font-size: 16px;
line-height: 20px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment