plotly/plotly.js · error
Multiple implied roots, cannot build <trace.type> hierarchy
Error message
Multiple implied roots, cannot build <trace.type> hierarchy of <trace.name>. These roots include: <impliedRoots.join(', ')> What it means
In src/traces/sunburst/calc.js:107, when labels/parents imply more than one root (multiple entries whose parent is empty), the hierarchy is ambiguous. d3 stratify needs exactly one root, so Plotly warns 'Multiple implied roots' and skips building that trace's hierarchy, leaving the sunburst empty.
Source
Thrown at src/traces/sunburst/calc.js:107
for(k in parent2children) {
if(!refs[k]) {
impliedRoots.push(k);
}
}
// if an `id` has no ref in the `parents` array,
// take it as being the root node
if(impliedRoots.length === 1) {
k = impliedRoots[0];
cd.unshift({
hasImpliedRoot: true,
id: k,
pid: '',
label: k
});
} else {
return Lib.warn([
'Multiple implied roots, cannot build', trace.type, 'hierarchy of', trace.name + '.',
'These roots include:', impliedRoots.join(', ')
].join(' '));
}
} else if(parent2children[''].length > 1) {
var dummyId = Lib.randstr();
// if multiple rows linked to the root node,
// add dummy "root of roots" node to make d3 build the hierarchy successfully
for(var j = 0; j < cd.length; j++) {
if(cd[j].pid === '') {
cd[j].pid = dummyId;
}
}
cd.unshift({
hasMultipleRoots: true,View on GitHub (pinned to 1d090e0b5f)
Solutions
- Add a single explicit root node and set every former implied root's parent to that root's id.
- Split the data into separate traces, one per tree.
- Audit the parents array so exactly one entry (or one implied root) has an empty parent.
Example fix
// before ids: ['a','b','a1'], parents: ['', '', 'a'] // two implied roots a and b // after ids: ['root','a','b','a1'], parents: ['', 'root', 'root', 'a']
Defensive patterns
Strategy: validation
Validate before calling
const rootCount = ids.reduce((n, id, i) => (parents[i] === '' ? n + 1 : n), 0);
const hasExplicitRoot = ids.some(id => parents.every(p => p !== '' ) === false && parents[ids.indexOf(id)] === undefined);
if (rootCount > 1) throw new Error('Multiple implied roots: ' + ids.filter((_, i) => parents[i] === '')); Type guard
function hasSingleRoot(ids, parents) {
const roots = ids.filter((_, i) => parents[i] === '');
return roots.length <= 1;
} Prevention
- Always include one explicit root node with parent '' and attach all top-level nodes to it.
- Validate that exactly one entry has an empty parent before Plotly.react/Plotly.newPlot.
- When merging multiple trees, insert a synthetic root instead of leaving several empty parents.
When it happens
Trigger: A sunburst (or treemap/icicle) trace where ids/parents produce two or more nodes with pid '' that are not the designated root — e.g. parents: ['', '', ...] for several top-level entries without a single explicit root id.
Common situations: Converting multiple trees to one sunburst without a common root; data where several categories have empty parent strings by mistake; renaming the root id while children still reference the old parent.
Related errors
- Total value for node <d.data.data.id> of <trace.name> is sma
- Failed to build <trace.type> hierarchy of <trace.name>. Erro
- Node <nodeIndex> is already part of a group.
AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02).
Data as JSON: /api/errors/dd2c16a4594b193f.
Report an issue: GitHub.