Skip to content

Commit 883b704

Browse files
Fix bug on TopN weird behavior with zero values (#74942) (#75048)
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
1 parent 627b457 commit 883b704

File tree

1 file changed

+3
-1
lines changed
  • src/plugins/vis_type_timeseries/public/application/visualizations/views

1 file changed

+3
-1
lines changed

src/plugins/vis_type_timeseries/public/application/visualizations/views/top_n.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ export class TopN extends Component {
110110
const isPositiveValue = lastValue >= 0;
111111

112112
const intervalLength = TopN.calcDomain(renderMode, min, max);
113-
const width = 100 * (Math.abs(lastValue) / intervalLength);
113+
// if both are 0, the division returns NaN causing unexpected behavior.
114+
// For this it defaults to 0
115+
const width = 100 * (Math.abs(lastValue) / intervalLength) || 0;
114116

115117
const styles = reactcss(
116118
{

0 commit comments

Comments
 (0)