Language
Login
Language Setting
X
English
日本語 [Japanese]
about this App
forked:統計データを棒グラフで表示するアプリ
useful
0
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(); this._getHistoryYear(); }, _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"); }); }, _configArray : function() { var array = [ { "caption" : "平成18年", "property" : "平成18年" }, { "caption" : "平成19年", "property" : "平成19年" }, { "caption" : "平成20年", "property" : "平成20年" }, { "caption" : "平成21年", "property" : "平成21年" }, { "caption" : "平成22年", "property" : "平成22年" } ]; return array; }, _getGoogleOption : function() { var options = { title: '従業者数', hAxis: {title: '単位:人', titleTextStyle: {color: '#A9A9A9'}, maxValue: 5999} }; 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(year, keyArray) { var self = this; var main = []; var titleArray = []; titleArray.push(""); var configArray = this._configArray(); $.each(configArray, function(k, obj) { if (year == "All" || obj.property === year) { titleArray.push(obj.property); } }); main.push(titleArray); $.each(keyArray, function(i, key) { var arr = []; arr.push(key.replace("http://ja.wikipedia.org/wiki/", "")); var array = self._mainArray[key]; $.each(array, function(j, objData) { $.each(configArray, function(k, obj) { var val = objData.value; if (! isNaN(val)) { if (objData.property === obj.property && (year == "All" || obj.property === year)) { val = parseFloat(val); arr.push(val); } } else { if (objData.property === obj.property && (year == "All" || obj.property === year)) { arr.push(0); } } }); }); main.push(arr); }); return main; }, getData : function() { return this._data; }, getOptions : function() { return this._options; }, _getHistoryYear : function(){ var sb = []; $.each(this._configArray(), function(k, obj) { sb[sb.length] = '<div class="year"><span class="text">' +obj.property+ '</span></div>'; }); sb[sb.length] = '<div class="year on"><span class="text">All</span></div>'; return $("#history").html(sb.join("")); } } 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($(".on").text(), 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; margin-right: 20px; width: 100px; } #checkBoxAreaId:after { content: ""; display: block; clear: left; } #chart_div { } #history { width: 900px; margin: auto; } #history .year { background-color: #888888; border: 1px solid #FFFFFF; color: #FFFFFF; float: left; font-size: 12px; height: 80px; text-align: center; width: 80px; cursor: pointer; } #history .on { background-color: #FF8888; border: 1px solid #FFFFFF; color: #FFFFFF; float: left; font-size: 12px; height: 80px; text-align: center; width: 80px; } #history .year .text{ line-height: 80px; } .cf:after { content: ''; display: block; clear: both; } .cf { zoom: 1; }
<h4>都道府県別従業者数(従業者10人以上の事業所)</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
工場立地動向調査:雇用予定従業者数5年分
Contributor:nobuotto
Update:Dec 5, 2011
1073 Downloads, 8 Applications
経済産業省 工場立地動向調査 平成22年度 個別表リスト 第9-3表 雇用予定従業者数[平成7年〜平成22年](都道府県別)(XLSX/18KB) のLOD
employee
Add LinkData work(LinkData)
Link http://app.linkdata.org/run/app1s6i?tab=readme
jquery-1.7.1.min.js
https://www.google.com/jsapi
Work
Add
Clear
insert work id or work name.