我有一个问题。我需要使用硬头和动态标头创建表。 所以我的问题是如何将数据放在右栏?
这就是我需要做的事情:
在Dynamics标题中,我将编写Compnies名称
这部分已经完成 - 这是我的代码:
M <- as.matrix(read.table(textConnection("0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0")))
my_spread <- function(m){
e <- which(m == 1, arr.ind = TRUE)
r <- c(e[, 1] - 1, e[, 1], e[, 1] + 1)
l <- c(e[, 2] - 1, e[, 2], e[, 2] + 1)
#dealing with border cases
r <- r[nrow(m) >= r]
l <- l[ncol(m) >= l]
m[as.matrix(expand.grid(r,l))] <- 1
m
}
my_spread(M)
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 0 0
[2,] 1 1 1 0 0
[3,] 1 1 1 0 0
[4,] 0 0 0 0 0
[5,] 0 0 0 0 0
my_spread(my_spread(M))
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 1 0
[2,] 1 1 1 1 0
[3,] 1 1 1 1 0
[4,] 1 1 1 1 0
[5,] 0 0 0 0 0
my_spread(my_spread(my_spread(M)))
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 1 1
[2,] 1 1 1 1 1
[3,] 1 1 1 1 1
[4,] 1 1 1 1 1
[5,] 1 1 1 1 1
这是HTML:
(function () {
'use strict';
angular
.module('myApp.views.payroll', ['myApp.directives'])
.controller('MyCtrl', ['$scope', '$stateParams', '$window', '$state', '$http', 'User',
function ($scope, $stateParams, $window, $state, $http, User) {
var vm = this;
vm.array = $stateParams.array;
vm.companies = [];
var days = [
'SUN', //Sunday starts at 0
'MON',
'TUE',
'WED',
'THU',
'FRI',
'SAT'
];
vm.getDay(item)
{
var day = new Date(item);
return days[day];
};
function getCompanies() {
$.each(vm.array , function (index, value) {
$.each(value.Companies, function (index, value) {
if (vm.companies.indexOf(value.CompanyName) === -1)
{
vm.companies.push(value.CompanyName);
}
});
});
};
getCompanies();
}
])
})();
谢谢。