changed chart for actions in the past 12 months to interpolate the current month. Also updated the open-flahs-chart to the latest version and removed a small error (corner case) in completion_time chart

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@631 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lrbalt 2007-11-05 12:45:00 +00:00
parent b440e2b2ee
commit ff90b6d737
4 changed files with 24 additions and 20 deletions

View file

@ -93,6 +93,11 @@ class StatsController < ApplicationController
@actions_created_last12months_hash[i+2])/3.0
}
# interpolate avg for this month. Assume 31 days in this month
days_passed_this_month = Time.new.day/1.0
@interpolated_actions_created_this_month = @actions_created_last12months_hash[0]/days_passed_this_month*31.0
@interpolated_actions_done_this_month = @actions_done_last12months_hash[0]/days_passed_this_month*31.0
render :layout => false
end

View file

@ -6,32 +6,33 @@
&filled_bar=50,0x9933CC,0x8010A0&
&values=
<% @count = @max_days > @cut_off*7 ? @cut_off : @max_days/7
0.upto @count-1 do |i| -%>
<%= @actions_completion_time_hash[i] -%>,
@count = @count.to_i
0.upto @count-1 do |i| -%>
<%= @actions_completion_time_hash[i] -%>,
<% end -%>
<%
@sum=0
@count.upto @max_days/7 do |i|
@sum += @actions_completion_time_hash[i]
end -%>
@sum=0
@count.upto @max_days/7 do |i|
@sum += @actions_completion_time_hash[i]
end -%>
<%=@sum%>&
&line_2=2,0xFF0000&
&values_2=
<% total=0
@count = @max_days > @cut_off*7 ? @cut_off : @max_days/7
0.upto @count-1 do |i|
total += @actions_completion_time_hash[i]*100.0/@sum_actions -%>
<%= total -%>,
@count = @max_days > @cut_off*7 ? @cut_off : @max_days/7
0.upto @count-1 do |i|
total += @actions_completion_time_hash[i]*100.0/@sum_actions -%>
<%= total -%>,
<% end -%>
<%= total+@sum*100.0/@sum_actions%>&
&x_labels=within 1,
<% 1.upto @count-1 do |i| -%>
<%= i %>-<%= i+1 %>,
<%= i %>-<%= i+1 %>,
<% end -%>
> <%= @count %>&
&y_min=0&
<% # add one to @max for people who have no actions completed yet.
# OpenFlashChart cannot handle y_max=0 -%>
# OpenFlashChart cannot handle y_max=0 -%>
&y_max=<%=1+@max_actions+@max_actions/10-%>&
&show_y2=true&
&y2_lines=2&

View file

@ -8,18 +8,16 @@
&line_4=2,0x00FF00, Avg created, 9&
&line_5=2,0xAA0000, 3 Month Avg Completed, 9&
&line_6=2,0x007700, 3 Month Avg Created, 9&
&values=
<% 0.upto 11 do |i| -%>
<%= @actions_done_last12months_hash[i]%>,
<% end -%><%= @actions_done_last12months_hash[12]%>&
&values_2=
<% 0.upto 11 do |i| -%>
<%= @actions_created_last12months_hash[i]%>,
<% end -%><%= @actions_created_last12months_hash[12]%>&
&line_7=1,0xAA0000&
&line_8=1,0x007700&
&values=<% 0.upto 11 do |i| -%><%= @actions_done_last12months_hash[i]%>,<% end -%><%= @actions_done_last12months_hash[12]%>&
&values_2=<% 0.upto 11 do |i| -%><%= @actions_created_last12months_hash[i]%>,<% end -%><%= @actions_created_last12months_hash[12]%>&
&values_3=<%0.upto 11 do |i| -%><%=@sum_actions_done_last12months/12-%>,<%end-%><%=@sum_actions_done_last12months/12-%>&
&values_4=<%0.upto 11 do |i| -%><%=@sum_actions_created_last12months/12-%>,<%end-%><%=@sum_actions_created_last12months/12-%>&
&values_5=<%0.upto 11 do |i| -%><%=@actions_done_avg_last12months_hash[i]-%>,<%end-%><%=@actions_done_avg_last12months_hash[12]-%>&
&values_6=<%0.upto 11 do |i| -%><%=@actions_created_avg_last12months_hash[i]-%>,<%end-%><%=@actions_created_avg_last12months_hash[12]-%>&
&values_7=<%=@interpolated_actions_created_this_month%>,<%=@actions_done_avg_last12months_hash[1]%>&
&values_8=<%=@interpolated_actions_done_this_month%>,<%=@actions_created_avg_last12months_hash[1]%>&
&x_labels=<%0.upto 11 do |i| -%>
<%= Date::MONTHNAMES[ (Time.now.mon - i -1 ) % 12 + 1 ] -%>,
<% end -%>