51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
let cluster_result;
|
|
|
|
function updateClusters(id) {
|
|
if(typeof id !== 'undefined') {
|
|
request('clusters', id).then(function (data) {
|
|
cluster_result = data;
|
|
drawClusterTable();
|
|
});
|
|
}else request('clusters').then(function(data) {
|
|
cluster_result = data;
|
|
drawClusterTable();
|
|
});
|
|
}
|
|
|
|
function drawClusterTable(){
|
|
let row = $("<thead>");
|
|
row.append("<tr>");
|
|
row.append("<td></td>");
|
|
for (x in cluster_result){
|
|
if(x == 0){
|
|
row.append("<td>" + "ø" + "</td>");
|
|
}else{
|
|
row.append("<td>" + x + "</td>");
|
|
}
|
|
}
|
|
row.append("</tr>");
|
|
row.append("</thead>");
|
|
|
|
|
|
appendClusterTable(row, "Alter");
|
|
appendClusterTable(row, "Wohnort");
|
|
appendClusterTable(row, "Einkaufstag");
|
|
appendClusterTable(row, "Geschlecht");
|
|
appendClusterTable(row, "Familienstand");
|
|
appendClusterTable(row, "Einkaufsuhrzeit");
|
|
|
|
|
|
row.append("</tbody>");
|
|
$("#cluster_table").append(row);
|
|
}
|
|
|
|
function appendClusterTable(row, attrib){
|
|
row.append("</tbody>");
|
|
row.append("<tr>");
|
|
row.append("<td>" + attrib + "</td>");
|
|
for (x in cluster_result){
|
|
row.append($("<td>" + cluster_result[x][attrib] +"</td>"));
|
|
}
|
|
row.append("</tr>");
|
|
}
|