I am building a time registration program. Users can work on a project, and I want to display in a chart how many hours each user worked on a project, let's say, each month. The chart plugin works like this:
first_serie = OpenFlashChartLazy::Serie.new(
[["2008-1",100],["2008-2",120],["2008-3",130]],
{:title=>"name_of_user1",:start_date=>Time.mktime(2008,1,1),:items=>8})
This adds a new line in the graph.
My question is how can I loop through all my users and for each fill a new series with data from the database?
As a follow up to Pesto would be nicer to use inject.
@series = User.all.inject([]) do |mem, user|
mem << OpenFlashChartLazy::Serie.new(user.foo, user.bar, user.foobarbob)
end
Same code, just doesnt have a @series = []