[scotedublog commit] r149 - in trunk/seb/app: controllers views/stats

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 10, 2008, 2:42:35 PM4/10/08
to scotedubl...@googlegroups.com
Author: jonesieboy
Date: Thu Apr 10 11:08:41 2008
New Revision: 149

Modified:
trunk/seb/app/controllers/stats_controller.rb
trunk/seb/app/views/stats/summary.rhtml

Log:

open flash chart graphing


Modified: trunk/seb/app/controllers/stats_controller.rb
==============================================================================
--- trunk/seb/app/controllers/stats_controller.rb (original)
+++ trunk/seb/app/controllers/stats_controller.rb Thu Apr 10 11:08:41 2008
@@ -6,30 +6,76 @@
end

def summary
+ @graph = open_flash_chart_object(600,300, '/stats/per_day', false)
+ end
+
+ def per_day
@item_counts=[]
- @date_labels={}
+ @date_labels=[]
1.upto(30) do |i|
t=Time.now.at_midnight-60*60*24*i
@item_counts[30-i]=Item.date_count(t)
- @date_labels[30-i]=t.strftime("%d\r\n%b") if i.modulo(7)==0
+ @date_labels[30-i]=(Date.today-i+1).to_s
end
- g = Gruff::Bar.new(600)
- g.title = "Posts Over the Last 30 Days"
- #g.replace_colors(['#FA0', '#d9e043', '#34d8a2'])
-# g.theme = {
-# :colors => %w(green white red),
-# :marker_color => 'black',
-# :background_colors => %w(white grey)
-# }
- g. theme_rails_keynote()
- g.marker_font_size=15
- g.data("Posts", @item_counts)
- g.y_axis_increment=5
- #g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
- g.labels=@date_labels
- g.minimum_value=0
- g.write('images/stats.png')
-
+ g = Graph.new
+ g.title("Posts per Day", '{font-size: 26px;}')
+ g.set_data(@item_counts)
+ g.line(2,'0x80a033','Posts', 10)
+ g.set_x_labels(@date_labels)
+ g.set_x_label_style( 10, '#CC3399', 2 );
+ g.set_y_max(200)
+ g.set_y_label_steps(8)
+ render :text => g.render
+ end
+
+ def per_month
+ @item_counts=[]
+ @date_labels=[]
+ 1.upto(30) do |i|
+ t=Time.now.at_midnight-60*60*24*i
+ @item_counts[30-i]=Item.date_count(t)
+ @date_labels[30-i]=(Date.today-i+1).to_s
+ end
+ g = Graph.new
+ g.title("Posts per Day", '{font-size: 26px;}')
+ g.set_data(@item_counts)
+ g.line(2,'0x80a033','Posts', 10)
+ g.set_x_labels(@date_labels)
+ g.set_x_label_style( 10, '#CC3399', 2 );
+ g.set_y_max(200)
+ g.set_y_label_steps(8)
+ render :text => g.render
+ end
+
+ def testing
+ g = Graph.new
+ g.title( 'Users vs. Ram - 24h statistics', '{color: #7E97A6;
font-size: 20; text-align: center}' )
+ g.set_bg_color('#FFFFFF')
+ g.set_data([289,198,143,126,98,96,124,164,213,238,256,263,265,294,291,289,306,341,353,353,402,419,404,366,309])
+ g.line_dot( 2, 4, '#818D9D', 'Max Users', 10 )
+ g.set_data([698,1101,1324,1396,1568,1571,1496,1349,1140,1045,966,926,906,754,766,757,672,510,431,436,227,533,566,744,1004])
+ g.line_hollow( 2, 4, '#164166', 'Free Ram', 10 )
+ g.attach_to_y_right_axis(2)
+ g.set_y_max(600)
+ g.set_y_right_max(1700)
+ g.set_x_axis_color('#818D9D', '#F0F0F0' )
+ g.set_y_axis_color( '#818D9D', '#ADB5C7' )
+ g.y_right_axis_color('#164166' )
+ g.set_x_legend( 'My IRC Server', 12, '#164166' )
+ g.set_y_legend( 'Max Users', 12, '#164166' )
+ g.set_y_legend_right( 'Free Ram (MB)' ,12 , '#164166' )
+ tmp = []
+ (0..25).to_a.each do |x|
+ tmp << "#{x}:00"
+ end
+ g.set_x_labels(tmp)
+ g.set_x_label_style(10, '#164166', 0, 3, '#818D9D' )
+ g.set_y_label_steps(5)
+
+ render :text => g.render
+ end
+
+ def hourly
@item_counts=[]
@date_labels={}
0.upto(23) do |i|

Modified: trunk/seb/app/views/stats/summary.rhtml
==============================================================================
--- trunk/seb/app/views/stats/summary.rhtml (original)
+++ trunk/seb/app/views/stats/summary.rhtml Thu Apr 10 11:08:41 2008
@@ -1,3 +1,2 @@
<h1> Scotedublogs Statistics</h1>
-<div class="stat_image"><%=image_tag("stats.png")%></div>
-<div class="stat_image"><%=image_tag("hour_stats.png")%></div>
\ No newline at end of file
+<div class="stat_image"><%= @graph %></div>

Reply all
Reply to author
Forward
0 new messages