From 883b70402a84ca315d63b5e895e8618c09d6782f Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Mon, 17 Aug 2020 11:16:35 +0300 Subject: [PATCH] Fix bug on TopN weird behavior with zero values (#74942) (#75048) Co-authored-by: Elastic Machine --- .../public/application/visualizations/views/top_n.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/public/application/visualizations/views/top_n.js b/src/plugins/vis_type_timeseries/public/application/visualizations/views/top_n.js index b595979130d3a..3aae1bd64d953 100644 --- a/src/plugins/vis_type_timeseries/public/application/visualizations/views/top_n.js +++ b/src/plugins/vis_type_timeseries/public/application/visualizations/views/top_n.js @@ -110,7 +110,9 @@ export class TopN extends Component { const isPositiveValue = lastValue >= 0; const intervalLength = TopN.calcDomain(renderMode, min, max); - const width = 100 * (Math.abs(lastValue) / intervalLength); + // if both are 0, the division returns NaN causing unexpected behavior. + // For this it defaults to 0 + const width = 100 * (Math.abs(lastValue) / intervalLength) || 0; const styles = reactcss( {