From: Fabrice Bellingard Date: Wed, 31 Aug 2011 16:58:07 +0000 (+0200) Subject: SONAR-2074 Fix display bug caused by Protovis limitation X-Git-Tag: 2.11^2~109 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8e085c96accc9c912747df5c8b93c8a0bc85ad95;p=sonarqube.git SONAR-2074 Fix display bug caused by Protovis limitation If the array used to display the Y axis contains only data with the exact same value, Protovis function y() returns NaN, which makes it impossible to display the line for the given array. --- diff --git a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js index a2854578fb4..840ae49a3bb 100755 --- a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js +++ b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js @@ -47,15 +47,15 @@ SonarWidgets.Timeline.prototype.render = function() { var show_y_axis = (data.length==1) /* Sizing and scales. */ - var footerHeight = 4 + Math.max(this.wMetrics.size(), events ? 2 : 1) * 18; - var w = widgetDiv.parentNode.clientWidth - 60, - h = (this.wHeight == null ? 80 : this.wHeight) + footerHeight, - S=2; + var headerHeight = 4 + Math.max(this.wMetrics.size(), events ? 2 : 1) * 18; + var w = widgetDiv.parentNode.clientWidth - 60; + var h = (this.wHeight == null ? 80 : this.wHeight) + headerHeight; + var yMaxHeight = h-headerHeight; var x = pv.Scale.linear(pv.blend(pv.map(data, function(d) {return d;})), function(d) {return d.x}).range(0, w); var y = new Array(data.length); for(var i = 0; i < data.length; i++){ - y[i]=pv.Scale.linear(data[i], function(d) {return d.y;}).range(20, h-footerHeight) + y[i]=pv.Scale.linear(data[i], function(d) {return d.y;}).range(20, yMaxHeight); } var interpolate = "linear"; /* cardinal or linear */ var idx = this.wData[0].size() - 1; @@ -89,7 +89,7 @@ SonarWidgets.Timeline.prototype.render = function() { var line = panel.add(pv.Line) .data(function(array) {return array;}) .left(function(d) {return x(d.x);}) - .bottom(function(d) {return y[this.parent.index](d.y);}) + .bottom(function(d) {var yAxis = y[this.parent.index](d.y); return isNaN(yAxis) ? yMaxHeight : yAxis;}) .interpolate(function() {return interpolate;}) .lineWidth(2);