{"record":{"id":"105c35bf9c1483ef","repo":"plotly/plotly.js","slug":"total-value-for-node-d-data-data-id-of-trace-na","errorCode":null,"errorMessage":"Total value for node <d.data.data.id> of <trace.name> is smaller than the sum of its children. \nparent value = <v> \nchildren sum = <partialSum>","messagePattern":"Total value for node <d\\.data\\.data\\.id> of <trace\\.name> is smaller than the sum of its children\\. \nparent value = <v> \nchildren sum = <partialSum>","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/traces/sunburst/calc.js","lineNumber":171,"sourceCode":"            case 'total':\n                hierarchy.each(function(d) {\n                    var cdi = d.data.data;\n                    var v = cdi.v;\n\n                    if(d.children) {\n                        var partialSum = d.children.reduce(function(a, c) {\n                            return a + c.data.data.v;\n                        }, 0);\n\n                        // N.B. we must fill in `value` for generated sectors\n                        // with the partialSum to compute the correct partition\n                        if(cdi.hasImpliedRoot || cdi.hasMultipleRoots) {\n                            v = partialSum;\n                        }\n\n                        if(v < partialSum * ALMOST_EQUAL) {\n                            failed = true;\n                            return Lib.warn([\n                                'Total value for node', d.data.data.id, 'of', trace.name,\n                                'is smaller than the sum of its children.',\n                                '\\nparent value =', v,\n                                '\\nchildren sum =', partialSum\n                            ].join(' '));\n                        }\n                    }\n\n                    d.value = v;\n                });\n                break;\n        }\n    } else {\n        countDescendants(hierarchy, trace, {\n            branches: trace.count.indexOf('branches') !== -1,\n            leaves: trace.count.indexOf('leaves') !== -1\n        });\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/traces/sunburst/calc.js#L153-L189","documentation":"During sunburst value propagation (src/traces/sunburst/calc.js:171), each internal node's value is compared with the sum of its children's values. If the parent's explicit value is smaller than the children's sum (beyond an ALMOST_EQUAL tolerance), the geometry is inconsistent, the trace is marked failed, and Plotly warns with both values.","triggerScenarios":"Setting an explicit `values` entry for a parent smaller than the sum of its descendants' values, e.g. parent value 10 with children 6 and 6; also triggered when marker colors/branches use 'remainder' on inconsistent totals.","commonSituations":"Budget/category data where sub-items were updated but the parent total wasn't; rounding after percentage conversions; mixing explicit parent values with child values computed independently.","solutions":["Recompute the parent value as the sum of its children (or omit the parent's value entirely so Plotly sums it).","Fix the child values so they sum to the declared parent total.","If the parent intentionally shows an aggregate cap, split the trace or use branchvalues consistently ('total' vs 'remainder') to match your semantics."],"exampleFix":"// before\nvalues: [10, 6, 6] // parent 10 < children sum 12\n// after\nvalues: [12, 6, 6] // or omit the parent value and let Plotly sum children","handlingStrategy":"validation","validationCode":"// ids/parents/values arrays; verify each parent's value >= sum of direct children\nfunction totalsAreConsistent(ids, parents, values) {\n  const sum = new Map(ids.map(id => [id, 0]));\n  ids.forEach((id, i) => {\n    if (parents[i] !== '') sum.set(parents[i], (sum.get(parents[i]) || 0) + values[i]);\n  });\n  return ids.every((id, i) =>\n    !sum.has(id) || sum.get(id) === 0 || values[i] >= sum.get(id));\n}","typeGuard":"function parentCoversChildren(ids, parents, values) {\n  return ids.every((id, i) => {\n    const kids = ids.reduce((s, _, j) => parents[j] === id ? s + values[j] : s, 0);\n    return kids === 0 || values[i] >= kids;\n  });\n}","tryCatchPattern":null,"preventionTips":["Omit explicit values for internal nodes and let Plotly sum children (branchvalues 'remainder').","If using branchvalues: 'total', assert each parent value equals (or exceeds) its children's sum before plotting.","Recompute parent totals from leaf data at build time instead of storing them by hand."],"tags":["sunburst","hierarchy","values-mismatch","data-validation"],"backgroundTag":"hierarchy-value-mismatch","analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}