From f9beedba40217f07169ce9764f4371d40ee72367 Mon Sep 17 00:00:00 2001 From: jcopperfield <33193571+jcopperfield@users.noreply.github.com> Date: Thu, 14 Dec 2017 16:03:07 +0100 Subject: [PATCH] Fix issue #5029 (#5041) - infinite loop in generating time axis, due to insufficient bounds checking. --- src/scales/scale.time.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 4fe39b81082..cfa9f829aa9 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -240,7 +240,7 @@ function determineStepSize(min, max, unit, capacity) { var i, ilen, factor; if (!steps) { - return Math.ceil(range / ((capacity || 1) * milliseconds)); + return Math.ceil(range / (capacity * milliseconds)); } for (i = 0, ilen = steps.length; i < ilen; ++i) { @@ -748,7 +748,8 @@ module.exports = function(Chart) { var tickLabelWidth = me.getLabelWidth(exampleLabel); var innerWidth = me.isHorizontal() ? me.width : me.height; - return Math.floor(innerWidth / tickLabelWidth); + var capacity = Math.floor(innerWidth / tickLabelWidth); + return capacity > 0 ? capacity : 1; } });