From b2c32034a3f3f955d7ad15fcabde08a25055a3de Mon Sep 17 00:00:00 2001 From: Matthew Crumley Date: Tue, 13 Oct 2020 19:53:54 -0400 Subject: [PATCH] Fix Maximum call stack size exception in _computeLabelSizes Issue #7881 --- src/core/core.scale.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 82433fc1990..06c50395c6b 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -894,6 +894,8 @@ export default class Scale extends Element { const widths = []; const heights = []; const offsets = []; + let widestLabelSize = 0; + let highestLabelSize = 0; let ticks = me.ticks; if (sampleSize < ticks.length) { ticks = sample(ticks, sampleSize); @@ -926,11 +928,13 @@ export default class Scale extends Element { widths.push(width); heights.push(height); offsets.push(lineHeight / 2); + widestLabelSize = Math.max(width, widestLabelSize); + highestLabelSize = Math.max(height, highestLabelSize); } garbageCollect(caches, length); - const widest = widths.indexOf(Math.max.apply(null, widths)); - const highest = heights.indexOf(Math.max.apply(null, heights)); + const widest = widths.indexOf(widestLabelSize); + const highest = heights.indexOf(highestLabelSize); function valueAt(idx) { return {