Ok, after a couple of hours of googling I haven't found a solution that (works) and doesn't use eval(). I have an array which i would like to run the same function to nest and do roll-up sums.
dsAhsBes = createAhsBesok(dsFilterBes, dsAhsBes, "d.Ar")
function createAhsBesok(ds, output, groupVar) {
output = d3.nest()
.key(function(d) {
return eval(groupVar);
})
.rollup(function(d) {
return {
"Count": d3.sum(d, function(g) {
return g.Count;
})
};
}).entries(ds);
output.forEach(function(d) {
d.Count = +d.values.Count;
d.Dep = "Main";
});
return (output);
}
The snippet above works, but I rather use something else than eval()
, if possible. How do i get the child function to parse groupVar
the right way without using eval?