mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-21 07:36:52 +01:00
Fix Maximum call stack size exception in computeLabelSizes (#7883)
Calling Math.max with a large number of values was throwing an exception. Tracking the current largest width and height as the widths and heights are built up should be faster and avoids the exception.
This commit is contained in:
@@ -130,6 +130,8 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) {
|
||||
var widths = [];
|
||||
var heights = [];
|
||||
var offsets = [];
|
||||
var widestLabelSize = 0;
|
||||
var highestLabelSize = 0;
|
||||
var i, j, jlen, label, tickFont, fontString, cache, lineHeight, width, height, nestedLabel, widest, highest;
|
||||
|
||||
for (i = 0; i < length; ++i) {
|
||||
@@ -157,11 +159,13 @@ function computeLabelSizes(ctx, tickFonts, ticks, caches) {
|
||||
widths.push(width);
|
||||
heights.push(height);
|
||||
offsets.push(lineHeight / 2);
|
||||
widestLabelSize = Math.max(width, widestLabelSize);
|
||||
highestLabelSize = Math.max(height, highestLabelSize);
|
||||
}
|
||||
garbageCollect(caches, length);
|
||||
|
||||
widest = widths.indexOf(Math.max.apply(null, widths));
|
||||
highest = heights.indexOf(Math.max.apply(null, heights));
|
||||
widest = widths.indexOf(widestLabelSize);
|
||||
highest = heights.indexOf(highestLabelSize);
|
||||
|
||||
function valueAt(idx) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user