* updates the Open Flash Chart to latest version which containts bugfixes

* updates the pie charts to truncate the labels. Long labels causes the pie chart to become very small
* updates the 12 month chart so that the current month includes the averages from the past 2 months

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@666 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lrbalt 2007-12-02 13:04:33 +00:00
parent e6f42cd341
commit ba56090ee0
4 changed files with 60 additions and 17 deletions

View file

@ -95,8 +95,15 @@ class StatsController < ApplicationController
# 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
@interpolated_actions_created_this_month = (
@actions_created_last12months_hash[0]/days_passed_this_month*31.0+
@actions_created_last12months_hash[1]+
@actions_created_last12months_hash[2]) / 3.0
@interpolated_actions_done_this_month = (
@actions_done_last12months_hash[0]/days_passed_this_month*31.0 +
@actions_done_last12months_hash[1]+
@actions_done_last12months_hash[2]) / 3.0
render :layout => false
end
@ -242,7 +249,7 @@ class StatsController < ApplicationController
def context_total_actions_data
# get total action count per context
@actions_per_context = @contexts.find_by_sql(
@all_actions_per_context = @contexts.find_by_sql(
"SELECT c.name AS name, count(*) AS total "+
"FROM contexts c, todos t "+
"WHERE t.context_id=c.id "+
@ -250,18 +257,36 @@ class StatsController < ApplicationController
"GROUP BY c.id "+
"ORDER BY total DESC"
)
@sum=0
0.upto @actions_per_context.size()-1 do |i|
@sum += @actions_per_context[i]['total'].to_i
pie_cutoff=10
size = @all_actions_per_context.size()
size = pie_cutoff if size > pie_cutoff
@actions_per_context = Array.new(size)
0.upto size-1 do |i|
@actions_per_context[i] = @all_actions_per_context[i]
end
if size==pie_cutoff
@actions_per_context[size-1]['name']='(others)'
@actions_per_context[size-1]['total']=0
(size-1).upto @all_actions_per_context.size()-1 do |i|
@actions_per_context[size-1]['total']+=@all_actions_per_context[i]['total'].to_i
end
end
@sum=0
0.upto @all_actions_per_context.size()-1 do |i|
@sum += @all_actions_per_context[i]['total'].to_i
end
@truncate_chars = 15
render :layout => false
end
def context_running_actions_data
# get uncompleted action count per visible context
@actions_per_context = @contexts.find_by_sql(
@all_actions_per_context = @contexts.find_by_sql(
"SELECT c.name AS name, count(*) AS total "+
"FROM contexts c, todos t "+
"WHERE t.context_id=c.id AND t.completed_at IS NULL AND NOT c.hide "+
@ -269,12 +294,30 @@ class StatsController < ApplicationController
"GROUP BY c.id "+
"ORDER BY total DESC"
)
pie_cutoff=10
size = @all_actions_per_context.size()
size = pie_cutoff if size > pie_cutoff
@actions_per_context = Array.new(size)
0.upto size-1 do |i|
@actions_per_context[i] = @all_actions_per_context[i]
end
if size==pie_cutoff
@actions_per_context[size-1]['name']='(others)'
@actions_per_context[size-1]['total']=0
(size-1).upto @all_actions_per_context.size()-1 do |i|
@actions_per_context[size-1]['total']+=@all_actions_per_context[i]['total'].to_i
end
end
@sum=0
0.upto @actions_per_context.size()-1 do |i|
@sum += @actions_per_context[i]['total'].to_i
0.upto @all_actions_per_context.size()-1 do |i|
@sum += @all_actions_per_context[i]['total'].to_i
end
@truncate_chars = 15
render :layout => false
end

View file

@ -8,9 +8,9 @@ end
-%><%=@actions_per_context[@actions_per_context.size()-1]['total'].to_i*100/@sum%>&
&pie_labels=<%
0.upto @actions_per_context.size()-2 do | i |
%><%=@actions_per_context[i]['name']%>,<%
%><%=truncate(@actions_per_context[i]['name'],@truncate_chars, '...')%>,<%
end
-%><%=@actions_per_context[@actions_per_context.size()-1]['name']%>&
-%><%=truncate(@actions_per_context[@actions_per_context.size()-1]['name'],@truncate_chars,'...') %>&
&colours=#d01f3c,#356aa0,#C79810,#c61fd0,#1fc6d0,#1fd076,#72d01f,#c6d01f,#d0941f&
&tool_tip=#x_label#: #val#%25&
&x_label_style=9,,2,1&

View file

@ -8,9 +8,9 @@ end
-%><%=@actions_per_context[@actions_per_context.size()-1]['total'].to_i*100/@sum%>&
&pie_labels=<%
0.upto @actions_per_context.size()-2 do | i |
%><%=@actions_per_context[i]['name']%>,<%
%><%=truncate(@actions_per_context[i]['name'], @truncate_chars, '...') %>,<%
end
-%><%=@actions_per_context[@actions_per_context.size()-1]['name']%>&
&colours=#d01f3c,#356aa0,#C79810,#c61fd0,#1fc6d0,#1fd076,#72d01f,#c6d01f,#d0941f&
-%><%=truncate(@actions_per_context[@actions_per_context.size()-1]['name'], @truncate_chars, '...') %>&
&colours=#d01f3c,#356aa0,#C79810,#c61fd0,#1fc6d0,#1fd076,#72d01f,#c6d01f,#d0941f,#40941f&
&tool_tip=#x_label#: #val#%25&
&x_label_style=9,,2,1&