Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ruby many-to-many table query
- Work
- int id
- int status_id
- Team
- int id
- string name (A,B,C,D)
- Assignment
- int id
- int work_id
- int team_id
- date date
- Status
- int id
- string name (done,ongoing,idle)
- b = Gruff::StackedBar.new('600x350')
- @teams = Team.find(:all)
- @statuses = Status.find(:all)
- @names = Array.new
- @list2 = Array.new
- # data collection
- @teams.each do |e|
- @list2 << e.works.count(:all,:group=>"status_id")
- @names << e.name
- end
- # for the labels
- @keys = Hash[*@names.sort.collect {|v| [@names.sort.index(v),v.to_s] }.flatten]
- b.labels = @keys
- # Plot the data into graph
- (0..@list2.length-3).each do |i|
- b.data("#{@statuses[i].name2 unless @statuses[i].name2.nil?}", @keys.sort.collect {|k,v| @list2[i][k].nil? ? 0 : @list2[i][k]})
- end
- b.write("#{RAILS_ROOT}/public/images/tcr.png")
- render(:layout => false)
Add Comment
Please, Sign In to add comment