Skip to content

Instantly share code, notes, and snippets.

@mikelotis
Last active October 15, 2018 22:06
Show Gist options
  • Save mikelotis/2e194e9973b8bfcd0f27c55db27910cc to your computer and use it in GitHub Desktop.
Save mikelotis/2e194e9973b8bfcd0f27c55db27910cc to your computer and use it in GitHub Desktop.
October Quarter, Total Population Estimate (Alberta)
height: 400
width: 800
border: yes

Metadata
Data Source: Statistics Canada
Date Updated: September 27, 2018
Notes: Estimates from July 1, 1971 on include non-permanent residents and are adjusted for net census undercoverage, including incompletely enumerated Indian Reserves. Estimates prior to this date are unadjusted for net census undercoverage and do not include non-permanent residents.
All estimates subject to revision.

Credits

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
div#main {
margin: 0 auto;
padding-top: 30px;
}
</style>
</head>
<body>
<!-- preparing a DOM with width and height for ECharts -->
<div id="main" style="width:800px; height:400px;"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<script lang="babel" type="text/babel">
const log = console.log;
const myChart = echarts.init(document.getElementById('main'));
d3.csv("population-estimates-ab-quartely-1951-to-current.csv")
.then(function(populationEstms) {
//Convert all strings to intergers
const keys = populationEstms["columns"];
populationEstms.forEach(d => {
keys.forEach(p => {
if(d[p] !== "") d[p] = parseInt(d[p]);
});
});
//Added these to extend years range
//Not ideal but works for now
populationEstms.unshift({
"Year": populationEstms[0]["Year"] - 1,
"January 1": "",
"April 1": "",
"July 1": "",
"October 1": ""
});
populationEstms.push({
"Year": populationEstms[populationEstms.length -1]["Year"] + 1,
"January 1": "",
"April 1": "",
"July 1": "",
"October 1": ""
});
const option = {
title: {
left: "center",
text: "October Quater, Alberta Total Population Estimates: 1951 - 2017"
},
tooltip: {
trigger: "none",
axisPointer: {
type: "cross"
}
},
xAxis: [
{
data: populationEstms.map(d => d["Year"]),
axisLabel: {
interval: 9,
showMaxLabel: true,
showMinLabel: true
},
axisPointer: {
label: {
formatter: params => `${params.value} : ${params.seriesData[0].data.toLocaleString()}`,
margin: -45
}
},
boundaryGap: false,
name: "Year"
}
],
yAxis: {
name: "Population Estimate",
axisPointer: {
show: false
}
},
series: [
{
data: populationEstms.map(d => d["October 1"]),
type: "line",
smooth: true,
name: "October 1"
}
]
};
//set options and render chart
myChart.setOption(option);
});
</script>
</body>
</html>
Year January 1 April 1 July 1 October 1
1951 943000 950000
1952 959000 965000 977000 985000
1953 994000 1002000 1016000 1029000
1954 1039000 1047000 1061000 1070000
1955 1078000 1084000 1094000 1102000
1956 1109000 1118000 1126000 1136000
1957 1144000 1153000 1169000 1179000
1958 1191000 1198000 1211000 1221000
1959 1233000 1241000 1252000 1263000
1960 1274000 1282000 1296000 1307000
1961 1317000 1325000 1335000 1345000
1962 1356000 1363000 1373000 1382000
1963 1391000 1398000 1407000 1414000
1964 1419000 1425000 1431000 1436000
1965 1443000 1445000 1451000 1453000
1966 1456000 1459000 1465000 1470000
1967 1476000 1483000 1493000 1501000
1968 1510000 1518000 1527000 1536000
1969 1546000 1553000 1562000 1571000
1970 1579000 1589000 1597000 1607000
1971 1616000 1623000 1665717 1675638
1972 1679985 1686758 1694090 1705519
1973 1710866 1717910 1725327 1735396
1974 1739942 1746975 1754621 1769880
1975 1782575 1795097 1808689 1825051
1976 1839191 1852651 1869287 1896466
1977 1914570 1931214 1948263 1974721
1978 1991454 2006745 2022241 2047919
1979 2064776 2079840 2096966 2128647
1980 2149996 2168863 2191029 2227159
1981 2249907 2270227 2291104 2319715
1982 2337458 2352042 2369827 2378405
1983 2383354 2388090 2393587 2394239
1984 2394892 2396706 2393907 2390913
1985 2395813 2401499 2404490 2407001
1986 2415590 2424950 2432930 2429949
1987 2432958 2439074 2440877 2437537
1988 2443396 2450646 2456614 2465242
1989 2477533 2489032 2498325 2507203
1990 2520056 2532621 2547788 2563142
1991 2572947 2580625 2592306 2604031
1992 2611786 2620771 2632672 2643421
1993 2650886 2658293 2667292 2678623
1994 2683346 2691443 2700606 2709011
1995 2715701 2724946 2734519 2745255
1996 2753463 2762903 2775133 2789691
1997 2799561 2813157 2829848 2847526
1998 2859305 2876753 2899066 2915781
1999 2926079 2937393 2952692 2966682
2000 2974517 2988465 3004198 3016947
2001 3027941 3041238 3058108 3078336
2002 3092107 3108360 3128429 3144926
2003 3155103 3169049 3183065 3197858
2004 3209372 3223490 3238668 3260590
2005 3276797 3296271 3321768 3346754
2006 3371823 3396802 3421434 3453944
2007 3472771 3490842 3514147 3533413
2008 3548796 3567458 3595856 3619292
2009 3638482 3659228 3678996 3694303
2010 3702266 3714974 3732082 3747226
2011 3754424 3768773 3789030 3807726
2012 3825072 3847722 3874548 3900333
2013 3920499 3946798 3981011 4010903
2014 4029951 4054280 4083648 4106056
2015 4116047 4128300 4144491 4159519
2016 4169830 4181765 4196061 4210052
2017 4219363 4230284 4243995 4262642
2018 4274054 4288327 4307110
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment