rollupsToTree = function(rollupsData) {
const makeTreeNode = d => {
let res = {
name: "" + d[0]
};
if (Array.isArray(d[1])) res.children = rollupsToTree(d[1]);
else res.value = d[1];
return res;
};
function rollupsToTree(groupedData) {
if (!groupedData) return;
return groupedData.map(makeTreeNode);
}
return {
name: "",
children: Array.isArray(rollupsData)
? rollupsToTree(rollupsData)
: [{ name: "", value: rollupsData }]
};
}