You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by wu...@apache.org on 2022/11/19 17:54:36 UTC

[ambari] branch trunk updated: AMBARI-25546: To prevent negative float and NaN value in heatmap metrics page (#3546)

This is an automated email from the ASF dual-hosted git repository.

wuzhiguo pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d6451dcc1e AMBARI-25546: To prevent negative float and NaN value in heatmap metrics page (#3546)
d6451dcc1e is described below

commit d6451dcc1e977326e9cac873a5b0c7f4f42c58ef
Author: Yu Hou <52...@qq.com>
AuthorDate: Sun Nov 20 01:54:31 2022 +0800

    AMBARI-25546: To prevent negative float and NaN value in heatmap metrics page (#3546)
---
 .../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 499920cd29..5246e0c573 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;
@@ -174,6 +174,15 @@ App.MainChartHeatmapMetric = Em.Object.extend({
     return hatchStyle;
   },
 
+  /**
+   * 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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ambari.apache.org
For additional commands, e-mail: commits-help@ambari.apache.org