Language
Login
Language Setting
X
English
日本語 [Japanese]
about this App
京都市行政区別外国人登録数統計データを棒グラフで表示するアプリ
useful
1
Loading...
if(typeof Application==="undefined"||!Application){var Application= {};} Application.bc = function() { this._init.apply(this, arguments); } Application.bc.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" : "平成20年(2008)", "property" : "平成20年(2008)" }, { "caption" : "平成21年(2009)", "property" : "平成21年(2009)" }, { "caption" : "平成22年(2010)", "property" : "平成22年(2010)" }, { "caption" : "平成22年(2010)", "property" : "平成22年(2010)" }, { "caption" : "平成24年(2012)", "property" : "平成24年(2012)" }, { "caption" : "平成25年(2013)", "property" : "平成25年(2013)" } ]; return array; }, _getGoogleOption : function() { var options = { title: '外国人登録総数', hAxis: {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 bc = new Application.bc(); var options = bc.getOptions(); var chart = new google.visualization.BarChart(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); }); } google.load("visualization", "1", {packages:['corechart', 'table', 'geomap']}); google.setOnLoadCallback(drawMarkersMap);
#checkBoxAreaId .entry { float: left; margin-right: 20px; width: 100px; } #checkBoxAreaId:after { content: ""; display: block; clear: left; }
<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>
Preview
Input Data
ReadMe
Snapshots
LinkData Work
Table Data
京都市行政区別外国人登録数
Contributor:kyolib2013
Update:May 7, 2013
731 Downloads, 1 Applications
平成20年10月より京都市行政区別外国人登録数
foreigners_in_kyotocity
foreigners_in_kyotocity_2008
foreigners_in_kyotocity_2009
foreigners_in_kyotocity_2010
foreigners_in_kyotocity_2011
foreigners_in_kyotocity_2012
Add LinkData work(LinkData)
Link http://app.linkdata.org/run/app1s348i?tab=readme
Initial content
jquery-1.7.1.min.js
https://www.google.com/jsapi
Work
Add
Clear
insert work id or work name.