{"record":{"id":"aa50eb873c2a192f","repo":"plotly/plotly.js","slug":"node-pad-was-reduced-to-sankey-nodepadding-to","errorCode":null,"errorMessage":"node.pad was reduced to <sankey.nodePadding()>  to fit within the figure.","messagePattern":"node\\.pad was reduced to <sankey\\.nodePadding\\(\\)>  to fit within the figure\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/traces/sankey/render.js","lineNumber":94,"sourceCode":"    function applyInputSort(type) {\n        if (trace[type].sort === 'input') {\n            if (circular) {\n                Lib.warn(\n                    `Circular Sankey diagrams do not support the \"input\" ${type}.sort mode; falling back to the default sort.`\n                );\n            } else {\n                // Passing null maintains the input order\n                sankey[`${type}Sort`](null);\n            }\n        }\n    }\n    applyInputSort('link');\n    applyInputSort('node');\n\n    var graph = sankey();\n\n    if(sankey.nodePadding() < nodePad) {\n        Lib.warn('node.pad was reduced to ', sankey.nodePadding(), ' to fit within the figure.');\n    }\n\n    // Counters for nested loops\n    var i, j, k;\n\n    // Create transient nodes for animations\n    for(var nodePointNumber in calcData._groupLookup) {\n        var groupIndex = parseInt(calcData._groupLookup[nodePointNumber]);\n\n        // Find node representing groupIndex\n        var groupingNode;\n\n        for(i = 0; i < graph.nodes.length; i++) {\n            if(graph.nodes[i].pointNumber === groupIndex) {\n                groupingNode = graph.nodes[i];\n                break;\n            }\n        }","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/traces/sankey/render.js#L76-L112","documentation":"After running the d3-sankey layout in src/traces/sankey/render.js:94, Plotly compares the padding d3 actually used (sankey.nodePadding()) with the requested node.pad. When the figure is too short for all nodes at the requested padding, d3 shrinks the padding to fit and Plotly warns that node.pad was reduced.","triggerScenarios":"Large node.pad (default 20/8 px) combined with many nodes and/or a small figure height, so node heights plus requested padding exceed the plot height.","commonSituations":"Sankeys with dozens of nodes in a 400px-tall figure; embedding sankeys in small dashboard tiles; increasing node.pad or node.thickness without resizing the container.","solutions":["Increase the figure height (layout.height) so the requested node.pad fits.","Reduce layout.node.pad to a value the figure can accommodate.","Reduce the number of nodes or consolidate links so less vertical space is needed."],"exampleFix":"// before\nvar layout = { height: 300, node: { pad: 20 } }; // many nodes\n// after\nvar layout = { height: 700, node: { pad: 20 } };","handlingStrategy":"validation","validationCode":"// rough check: needed height ~ nNodes*(nodeThickness) + (nNodes+1)*pad\nconst est = nodes.length * 20 + (nodes.length + 1) * layout.node.pad;\nif (est > layout.height) console.warn('Increase layout.height above ~' + est + ' or lower node.pad');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Size layout.height proportional to node count when using large node.pad.","Prefer node.pad of 8-15 for dense sankeys in small containers.","Listen for plotly_warnings events / console warnings in embedded dashboards."],"tags":["sankey","layout","spacing","figure-size"],"backgroundTag":"layout-space-insufficient","analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}