comparison lib/redmine/helpers/gantt.rb @ 1:cca12e1c1fd4

* Update to Redmine trunk (SVN revisions 3860-3892)
author Chris Cannam
date Wed, 28 Jul 2010 12:08:28 +0100
parents 513646585e45
children 40f7cfd4df19
comparison
equal deleted inserted replaced
0:513646585e45 1:cca12e1c1fd4
89 { :year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months } 89 { :year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months }
90 end 90 end
91 91
92 # Generates a gantt image 92 # Generates a gantt image
93 # Only defined if RMagick is avalaible 93 # Only defined if RMagick is avalaible
94 def to_image(format='PNG') 94 def to_image(project, format='PNG')
95 date_to = (@date_from >> @months)-1 95 date_to = (@date_from >> @months)-1
96 show_weeks = @zoom > 1 96 show_weeks = @zoom > 1
97 show_days = @zoom > 2 97 show_days = @zoom > 2
98 98
99 subject_width = 320 99 subject_width = 400
100 header_heigth = 18 100 header_heigth = 18
101 # width of one day in pixels 101 # width of one day in pixels
102 zoom = @zoom*2 102 zoom = @zoom*2
103 g_width = (@date_to - @date_from + 1)*zoom 103 g_width = (@date_to - @date_from + 1)*zoom
104 g_height = 20 * events.length + 20 104 g_height = 20 * events.length + 20
113 top = headers_heigth + 20 113 top = headers_heigth + 20
114 gc.fill('black') 114 gc.fill('black')
115 gc.stroke('transparent') 115 gc.stroke('transparent')
116 gc.stroke_width(1) 116 gc.stroke_width(1)
117 events.each do |i| 117 events.each do |i|
118 gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name)) 118 text = ""
119 if i.is_a? Issue
120 text = "#{i.tracker} #{i.id}: #{i.subject}"
121 else
122 text = i.name
123 end
124 text = "#{i.project} - #{text}" unless project && project == i.project
125 gc.text(4, top + 2, text)
119 top = top + 20 126 top = top + 20
120 end 127 end
121 128
122 # Months headers 129 # Months headers
123 month_f = @date_from 130 month_f = @date_from