From 89ed7ca079f1db2c362fbee7fcd835995d68a46d Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Fri, 9 Sep 2011 10:13:48 +0200 Subject: [PATCH] SONAR-2074 Improve Timeline widget style - Apply same event style as for the stack area chart - Fix bug in event display (displays too many events) --- .../org/sonar/plugins/core/widgets/timeline.html.erb | 9 ++++++++- .../src/main/webapp/javascripts/protovis-sonar.js | 12 +++++++----- 2 files changed, 15 insertions(+), 6 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 58f6fe9376d..73b0d9a951b 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 @@ -72,7 +72,14 @@ # Prepare also event structure if required unless widget_properties["hideEvents"] events = {} - Event.find(:all, :conditions => {:resource_id => @resource.id}, :order => 'event_date').each() do |event| + unless from_date + # find the oldest date + metric_data_map.values.each() do |metric_data_array| + first_date = Time.parse(metric_data_array[0][:date]) + from_date = first_date if !from_date || from_date > first_date + end + end + Event.find(:all, :conditions => ["resource_id=? AND event_date>=?", @resource.id, from_date], :order => 'event_date').each() do |event| if events[event.event_date] events[event.event_date] << event else diff --git a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js index f80836031b5..2ae43a256a5 100755 --- a/sonar-server/src/main/webapp/javascripts/protovis-sonar.js +++ b/sonar-server/src/main/webapp/javascripts/protovis-sonar.js @@ -302,7 +302,7 @@ SonarWidgets.Timeline.prototype.render = function() { .height(h) .left(20) .right(20) - .bottom(20) + .bottom(30) .top(5) .strokeStyle("#CCC"); @@ -310,8 +310,8 @@ SonarWidgets.Timeline.prototype.render = function() { vis.add(pv.Rule) .data(x.ticks()) .left(x) - .bottom(-5) - .height(5) + .bottom(-10) + .height(10) .anchor("bottom") .add(pv.Label) .text(x.tickFormat); @@ -361,8 +361,9 @@ SonarWidgets.Timeline.prototype.render = function() { .bottom(0) .anchor("top") .add(pv.Dot) - .bottom(6) + .bottom(-6) .shape("triangle") + .angle(pv.radians(180)) .strokeStyle("grey") .fillStyle(function(e) {return e.sid == snapshots[idx].sid ? eventHoverColor : eventColor;}) .add(pv.Dot) @@ -382,7 +383,8 @@ SonarWidgets.Timeline.prototype.render = function() { /* An invisible bar to capture events (without flickering). */ vis.add(pv.Bar) .fillStyle("rgba(0,0,0,.001)") - .width(w+10) + .width(w+30) + .height(h+30) .event("mouseout", function() { i = -1; return vis; -- 2.39.5