Language
Login
Language Setting
X
English
日本語 [Japanese]
about this App
京都市高齢化率
useful
4
Loading...
if(typeof Application==="undefined"||!Application){var Application= {};} Application.lc = function() { this._init.apply(this, arguments); } Application.lc.prototype = { _data : null, _options : null, _mainArray : null, _init : function() { this._mainArray = []; this._mainArray = this._getObjectArray(); this._options = this._getGoogleOption(); this._initCheckBox(); }, _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 + "' " + checked + "/><span>" + obj.value + "</span></div>").appendTo("#checkBoxAreaId"); }); }, _configArray : function() { var array = [ { "caption" : "平成7年", "property" : "1995" }, { "caption" : "平成8年", "property" : "1996" }, { "caption" : "平成9年", "property" : "1997" }, { "caption" : "平成10年", "property" : "1998" }, { "caption" : "平成11年", "property" : "1999" }, { "caption" : "平成12年", "property" : "2000" }, { "caption" : "平成13年", "property" : "2001" }, { "caption" : "平成14年", "property" : "2002" }, { "caption" : "平成15年", "property" : "2003" }, { "caption" : "平成16年", "property" : "2004" }, { "caption" : "平成17年", "property" : "2005" }, { "caption" : "平成18年", "property" : "2006" }, { "caption" : "平成19年", "property" : "2007" }, { "caption" : "平成20年", "property" : "2008" }, { "caption" : "平成21年", "property" : "2009" }, { "caption" : "平成20年", "property" : "2010" }, { "caption" : "平成22年", "property" : "2011" }, { "caption" : "平成23年", "property" : "2012" }, ]; return array; }, _getGoogleOption : function() { var options = { title: '高齢化率', vAxis: {title: '単位:%', titleTextStyle: {color: '#A9A9A9'}} }; return options; }, _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 = []; $.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; }, _getSubjectKeyValuePair : function() { var array = []; for (var key in this._mainArray) { var obj = {}; var label = key.replace("http://ja.wikipedia.org/wiki/", ""); obj.key = key; obj.value = label; array.push(obj); } return array; }, getDataByKey : function(keyArray) { var self = this; var main = []; var titleArray = []; titleArray.push(""); $.each(keyArray, function(i, key) { key = key.replace("http://ja.wikipedia.org/wiki/", ""); titleArray.push(key); }); main.push(titleArray); var configArray = this._configArray(); $.each(configArray, function(k, obj) { var arr = []; arr.push(obj.property); $.each(keyArray, function(i, key) { var array = self._mainArray[key]; $.each(array, function(j, objData) { if (objData.property === obj.property) { //alert(objData.property + " | " + obj.property + " | " + objData.value); var val = objData.value; if (! isNaN(val)) { val = parseFloat(val); } arr.push(val); } }); }); main.push(arr); }); return main; }, getData : function() { return this._data; }, getOptions : function() { return this._options; } } var drawMarkersMap = function() { var lc = new Application.lc(); var options = lc.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 = lc.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); }); } google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawMarkersMap);
#checkBoxAreaId .entry { float: left; margin-right: 20px; width: 100px; } #checkBoxAreaId:after { content: ""; display: block; clear: left; }
<h4>高齢化率(総人口に占める65歳以上人口の割合)</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>
Preview
Input Data
ReadMe
Snapshots
LinkData Work
Table Data
京都市高齢化率
Contributor:kitayan
Update:May 17, 2013
523 Downloads, 1 Applications
京都市の統計情報を利用しています。 http://www.city.kyoto.jp/sogo/toukei/Population/Estimate/elderly.html
kyoto_city_elderly
Add LinkData work(LinkData)
Link http://app.linkdata.org/run/app1s374i?tab=readme
Initial content
jquery-1.7.1.min.js
https://www.google.com/jsapi
Work
Add
Clear
insert work id or work name.