アットウィキロゴ

sentrt

var x = new Array();
var y = new Array();
 
function sample() {
 
        var query = "SELECT * FROM " +
            '1bn4cnZfYFU2UTceBYU5HJ-DXgr9VE7l0_5LuTdJM';
        var encodedQuery = encodeURIComponent(query);
 
        var url = ['https://www.googleapis.com/fusiontables/v1/query'];
        url.push('?sql=' + encodedQuery);
        url.push('&key=AIzaSyAH0WCAXRIdHdbI-6bnMSN4kVDDZZmGyqY');
        url.push('&callback=?');
 
 
 
 
 
        $.ajax({
            url: url.join(''),
            dataType: 'jsonp',
            success: function (data) {
                var rows = data['rows'];
 
 
 
                sx = 0;
 
                for (var i in rows) {
                    sx = sx + 1;
                    x[sx] = rows[i][0]/1;
                  y[sx] = rows[i][1]/1;
 
 
                }
 
 
                number = sx;
 
 
 
 
                paint();
 
                cal();
 
 
            }
        });
 
}
 
function paint(){
 
 
   str1="<table class=\"mdl-data-table mdl-js-data-table mdl-data-table--selectable mdl-shadow--2dp\">";
  str2="<th class=\"mdl-data-table__cell--non-numeric\">";
  str3="<td class=\"mdl-data-table__cell--non-numeric\">";
 
   str=str1;
   str=str+"<thead>";
   str=str+"<tr>";
   str=str+"<th>あり</th>";
   str=str+"<th>なし</th>";
    str=str+"</tr>"
  str=str+"</thead>";
 
  str=str+"<tbody>";
   for(s=1;s<number+1;s++){
   str=str+"<tr>";
   str=str+"<td>"+x[s]+"</td>";
   str=str+"<td>"+y[s]+"</td>";
   str=str+"</tr>";
   }
str=str+"</table>";
 
 
 
 $("#tab2").html(str);
 
 
 
 
}
 
 
function cal(){
 
    y1 = 0;
    for (s = 1; s < number + 1;s++ ){
    y1=y1+(x[s]-y[s]);    
    }
    y1 = y1 / number;
 
 y2 = 0;
    for (s = 1; s < number + 1;s++ ){
    y2=y2+x[s]    
    }
    y2 = y2 / number;
 
     y3 = 0;
    for (s = 1; s < number + 1;s++ ){
    y3=y3+y[s]    
    }
    y3 = y3 / number;
 
 
        $("#memo").html(y1+","+y2+","+y3);
 
 
 
 
 
 
 
 
                }
 
最終更新:2016年03月11日 00:08