{"record":{"id":"c974b318417cefe8","repo":"plotly/plotly.js","slug":"too-many-auto-margin-redraws","errorCode":null,"errorMessage":"Too many auto-margin redraws.","messagePattern":"Too many auto-margin redraws\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/plots/plots.js","lineNumber":1855,"sourceCode":"    if(!fullLayout._replotting && (plots.didMarginChange(oldMargins, gs) || needsRedrawForShift(gd))) {\n        if('_redrawFromAutoMarginCount' in fullLayout) {\n            fullLayout._redrawFromAutoMarginCount++;\n        } else {\n            fullLayout._redrawFromAutoMarginCount = 1;\n        }\n\n        // Always allow at least one redraw and give each margin-push\n        // call 3 loops to converge. Of course, for most cases this way too many,\n        // but let's keep things on the safe side until we fix our\n        // auto-margin pipeline problems:\n        // https://github.com/plotly/plotly.js/issues/2704\n        var maxNumberOfRedraws = 3 * (1 + Object.keys(pushMarginIds).length);\n\n        if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) {\n            return Registry.call('_doPlot', gd);\n        } else {\n            fullLayout._size = oldMargins;\n            Lib.warn('Too many auto-margin redraws.');\n        }\n    }\n\n    refineTicks(gd);\n};\n\nfunction refineTicks(gd) {\n    var axList = axisIDs.list(gd, '', true);\n\n    [\n        '_adjustTickLabelsOverflow',\n        '_hideCounterAxisInsideTickLabels'\n    ].forEach(function(k) {\n        for(var i = 0; i < axList.length; i++) {\n            var hideFn = axList[i][k];\n            if(hideFn) hideFn();\n        }\n    });","sourceCodeStart":1837,"sourceCodeEnd":1873,"githubUrl":"https://github.com/plotly/plotly.js/blob/1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314/src/plots/plots.js#L1837-L1873","documentation":"Convergence guard in the auto-margin pipeline. When margins are auto (layout.margin has auto sizes), Plotly redraws the plot repeatedly so margin-pushing components (titles, legends, colorbars, ticks) can converge. fullLayout._redrawFromAutoMarginCount tracks these redraws; once the count exceeds the allowed budget (one initial redraw plus a bounded number of loops per margin-push call), Plotly gives up and throws rather than looping forever. Firing indicates margin computations oscillate or never stabilize for this layout.","triggerScenarios":"Thrown at src/plots/plots.js:1855 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set explicit margin values in layout.margin (l, r, t, b) so no auto-margin redraws are needed.","Simplify or resize components that push margins (long titles, large legends, colorbars) to help convergence.","Check for custom component modules whose margin-push callbacks oscillate between values.","Reduce container resize churn that restarts the auto-margin loop."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1d090e0b5ffb8d0fdf6e0e4ff51d3f3cf67f1314","analyzedAt":"2026-09-02T22:03:39.906Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}