Skip to content

Instantly share code, notes, and snippets.

@danielatkin
Last active August 29, 2015 14:19
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 danielatkin/557716c9941820de7f35 to your computer and use it in GitHub Desktop.
Save danielatkin/557716c9941820de7f35 to your computer and use it in GitHub Desktop.
Updated Attrition Time Series
state provider 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
New South Wales Charles Sturt University 0.2072 0.2148 0.2014 0.212 0.2104 0.2296 0.2422 0.2199 0.2239 0.2333 0.2301 0.227
New South Wales Macquarie University 0.1486 0.1386 0.1094 0.1041 0.118 0.117 0.1215 0.1124 0.1147 0.1207 0.1273 0.1476
New South Wales Southern Cross University 0.3213 0.3327 0.2731 0.2773 0.2986 0.2617 0.2635 0.2274 0.263 0.2506 0.258 0.3021
New South Wales The University of Sydney 0.1228 0.126 0.1168 0.1066 0.1061 0.1045 0.1065 0.099 0.1022 0.1057 0.1046 0.1116
New South Wales University of New England 0.2667 0.2724 0.2584 0.2566 0.2475 0.2432 0.2386 0.2226 0.2504 0.2467 0.2598 0.2629
New South Wales University of New South Wales(d) 0.1024 0.1051 0.0967 0.1047 0.1061 0.1082 0.1069 0.101 0.0896 0.1007 0.1019 0.0966
New South Wales University of Newcastle 0.1473 0.1687 0.1528 0.1467 0.1602 0.1659 0.1793 0.1538 0.1652 0.1672 0.1793 0.1681
New South Wales University of Technology, Sydney 0.1257 0.1222 0.1085 0.1184 0.1179 0.1184 0.1632 0.1159 0.1281 0.1157 0.1336 0.1296
New South Wales University of Western Sydney 0.2061 0.1742 0.178 0.2133 0.1962 0.1779 0.1984 0.1845 0.192 0.198 0.2063 0.2134
New South Wales University of Wollongong 0.1391 0.1414 0.1533 0.1312 0.1311 0.1438 0.1231 0.1054 0.1212 0.1396 0.1377 0.1341
Victoria Deakin University 0.193 0.1917 0.1746 0.17 0.1725 0.1593 0.1593 0.152 0.144 0.1329 0.1486 0.1611
Victoria Federation University Australia(e) 0.1746 0.1795 0.2183 0.2109 0.2073 0.2041 0.2134 0.2153 0.1774 0.2046 0.2347 0.2597
Victoria La Trobe University 0.1977 0.2139 0.2055 0.1903 0.1727 0.1624 0.1817 0.1696 0.1557 0.1699 0.167 0.165
Victoria Monash University 0.1342 0.1352 0.1222 0.1225 0.1179 0.1103 0.0965 0.0898 0.0935 0.1023 0.0999 0.0978
Victoria RMIT University 0.1684 0.1743 0.1499 0.1596 0.1414 0.1503 0.1142 0.1312 0.1159 0.112 0.115 0.1144
Victoria Swinburne University of Technology 0.1687 0.1796 0.1607 0.1651 0.1824 0.1562 0.1477 0.1706 0.1546 0.173 0.1752 0.2308
Victoria The University of Melbourne(f) 0.1503 0.1634 0.1529 0.1448 0.078 0.0753 0.0735 0.0767 0.0621 0.0705 0.0739 0.0674
Victoria Victoria University 0.2596 0.24 0.2414 0.2048 0.215 0.2121 0.2109 0.1856 0.2003 0.2245 0.1926 0.2236
Queensland Central Queensland University 0.2084 0.2241 0.2446 0.2236 0.2978 0.3371 0.3155 0.3052 0.3062 0.2727 0.2828 0.3095
Queensland Griffith University 0.1985 0.2365 0.2235 0.2184 0.2141 0.2072 0.214 0.1903 0.1914 0.2145 0.2003 0.2075
Queensland James Cook University 0.2473 0.2655 0.2707 0.2646 0.2507 0.2564 0.2323 0.2266 0.2096 0.2216 0.2143 0.2315
Queensland Queensland University of Technology 0.1725 0.1837 0.157 0.1738 0.1657 0.1728 0.1788 0.166 0.1494 0.1647 0.154 0.1574
Queensland The University of Queensland 0.1527 0.1529 0.1557 0.1382 0.1512 0.16 0.1693 0.1346 0.1385 0.1418 0.1364 0.1389
Queensland University of Southern Queensland 0.2711 0.2856 0.2667 0.2752 0.2658 0.2631 0.2468 0.2235 0.2313 0.2484 0.2434 0.2594
Queensland University of the Sunshine Coast 0.326 0.3856 0.3883 0.3619 0.3497 0.3475 0.3151 0.2748 0.2635 0.2649 0.2744 0.2816
Western Australia Curtin University of Technology 0.1551 0.1561 0.1394 0.1412 0.1622 0.1437 0.1633 0.1277 0.1235 0.1489 0.1365 0.1628
Western Australia Edith Cowan University 0.2267 0.2182 0.2207 0.2097 0.2122 0.2112 0.2184 0.2038 0.198 0.2085 0.2096 0.2116
Western Australia Murdoch University 0.1836 0.1955 0.188 0.2084 0.2064 0.2255 0.2138 0.1884 0.2071 0.1992 0.1725 0.1759
Western Australia The University of Western Australia 0.1321 0.1172 0.1195 0.1103 0.1169 0.1082 0.1113 0.1168 0.1161 0.1139 0.1092 0.1169
South Australia Flinders University of South Australia 0.2096 0.2119 0.1994 0.1875 0.1942 0.1767 0.1895 0.1774 0.1822 0.188 0.1838 0.1971
South Australia The University of Adelaide 0.1691 0.1652 0.1626 0.1468 0.1525 0.1317 0.1362 0.1304 0.1325 0.1388 0.1436 0.1563
South Australia University of South Australia 0.1844 0.1864 0.1709 0.1811 0.1771 0.1743 0.1676 0.1499 0.1427 0.1593 0.1784 0.1819
Tasmania Australian Maritime College(g) 0.2727 0.2717 0.3023 0.3506 0.3019 0.1638
Tasmania University of Tasmania(g) 0.1717 0.1838 0.1728 0.1761 0.1538 0.1878 0.2001 0.1983 0.1716 0.1805 0.1981 0.2125
Northern Territory Batchelor Institute of Indigenous Tertiary Education(h) 0.1 0.3617 0.3889 0.875 0.3171 0.3457 0.4045 0.4428 0.3977 0.5574 0.8864
Northern Territory Charles Darwin University(h) 0.3507 0.339 0.3369 0.3199 0.3154 0.3167 0.3085 0.3011 0.3038 0.3195 0.3074 0.3056
Australian Capital Territory The Australian National University 0.1616 0.1605 0.1242 0.1102 0.1074 0.1037 0.1152 0.0957 0.0864 0.0935 0.0895 0.1149
Australian Capital Territory University of Canberra 0.1882 0.1766 0.181 0.1674 0.1795 0.1894 0.187 0.1792 0.1759 0.1859 0.1938 0.1963
Multi-State Australian Catholic University 0.2077 0.1976 0.1973 0.1798 0.1885 0.1588 0.1608 0.1809 0.1899 0.192 0.2236 0.2148
<html>
<head>
<meta charset="utf-8">
<title>Attrition Time Series Line Chart</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<link rel="stylesheet" type="text/css" href="style-time-series.css">
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Cutive">
</head>
<body>
<div id="headspace"> &nbsp </div>
<div id="banner">
<div id="banner-inner">
<h1><span>Attrition</span> Time Series</h1>
</div>
</div>
<div id="container" class="center">
<div id="header">
<h2>Attrition Rate(a) for all commencing bachelor students by State and Higher Education Institution(b), 2001 to 2012(c)</h1>
</div>
<div id="time-series-chart">
<div id="tooltip" class="hidden">
<p><strong><span id="tooltipHeading">Important Label Heading</span></strong></p>
</div>
<div id="tooltipTail" class="hidden">
</div>
</div>
<script type="text/javascript">
//margins
var margin = {
top:20,
right:30,
bottom: 30,
left: 100
};
//chart size
var width = 1000 - margin.left - margin.right;
var height = 500 - margin.top - margin.bottom;
//number formats
var dateFormat = d3.time.format("%Y");
var percentformat = d3.format("%");
//Create the empty SVG image
var svg = d3.select("#time-series-chart")
.append("svg")
.attr({
"width": width + margin.left + margin.right,
"height": height + margin.top + margin.bottom
})
.append("g")
.attr("transform", "translate("+ margin.left + "," + margin.top + ")");
//Set up scales
var xScale = d3.time.scale()
.range([0, width]);
var yScale = d3.scale.linear()
.range([0, height]);
//Configure axis generators
var xAxis = d3.svg.axis()
.scale(xScale)
.orient("bottom")
.ticks(12)
.tickFormat(function(d) {
return dateFormat(d);
});
var yAxis = d3.svg.axis()
.scale(yScale)
.orient("left")
.tickFormat(function(d) {
return percentformat(d);
});
//Configure line generator
var line = d3.svg.line()
.x(function(d) {
return xScale(dateFormat.parse(d.year));
})
.y(function(d) {
return yScale(+d.rate);
});
//Load data
d3.csv("attritionTimeSeries.csv", function(data) {
var years = ["2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012"];
//Create a new, empty array to hold our restructured dataset
var dataset = [];
//Loop once for each row in data
for (var i = 0; i < data.length; i++) {
//Create new object with this provider's name and empty array
dataset[i] = {
provider: data[i].provider,
attrition: []
};
//Loop through all the years
for (var j = 0; j < years.length; j++) {
// If value is not empty
if (data[i][years[j]]) {
//Add a new object to the attrition data array
//for this provider
dataset[i].attrition.push({
year: years[j],
rate: data[i][years[j]]
});
}
}
}
//Uncomment to log the original data to the console
console.log(data);
//Uncomment to log the newly restructured dataset to the console
console.log(dataset);
//Set scale domains
xScale.domain([
d3.min(years, function(d) {
return dateFormat.parse(d);
}),
d3.max(years, function(d) {
return dateFormat.parse(d);
})
]);
yScale.domain([
d3.max(dataset, function(d) {
return d3.max(d.attrition, function(d) {
return +d.rate;
});
}),
0
]);
//Make a group for each provider
var groups = svg.selectAll("g")
.data(dataset)
.enter()
.append("g");
//Append a title with the provider name (so we get easy tooltips)
groups.attr("name", function (d){
return d.provider;
});
//Within each group, create a new line/path,
//binding just the attrition data to each one
groups.selectAll("path")
.data(function(d) {
return [ d.attrition ];
})
.enter()
.append("path")
.attr("class", "line")
.attr("d", line)
.attr("fill", "none")
.attr("stroke", "#95a5a6")
.attr("stroke-width", 2)
.classed("chartLine", true)
.on("mouseover", mouseover)
.on("mouseout", mouseout);
function mouseover (d) {
var lastRate = +d[d.length - 1].rate;
var x = width + margin.left + margin.right;
var y = yScale(lastRate) + margin.top -5 ;
var tailX = width + margin.left + margin.right - 20;
var tailY = yScale(lastRate) + margin.top;
var providerName = d3.select(this.parentNode).attr("name")
//Update the tooltip position and value
d3.select("#tooltip")
.style("left", x + "px")
.style("top", y + "px")
.select("#tooltipHeading")
.text(providerName);
d3.select("#tooltipTail")
.style("left", tailX + "px")
.style("top", tailY + "px")
;
//Show the tooltip
d3.select("#tooltip").classed("hidden", false);
d3.select("#tooltipTail").classed("hidden", false);
}
function mouseout (d) {
d3.select("#tooltip")
.classed("hidden", true);
d3.select("#tooltipTail").classed("hidden", true);
}
//Axes
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis);
});
</script>
<div id="footnotes">
<p class="left">(a) Attrition rate for year(x) is the proportion of students who commenced a bachelor course in year(x) who neither complete nor return in year(x + 1).</p>
<p class="left">(b) Includes only Public Universities (Table A).</p>
<p class="left">(c) Figures are based on full year data.</p>
<p class="left">(d) Data for the Australian Defence Force Academy data are included under University of New South Wales in this publication (for all years). Australian Defence Force Academy was excluded in the corresponding tables in previous years.</p>
<p class="left">(e) Previously University of Ballarat.</p>
<p class="left">(f) Prior to 2006 The University of Melbourne classified Study Abroad students as award. These were re-classififed in 2006 to non-award, removing them from the scope of Retention calculation and affecting the rates.</p>
<p class="left">(g) The Australian Maritime College is reported as a part of the University of Tasmania from 2008. These were previously reported separately.</p>
<p class="left">(h) As a result of a collaborative partnership between Batchelor Institute of Indigenous Tertiary Education and Charles Darwin University which established The Australian Centre for Indigenous Knowledge and Education (ACIKE),</p>
<p class="left">(i) Attrition rate (normal calculation) is based on a match process using the students' StudentID. This gives a "crude" attrition rate, which identifies students that neither complete a course nor are retained the following year at the same institution.</p>
</div>
<div id="source" class="left">
<p>SOURCE: <a href="https://education.gov.au/selected-higher-education-statistics-2013-student-data">Department of Education: selected higher education statistics 2013</a>.</p>
</div>
</div>
</body>
</html>
body {
font-family: helvetica, calibri, arial, sans-serif;
font-size: 11px;
text-align: center;
background-color: #ecf0f1;
margin:0px;
}
#headspace {
width: 100%;
height: 50px;
background-color: #ecf0f1;
display: inline-block;
margin: none;
}
#banner {
width: 100%;
height: 200px;
background-color: #e74c3c;
display: inline-block;
margin: none;
}
#banner-inner {
text-align: right;
font-family: Cutive, serif;
font-size: 30px;
color: #ffffff;
background-color: #e74c3c;
width:1000px;
height: 200px;
margin-left: auto;
margin-right: auto;
display: table;
}
#banner-inner h1 {
display:table-cell;
vertical-align:middle;
}
.center {
margin-left: auto;
margin-right: auto;
width: 1100px;
background-color: #ffffff;
text-align: left;
height: 100%;
margin-top: 0px;
}
#header {
height: 60px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 0px;
padding-top: 0px;
}
h1, h2{
margin-top: 0px;
}
h1 span{
color:#34495e
}
h2 {
text-align: center;
padding: 10px;
}
svg {
background-color: none;
text-align: center;
}
.axis path,
.axis line {
fill: none;
stroke: #95a5a6;
stroke-dasharray:2,1;
shape-rendering: crispEdges;
opacity: 0.7;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
#tooltip {
position: absolute;
padding: 5px;
background-color: #34495e;
-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: helvetica, calibri, arial, sans-serif;
font-size: 11px;
line-height: 15px;
color: #ffffff;
}
#tooltipTail {
position: absolute;
width: 0;
height: 0;
border-top: 8px solid transparent;
border-bottom: 8px solid transparent;
border-right:25px solid #34495e;
}
#tooltipTail.hidden {
display: none;
}
path.chartLine{
fill: none;
stroke: #95a5a6;
stroke-width: 2;
}
path.chartLine:hover
{
stroke: #e74c3c;
stroke-width: 3;
}
.left {
text-align:left;
}
#footnotes, #source {
padding-left:100px;
padding-right: 100px;
padding-top: 10px;
padding-bottom: 10px;
background-color:#ffffff;
}
#time-series-chart {
position:relative;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment