Language
Login
Language Setting
X
English
日本語 [Japanese]
about this App
province_population 1920-2011
useful
0
Loading...
if (typeof Application === "undefined" || !Application) { var Application = {}; } Application.population = function () { this._init.apply(this, arguments); } Application.population.prototype = { _data: null, _option: null, _array: null, _init: function() { this._array = []; this._array = this._getObjectArray(); this._options = this._getGoogleOption(); this._initCheckBox(); }, _getObjectArray: function() { var main = []; $.each(LinkData.getWorks(), function(workKey, workValue) { $.each(LinkData.getFiles(workValue), function(fileKey, fileValue) { $.each(LinkData.getSubjects(workValue, fileValue), function(subjKey, subjValue) { var array = []; if (typeof main[subjValue] !== "undefined") { array = main[subjValue]; } $.each(LinkData.getProperties(workValue, fileValue), function(propKey, propValue) { var propLabel = propValue; var arr = propValue.split("#"); if (arr.length > 1) { propLabel = decodeURIComponent(arr[1]); } var obj = {}; var objValue = LinkData.getObjects(workValue, fileValue, subjValue, propValue)[0]; obj.property = propLabel; obj.value = objValue; array.push(obj); }); main[subjValue] = array; }); }); }); return main; }, _getGoogleOption : function() { var options = { title: '都道府県別人口', animation:{ duration: 1000, easing: 'out', }, curveType: "none", vAxis: {title: '単位:千人', titleTextStyle: {color: '#A9A9A9'}} }; return options; }, _initCheckBox : function() { var array = this._getSubjectKeyValuePair(); $.each(array, function(i, obj) { var checked = ""; if (i == 0 || i ==2) { checked = "checked='checked'"; } $("<div class='entry'><input type='checkbox' class='chkPrefecture' value='" + obj.key + "' id='" + obj.key + "' " + checked + "/><label for='" + obj.key + "'><span>" + obj.value + "</span></label></div>").appendTo("#checkBoxAreaId"); }); }, _getSubjectKeyValuePair : function() { var array = []; for (var key in this._array) { var obj = {}; var label = key.replace("http://ja.wikipedia.org/wiki/", ""); obj.key = key; obj.value = label; array.push(obj); } return array; }, _configArray : function() { var array = [ {"caption": "1920年", "property": "1920"}, {"caption": "1921年", "property": "1921"}, {"caption": "1922年", "property": "1922"}, {"caption": "1923年", "property": "1923"}, {"caption": "1924年", "property": "1924"}, {"caption": "1925年", "property": "1925"}, {"caption": "1926年", "property": "1926"}, {"caption": "1927年", "property": "1927"}, {"caption": "1928年", "property": "1928"}, {"caption": "1929年", "property": "1929"}, {"caption": "1930年", "property": "1930"}, {"caption": "1931年", "property": "1931"}, {"caption": "1932年", "property": "1932"}, {"caption": "1933年", "property": "1933"}, {"caption": "1934年", "property": "1934"}, {"caption": "1935年", "property": "1935"}, {"caption": "1936年", "property": "1936"}, {"caption": "1937年", "property": "1937"}, {"caption": "1938年", "property": "1938"}, {"caption": "1939年", "property": "1939"}, {"caption": "1940年", "property": "1940"}, {"caption": "1941年", "property": "1941"}, {"caption": "1942年", "property": "1942"}, {"caption": "1943年", "property": "1943"}, {"caption": "1944年", "property": "1944"}, {"caption": "1945年", "property": "1945"}, {"caption": "1946年", "property": "1946"}, {"caption": "1947年", "property": "1947"}, {"caption": "1948年", "property": "1948"}, {"caption": "1949年", "property": "1949"}, {"caption": "1950年", "property": "1950"}, {"caption": "1951年", "property": "1951"}, {"caption": "1952年", "property": "1952"}, {"caption": "1953年", "property": "1953"}, {"caption": "1954年", "property": "1954"}, {"caption": "1955年", "property": "1955"}, {"caption": "1956年", "property": "1956"}, {"caption": "1957年", "property": "1957"}, {"caption": "1958年", "property": "1958"}, {"caption": "1959年", "property": "1959"}, {"caption": "1960年", "property": "1960"}, {"caption": "1961年", "property": "1961"}, {"caption": "1962年", "property": "1962"}, {"caption": "1963年", "property": "1963"}, {"caption": "1964年", "property": "1964"}, {"caption": "1965年", "property": "1965"}, {"caption": "1966年", "property": "1966"}, {"caption": "1967年", "property": "1967"}, {"caption": "1968年", "property": "1968"}, {"caption": "1969年", "property": "1969"}, {"caption": "1970年", "property": "1970"}, {"caption": "1971年", "property": "1971"}, {"caption": "1972年", "property": "1972"}, {"caption": "1973年", "property": "1973"}, {"caption": "1974年", "property": "1974"}, {"caption": "1975年", "property": "1975"}, {"caption": "1976年", "property": "1976"}, {"caption": "1977年", "property": "1977"}, {"caption": "1978年", "property": "1978"}, {"caption": "1979年", "property": "1979"}, {"caption": "1980年", "property": "1980"}, {"caption": "1981年", "property": "1981"}, {"caption": "1982年", "property": "1982"}, {"caption": "1983年", "property": "1983"}, {"caption": "1984年", "property": "1984"}, {"caption": "1985年", "property": "1985"}, {"caption": "1986年", "property": "1986"}, {"caption": "1987年", "property": "1987"}, {"caption": "1988年", "property": "1988"}, {"caption": "1989年", "property": "1989"}, {"caption": "1990年", "property": "1990"}, {"caption": "1991年", "property": "1991"}, {"caption": "1992年", "property": "1992"}, {"caption": "1993年", "property": "1993"}, {"caption": "1994年", "property": "1994"}, {"caption": "1995年", "property": "1995"}, {"caption": "1996年", "property": "1996"}, {"caption": "1997年", "property": "1997"}, {"caption": "1998年", "property": "1998"}, {"caption": "1999年", "property": "1999"}, {"caption": "2000年", "property": "2000"}, {"caption": "2001年", "property": "2001"}, {"caption": "2002年", "property": "2002"}, {"caption": "2003年", "property": "2003"}, {"caption": "2004年", "property": "2004"}, {"caption": "2005年", "property": "2005"}, {"caption": "2006年", "property": "2006"}, {"caption": "2007年", "property": "2007"}, {"caption": "2008年", "property": "2008"}, {"caption": "2009年", "property": "2009"}, {"caption": "2010年", "property": "2010"}, {"caption": "2011年", "property": "2011"} ]; return array; }, getDataByKey : function(provinceArray) { var self = this; var main = []; var labelArray = []; var configArray = this._configArray(); labelArray.push(""); $.each(provinceArray, function(k, province) { labelArray.push(province.replace("http://ja.wikipedia.org/wiki/", "")); }); main.push(labelArray); $.each(configArray, function(i, year) { var arr = []; arr.push(year.caption); $.each(provinceArray, function(k, province) { var array = self._array[province]; $.each(array, function(j, objData) { var val = objData.value; if (! isNaN(val)) { if (objData.property == year.property) { val = parseFloat(val); arr.push(val); } } }); main.push(arr); }); }); return main; }, getOptions : function() { return this._options; } } var drawMarkersMap = function() { var bc = new Application.population(); var options = bc.getOptions(); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); var runApp = function(dataArray) { $("#chart_div").show(); if (dataArray.length == 0) { $("#chart_div").hide(); return; } var array = bc.getDataByKey(dataArray); var data = google.visualization.arrayToDataTable(array); chart.draw(data, options); } var initArray = []; $(".chkPrefecture:checked").each(function() { initArray.push($(this).val()); }); runApp(initArray); $(".chkPrefecture").change(function() { var arr = []; $(".chkPrefecture:checked").each(function () { arr.push($(this).val()); }); runApp(arr); }); $("#selectAllButton").click(function() { var arr = []; $(".chkPrefecture").each(function () { $(this).attr("checked", "checked"); arr.push($(this).val()); }); runApp(arr); }); $("#clearAllButton").click(function() { var arr = []; $(".chkPrefecture").each(function () { $(this).removeAttr("checked"); }); runApp(arr); }); $(".year").click(function() { $(".year").each(function () { $(this).removeClass("on"); }); $(this).addClass("on"); var arr = []; $(".chkPrefecture:checked").each(function () { arr.push($(this).val()); }); runApp(arr); }); } google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawMarkersMap);
#checkBoxAreaId .entry { float: left; font-size: 12px; margin-right: 8px; width: 72px; } #checkBoxAreaId:after { content: ""; display: block; clear: left; } .cf:after { content: ''; display: block; clear: both; } .cf { zoom: 1; }
<h4>都道府県別人口数</h4> <div> <div id="checkBoxAreaId"></div> <div> <br/> <input type="button" id="selectAllButton" value="Select All"/> <input type="button" id="clearAllButton" value="Clear All"/> </div> <div id="chart_div" style="width: 900px; height: 500px;"></div> <div id="history" class="cf" /> </div>
Preview
Input Data
ReadMe
Snapshots
LinkData Work
Table Data
総務省 都道府県別 人口推計 1920〜2011
Contributor:ohsada
Update:Jun 18, 2012
1156 Downloads, 1 Applications
総務省統計局・政策統括官(統計基準担当)の統計研修所により、総務省国勢調査による人口を基に、その後における各年の人口の動きを他の人口関連資料から得て人口を算出
province_population_1920_29
province_population_1930_39
province_population_1940_49
province_population_1950_59
province_population_1960_69
province_population_1970_79
province_population_1980_89
province_population_1990_99
province_population_2000_09
province_population_2010_11
Add LinkData work(LinkData)
Link http://app.linkdata.org/run/app1s12i?tab=readme
jquery-1.7.1.min.js
https://www.google.com/jsapi
Work
Add
Clear
insert work id or work name.