This is an automated email from the ASF dual-hosted git repository. hapylestat pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push: new 93f1824 AMBARI-25546 Prevent negative float and NaN value in heatmap metrics page (akiyamaneko via dgrinenko) (#3223) 93f1824 is described below commit 93f1824179dc164377eb5f4dca4a8b7e7381f0d7 Author: neko <52202080+akiyaman...@users.noreply.github.com> AuthorDate: Tue Sep 29 19:04:31 2020 +0800 AMBARI-25546 Prevent negative float and NaN value in heatmap metrics page (akiyamaneko via dgrinenko) (#3223) --- .../controllers/main/charts/heatmap_metrics/heatmap_metric.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js index 499920c..3e9af5c 100644 --- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js +++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric.js @@ -93,7 +93,7 @@ App.MainChartHeatmapMetric = Em.Object.extend({ * */ slotDefinitions: function () { - var max = this.get('maximumValue') ? parseFloat(this.get('maximumValue')) : 0; + var max = this.getMaximumValue(); var slotCount = this.get('numberOfSlots'); var units = this.get('units'); var delta = (max - this.get('minimumValue')) / slotCount; @@ -175,6 +175,15 @@ App.MainChartHeatmapMetric = Em.Object.extend({ }, /** + * compatible with special input value, such as negative float number or string + * @return {float} + */ + getMaximumValue: function getMaximumValue() { + var max = this.get('maximumValue') ? parseFloat(this.get('maximumValue')) : 0; + return isNaN(max) ? 0 : Math.max(0, max); + }, + + /** * In slot definitions this value is used to construct the label by appending * it to slot min-max values. For example giving '%' here would result in slot * definition label being '0% - 10%'.