aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-09-01 17:46:11 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-09-01 17:46:11 +0200
commitd76c641b9f6ad77d26f1bc80f850ed3b2496a91d (patch)
tree55b2fd7106a5496bdc3866290b5117316f90128b
parentda984a8349a5d847b9dace6a6d5c8b4f1b3f7dc1 (diff)
downloadsonarqube-d76c641b9f6ad77d26f1bc80f850ed3b2496a91d.tar.gz
sonarqube-d76c641b9f6ad77d26f1bc80f850ed3b2496a91d.zip
SONAR-2074 Update the JS script + JS data generation to fix bug on IE
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb28
-rwxr-xr-xsonar-server/src/main/webapp/javascripts/protovis-sonar.js14
2 files changed, 21 insertions, 21 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb
index e8987f98ca4..224099ade83 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb
@@ -38,7 +38,7 @@
js_data += "["
metric_data_map[metric_id].each() do |metric_data|
m_date = Time.parse(metric_data[:date])
- js_data += "{\"x\":d("
+ js_data += "{x:d("
js_data += m_date.year.to_s
js_data += ","
# Need to decrease by 1 the month as the JS Date object start months at 0 (= January)
@@ -51,24 +51,24 @@
js_data += m_date.min.to_s
js_data += ","
js_data += m_date.sec.to_s
- js_data += "),\"y\":"
+ js_data += "),y:"
js_data += sprintf( "%0.02f", metric_data[:value])
js_data += "},"
if index == 0
# we fill the js_snapshots array (no need to do this more than once)
- js_snapshots += "{\"sid\":"
+ js_snapshots += "{sid:"
js_snapshots += metric_data[:sid]
- js_snapshots += ",\"d\":\""
+ js_snapshots += ",d:\""
js_snapshots += l m_date, :format => :long
js_snapshots += "\"},"
end
end
- js_data += "],"
+ js_data = js_data.chomp(',') + "],"
end
end
- js_data += "]"
- js_snapshots += "]"
- js_metrics += "]"
+ js_data = js_data.chomp(',') + "]"
+ js_snapshots = js_snapshots.chomp(',') + "]"
+ js_metrics = js_metrics.chomp(',') + "]"
# Prepare also event structure if required
unless widget_properties["hideEvents"]
@@ -84,9 +84,9 @@
js_events = "["
events.keys().sort.each() do |e_date|
e_details = events[e_date]
- js_events += "{\"sid\":"
+ js_events += "{sid:"
js_events += e_details[0].snapshot_id.to_s
- js_events += ",\"d\":d("
+ js_events += ",d:d("
js_events += e_date.year.to_s
js_events += ","
# Need to decrease by 1 the month as the JS Date object start months at 0 (= January)
@@ -99,15 +99,15 @@
js_events += e_date.min.to_s
js_events += ","
js_events += e_date.sec.to_s
- js_events += "),\"l\":["
+ js_events += "),l:["
e_details.each() do |e|
- js_events += "{\"n\":\""
+ js_events += "{n:\""
js_events += e.name
js_events += "\"},"
end
- js_events += "]},"
+ js_events = js_events.chomp(',') + "]},"
end
- js_events += "]"
+ js_events = js_events.chomp(',') + "]"
end
# And prepare translations for labels
diff --git a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js
index 840ae49a3bb..5590d9387e9 100755
--- a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js
+++ b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js
@@ -41,10 +41,10 @@ SonarWidgets.Timeline.prototype.render = function() {
var snapshots = this.wSnapshots;
var translations = this.wTranslations;
var events = this.wEvents;
- var widgetDiv = document.getElementById(this.wDivId);
+ var widgetDiv = document.getElementById(this.wDivId);
var footerFont = "10.5px Arial,Helvetica,sans-serif";
- var show_y_axis = (data.length==1)
+ var show_y_axis = (trendData.size()==1)
/* Sizing and scales. */
var headerHeight = 4 + Math.max(this.wMetrics.size(), events ? 2 : 1) * 18;
@@ -52,10 +52,10 @@ SonarWidgets.Timeline.prototype.render = function() {
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, yMaxHeight);
+ var x = pv.Scale.linear(pv.blend(pv.map(trendData, function(d) {return d;})), function(d) {return d.x}).range(0, w);
+ var y = new Array(trendData.size());
+ for(var i = 0; i < trendData.size(); i++){
+ y[i]=pv.Scale.linear(trendData[i], function(d) {return d.y;}).range(20, yMaxHeight);
}
var interpolate = "linear"; /* cardinal or linear */
var idx = this.wData[0].size() - 1;
@@ -154,7 +154,7 @@ SonarWidgets.Timeline.prototype.render = function() {
})
.event("mousemove", function() {
var mx = x.invert(vis.mouse().x);
- idx = pv.search(data[0].map(function(d) {return d.x;}), mx);
+ idx = pv.search(trendData[0].map(function(d) {return d.x;}), mx);
idx = idx < 0 ? (-idx - 2) : idx;
idx = idx < 0 ? 0 : idx;
return vis;