I have data for popups, but when I use rollup, i dont know how to add this data. Is it possible?
const rollup = d3.rollup(
chartData,
data => d3.sum(data, d => d.value),
d => d.root,
d => d.category,
d => d.subcategory
)
I have data for popups, but when I use rollup, i dont know how to add this data. Is it possible?
const rollup = d3.rollup(
chartData,
data => d3.sum(data, d => d.value),
d => d.root,
d => d.category,
d => d.subcategory
)
For example, I try to add group index:
const rollup = d3.rollup(
chartData,
data => d3.sum(data, d => d.value),
d => d.root,
d => d.category,
d => d.subcategory
)
const pack = d3.pack().size([width, height])
const hierarchy = d3.hierarchy(rollup).sum(([_, value]: any) => value).sort(a, b) => b.value - a.value)
const nodes = pack(getIndexed(hierarchy))
const root = nodes.descendants()
With this func:
function getIndexed(node, index = 0) {
return node?.children
? Object.assign(node.copy(), { children: node.children.map(d, i) => getIndexed(d, i)), index })
: Object.assign(node.copy(), { index })
}
But result hierarchy don’t have parent, x, y and r parameters…
Does this example help?