]> source.dussan.org Git - sonarqube.git/commitdiff
Update widgets to use localized dates and numbers from WS
authorStas Vilchik <vilchiks@gmail.com>
Thu, 9 Jan 2014 09:15:54 +0000 (15:15 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 9 Jan 2014 09:15:54 +0000 (15:15 +0600)
sonar-server/src/main/webapp/javascripts/widgets/bubble-chart.js
sonar-server/src/main/webapp/javascripts/widgets/histogram.js
sonar-server/src/main/webapp/javascripts/widgets/pie-chart.js

index 2b2c1910e87db0afbe016f09897a5a138daae75d..a913fb3c6e4c8ddcb2b448fee9b79a7bd203fe5d 100644 (file)
@@ -108,19 +108,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
       return d.measures[widget.sizeMetric].val;
     };
 
-    this.fm = function(value, name) {
-      var type = this.metrics()[name].type;
-
-      switch (type) {
-        case 'FLOAT':
-          return d3.format('.1f')(value);
-        case 'INT':
-          return d3.format('d')(value);
-        default :
-          return value;
-      }
-    };
-
 
     // Configure scales
     this
@@ -204,9 +191,9 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
           widget.infoDate.text(d.longName);
 
           var metricLines = [
-            { metric: widget.metrics()[widget.xMetric].name, value: widget.fm(widget.getXMetric(d), widget.xMetric) },
-            { metric: widget.metrics()[widget.yMetric].name, value: widget.fm(widget.getYMetric(d), widget.yMetric) },
-            { metric: widget.metrics()[widget.sizeMetric].name, value: widget.fm(widget.getSizeMetric(d), widget.sizeMetric) }
+            { metric: widget.metrics()[widget.xMetric].name, value: d.measures[widget.xMetric].fval },
+            { metric: widget.metrics()[widget.yMetric].name, value: d.measures[widget.yMetric].fval },
+            { metric: widget.metrics()[widget.sizeMetric].name, value: d.measures[widget.sizeMetric].fval }
           ];
 
           var lastX = 0;
index dad5ed09d6f28e83d4582d49a06bcaa1cce75c3b..ca8963ee478fa7322eeeeea4ca809df9fcc2c66b 100644 (file)
@@ -86,18 +86,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         return 0;
       }
     };
-    this.fm = function(value, name) {
-      var type = this.metrics()[name].type;
-
-      switch (type) {
-        case 'FLOAT':
-          return d3.format('.1f')(value);
-        case 'INT':
-          return d3.format('d')(value);
-        default :
-          return value;
-      }
-    };
 
 
     // Configure scales
@@ -234,7 +222,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         .append('text')
         .classed('legend-text value', true)
         .attr('dy', '-0.35em')
-        .text(function(d) { return widget.fm(widget.getMainMetric(d), widget.mainMetric); })
+        .text(function(d) { return d.measures[widget.mainMetric].fval; })
         .attr('transform', function(d) { return trans(widget.legendWidth() + widget.x(widget.getMainMetric(d)) + 5, barHeight); });
 
     this.bars.selectAll('rect')
index 89bb8dbaec570f665d1192ac4e99c7ed3ca807dd..3ce3be314b757fababdbf248d25fbb79457e5f74 100644 (file)
@@ -91,18 +91,6 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
         return 0;
       }
     };
-    this.fm = function(value, name) {
-      var type = this.metrics()[name].type;
-
-      switch (type) {
-        case 'FLOAT':
-          return d3.format('.1f')(value);
-        case 'INT':
-          return d3.format('d')(value);
-        default :
-          return value;
-      }
-    };
 
 
     // Configure scales
@@ -257,7 +245,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
             var metrics = widget.metricsPriority().map(function(m) {
               return {
                 name: widget.metrics()[m].name,
-                value: widget.fm(d.measures[m].val, m)
+                value: d.measures[m].fval
               };
             });
             metrics.unshift({ name: d.name });
@@ -272,7 +260,7 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
           }
           widget.donutLabel
               .style('opacity', 1)
-              .text(widget.fm(widget.getMainMetric(d), widget.mainMetric));
+              .text(d.measures[widget.mainMetric].fval);
           widget.donutLabel
               .style('opacity', 1);
           widget.donutLabel2