annotate lib/redmine/helpers/.svn/text-base/gantt.rb.svn-base @ 879:8fb3bed996c3 feature_115

Close obsolete branch feature_115
author Chris Cannam
date Sat, 26 Mar 2011 15:07:00 +0000
parents 94944d00e43c
children af80e5618e9b
rev   line source
Chris@0 1 # Redmine - project management software
Chris@0 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 module Redmine
Chris@0 19 module Helpers
Chris@0 20 # Simple class to handle gantt chart data
Chris@0 21 class Gantt
chris@22 22 include ERB::Util
chris@22 23 include Redmine::I18n
chris@22 24
chris@22 25 # :nodoc:
chris@22 26 # Some utility methods for the PDF export
chris@22 27 class PDF
chris@22 28 MaxCharactorsForSubject = 45
chris@22 29 TotalWidth = 280
chris@22 30 LeftPaneWidth = 100
chris@22 31
chris@22 32 def self.right_pane_width
chris@22 33 TotalWidth - LeftPaneWidth
chris@22 34 end
chris@22 35 end
chris@22 36
chris@22 37 attr_reader :year_from, :month_from, :date_from, :date_to, :zoom, :months
chris@22 38 attr_accessor :query
chris@22 39 attr_accessor :project
chris@22 40 attr_accessor :view
chris@22 41
Chris@0 42 def initialize(options={})
Chris@0 43 options = options.dup
Chris@0 44
Chris@0 45 if options[:year] && options[:year].to_i >0
Chris@0 46 @year_from = options[:year].to_i
Chris@0 47 if options[:month] && options[:month].to_i >=1 && options[:month].to_i <= 12
Chris@0 48 @month_from = options[:month].to_i
Chris@0 49 else
Chris@0 50 @month_from = 1
Chris@0 51 end
Chris@0 52 else
Chris@0 53 @month_from ||= Date.today.month
Chris@0 54 @year_from ||= Date.today.year
Chris@0 55 end
Chris@0 56
Chris@0 57 zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
Chris@0 58 @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
Chris@0 59 months = (options[:months] || User.current.pref[:gantt_months]).to_i
Chris@0 60 @months = (months > 0 && months < 25) ? months : 6
Chris@0 61
Chris@0 62 # Save gantt parameters as user preference (zoom and months count)
Chris@0 63 if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months]))
Chris@0 64 User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
Chris@0 65 User.current.preference.save
Chris@0 66 end
Chris@0 67
Chris@0 68 @date_from = Date.civil(@year_from, @month_from, 1)
Chris@0 69 @date_to = (@date_from >> @months) - 1
Chris@0 70 end
chris@22 71
chris@22 72 def common_params
chris@22 73 { :controller => 'gantts', :action => 'show', :project_id => @project }
Chris@0 74 end
Chris@0 75
Chris@0 76 def params
chris@22 77 common_params.merge({ :zoom => zoom, :year => year_from, :month => month_from, :months => months })
Chris@0 78 end
Chris@0 79
Chris@0 80 def params_previous
chris@22 81 common_params.merge({:year => (date_from << months).year, :month => (date_from << months).month, :zoom => zoom, :months => months })
Chris@0 82 end
Chris@0 83
Chris@0 84 def params_next
chris@22 85 common_params.merge({:year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months })
Chris@0 86 end
chris@22 87
chris@22 88 ### Extracted from the HTML view/helpers
chris@22 89 # Returns the number of rows that will be rendered on the Gantt chart
chris@22 90 def number_of_rows
chris@22 91 if @project
chris@22 92 return number_of_rows_on_project(@project)
chris@22 93 else
chris@22 94 Project.roots.inject(0) do |total, project|
chris@22 95 total += number_of_rows_on_project(project)
chris@22 96 end
chris@22 97 end
chris@22 98 end
chris@22 99
chris@22 100 # Returns the number of rows that will be used to list a project on
chris@22 101 # the Gantt chart. This will recurse for each subproject.
chris@22 102 def number_of_rows_on_project(project)
chris@22 103 # Remove the project requirement for Versions because it will
chris@22 104 # restrict issues to only be on the current project. This
chris@22 105 # ends up missing issues which are assigned to shared versions.
chris@22 106 @query.project = nil if @query.project
chris@22 107
chris@22 108 # One Root project
chris@22 109 count = 1
chris@22 110 # Issues without a Version
chris@22 111 count += project.issues.for_gantt.without_version.with_query(@query).count
chris@22 112
chris@22 113 # Versions
chris@22 114 count += project.versions.count
chris@22 115
chris@22 116 # Issues on the Versions
chris@22 117 project.versions.each do |version|
chris@22 118 count += version.fixed_issues.for_gantt.with_query(@query).count
chris@22 119 end
chris@22 120
chris@22 121 # Subprojects
chris@22 122 project.children.each do |subproject|
chris@22 123 count += number_of_rows_on_project(subproject)
chris@22 124 end
chris@22 125
chris@22 126 count
chris@22 127 end
chris@22 128
chris@22 129 # Renders the subjects of the Gantt chart, the left side.
chris@22 130 def subjects(options={})
chris@22 131 options = {:indent => 4, :render => :subject, :format => :html}.merge(options)
chris@22 132
chris@22 133 output = ''
chris@22 134 if @project
chris@22 135 output << render_project(@project, options)
chris@22 136 else
chris@22 137 Project.roots.each do |project|
chris@22 138 output << render_project(project, options)
chris@22 139 end
chris@22 140 end
chris@22 141
chris@22 142 output
chris@22 143 end
chris@22 144
chris@22 145 # Renders the lines of the Gantt chart, the right side
chris@22 146 def lines(options={})
chris@22 147 options = {:indent => 4, :render => :line, :format => :html}.merge(options)
chris@22 148 output = ''
chris@22 149
chris@22 150 if @project
chris@22 151 output << render_project(@project, options)
chris@22 152 else
chris@22 153 Project.roots.each do |project|
chris@22 154 output << render_project(project, options)
chris@22 155 end
chris@22 156 end
chris@22 157
chris@22 158 output
chris@22 159 end
chris@22 160
chris@22 161 def render_project(project, options={})
chris@22 162 options[:top] = 0 unless options.key? :top
chris@22 163 options[:indent_increment] = 20 unless options.key? :indent_increment
chris@22 164 options[:top_increment] = 20 unless options.key? :top_increment
chris@22 165
chris@22 166 output = ''
chris@22 167 # Project Header
chris@22 168 project_header = if options[:render] == :subject
chris@22 169 subject_for_project(project, options)
chris@22 170 else
chris@22 171 # :line
chris@22 172 line_for_project(project, options)
chris@22 173 end
chris@22 174 output << project_header if options[:format] == :html
chris@22 175
chris@22 176 options[:top] += options[:top_increment]
chris@22 177 options[:indent] += options[:indent_increment]
chris@22 178
chris@22 179 # Second, Issues without a version
chris@22 180 issues = project.issues.for_gantt.without_version.with_query(@query)
chris@22 181 if issues
chris@22 182 issue_rendering = render_issues(issues, options)
chris@22 183 output << issue_rendering if options[:format] == :html
chris@22 184 end
chris@22 185
chris@22 186 # Third, Versions
chris@22 187 project.versions.sort.each do |version|
chris@22 188 version_rendering = render_version(version, options)
chris@22 189 output << version_rendering if options[:format] == :html
chris@22 190 end
chris@22 191
chris@22 192 # Fourth, subprojects
chris@22 193 project.children.each do |project|
chris@22 194 subproject_rendering = render_project(project, options)
chris@22 195 output << subproject_rendering if options[:format] == :html
chris@22 196 end
chris@22 197
chris@22 198 # Remove indent to hit the next sibling
chris@22 199 options[:indent] -= options[:indent_increment]
chris@22 200
chris@22 201 output
chris@22 202 end
chris@22 203
chris@22 204 def render_issues(issues, options={})
chris@22 205 output = ''
chris@22 206 issues.each do |i|
chris@22 207 issue_rendering = if options[:render] == :subject
chris@22 208 subject_for_issue(i, options)
chris@22 209 else
chris@22 210 # :line
chris@22 211 line_for_issue(i, options)
chris@22 212 end
chris@22 213 output << issue_rendering if options[:format] == :html
chris@22 214 options[:top] += options[:top_increment]
chris@22 215 end
chris@22 216 output
chris@22 217 end
chris@22 218
chris@22 219 def render_version(version, options={})
chris@22 220 output = ''
chris@22 221 # Version header
chris@22 222 version_rendering = if options[:render] == :subject
chris@22 223 subject_for_version(version, options)
chris@22 224 else
chris@22 225 # :line
chris@22 226 line_for_version(version, options)
chris@22 227 end
chris@22 228
chris@22 229 output << version_rendering if options[:format] == :html
chris@22 230
chris@22 231 options[:top] += options[:top_increment]
chris@22 232
chris@22 233 # Remove the project requirement for Versions because it will
chris@22 234 # restrict issues to only be on the current project. This
chris@22 235 # ends up missing issues which are assigned to shared versions.
chris@22 236 @query.project = nil if @query.project
chris@22 237
chris@22 238 issues = version.fixed_issues.for_gantt.with_query(@query)
chris@22 239 if issues
chris@22 240 # Indent issues
chris@22 241 options[:indent] += options[:indent_increment]
chris@22 242 output << render_issues(issues, options)
chris@22 243 options[:indent] -= options[:indent_increment]
chris@22 244 end
chris@22 245
chris@22 246 output
chris@22 247 end
chris@22 248
chris@22 249 def subject_for_project(project, options)
chris@22 250 case options[:format]
chris@22 251 when :html
chris@22 252 output = ''
chris@22 253
chris@22 254 output << "<div class='project-name' style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:#{options[:indent]}px;overflow:hidden;'><small> "
chris@22 255 if project.is_a? Project
chris@22 256 output << "<span class='icon icon-projects #{project.overdue? ? 'project-overdue' : ''}'>"
chris@22 257 output << view.link_to_project(project)
chris@22 258 output << '</span>'
chris@22 259 else
chris@22 260 ActiveRecord::Base.logger.debug "Gantt#subject_for_project was not given a project"
chris@22 261 ''
chris@22 262 end
chris@22 263 output << "</small></div>"
chris@22 264
chris@22 265 output
chris@22 266 when :image
chris@22 267
chris@22 268 options[:image].fill('black')
chris@22 269 options[:image].stroke('transparent')
chris@22 270 options[:image].stroke_width(1)
chris@22 271 options[:image].text(options[:indent], options[:top] + 2, project.name)
chris@22 272 when :pdf
chris@22 273 options[:pdf].SetY(options[:top])
chris@22 274 options[:pdf].SetX(15)
chris@22 275
chris@22 276 char_limit = PDF::MaxCharactorsForSubject - options[:indent]
chris@22 277 options[:pdf].Cell(options[:subject_width]-15, 5, (" " * options[:indent]) +"#{project.name}".sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR")
chris@22 278
chris@22 279 options[:pdf].SetY(options[:top])
chris@22 280 options[:pdf].SetX(options[:subject_width])
chris@22 281 options[:pdf].Cell(options[:g_width], 5, "", "LR")
chris@22 282 end
chris@22 283 end
chris@22 284
chris@22 285 def line_for_project(project, options)
chris@37 286 # Skip versions that don't have a start_date or due date
chris@37 287 if project.is_a?(Project) && project.start_date && project.due_date
chris@22 288 options[:zoom] ||= 1
chris@22 289 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
chris@22 290
chris@22 291
chris@22 292 case options[:format]
chris@22 293 when :html
chris@22 294 output = ''
chris@22 295 i_left = ((project.start_date - self.date_from)*options[:zoom]).floor
chris@22 296
chris@22 297 start_date = project.start_date
chris@22 298 start_date ||= self.date_from
chris@22 299 start_left = ((start_date - self.date_from)*options[:zoom]).floor
chris@22 300
chris@22 301 i_end_date = ((project.due_date <= self.date_to) ? project.due_date : self.date_to )
chris@22 302 i_done_date = start_date + ((project.due_date - start_date+1)* project.completed_percent(:include_subprojects => true)/100).floor
chris@22 303 i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
chris@22 304 i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
chris@22 305
chris@22 306 i_late_date = [i_end_date, Date.today].min if start_date < Date.today
chris@22 307 i_end = ((i_end_date - self.date_from) * options[:zoom]).floor
chris@22 308
chris@22 309 i_width = (i_end - i_left + 1).floor - 2 # total width of the issue (- 2 for left and right borders)
chris@22 310 d_width = ((i_done_date - start_date)*options[:zoom]).floor - 2 # done width
chris@22 311 l_width = i_late_date ? ((i_late_date - start_date+1)*options[:zoom]).floor - 2 : 0 # delay width
chris@22 312
chris@22 313 # Bar graphic
chris@22 314
chris@22 315 # Make sure that negative i_left and i_width don't
chris@22 316 # overflow the subject
chris@22 317 if i_end > 0 && i_left <= options[:g_width]
chris@22 318 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ i_width }px;' class='task project_todo'>&nbsp;</div>"
chris@22 319 end
chris@22 320
chris@22 321 if l_width > 0 && i_left <= options[:g_width]
chris@22 322 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ l_width }px;' class='task project_late'>&nbsp;</div>"
chris@22 323 end
chris@22 324 if d_width > 0 && i_left <= options[:g_width]
chris@22 325 output<< "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ d_width }px;' class='task project_done'>&nbsp;</div>"
chris@22 326 end
chris@22 327
chris@22 328
chris@22 329 # Starting diamond
chris@22 330 if start_left <= options[:g_width] && start_left > 0
chris@22 331 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:15px;' class='task project-line starting'>&nbsp;</div>"
chris@22 332 output << "<div style='top:#{ options[:top] }px;left:#{ start_left + 12 }px;' class='task label'>"
chris@22 333 output << "</div>"
chris@22 334 end
chris@22 335
chris@22 336 # Ending diamond
chris@22 337 # Don't show items too far ahead
chris@22 338 if i_end <= options[:g_width] && i_end > 0
chris@22 339 output << "<div style='top:#{ options[:top] }px;left:#{ i_end }px;width:15px;' class='task project-line ending'>&nbsp;</div>"
chris@22 340 end
chris@22 341
chris@22 342 # DIsplay the Project name and %
chris@22 343 if i_end <= options[:g_width]
chris@22 344 # Display the status even if it's floated off to the left
chris@22 345 status_px = i_end + 12 # 12px for the diamond
chris@22 346 status_px = 0 if status_px <= 0
chris@22 347
chris@22 348 output << "<div style='top:#{ options[:top] }px;left:#{ status_px }px;' class='task label project-name'>"
chris@22 349 output << "<strong>#{h project } #{h project.completed_percent(:include_subprojects => true).to_i.to_s}%</strong>"
chris@22 350 output << "</div>"
chris@22 351 end
chris@22 352
chris@22 353 output
chris@22 354 when :image
chris@22 355 options[:image].stroke('transparent')
chris@22 356 i_left = options[:subject_width] + ((project.due_date - self.date_from)*options[:zoom]).floor
chris@22 357
chris@22 358 # Make sure negative i_left doesn't overflow the subject
chris@22 359 if i_left > options[:subject_width]
chris@22 360 options[:image].fill('blue')
chris@22 361 options[:image].rectangle(i_left, options[:top], i_left + 6, options[:top] - 6)
chris@22 362 options[:image].fill('black')
chris@22 363 options[:image].text(i_left + 11, options[:top] + 1, project.name)
chris@22 364 end
chris@22 365 when :pdf
chris@22 366 options[:pdf].SetY(options[:top]+1.5)
chris@22 367 i_left = ((project.due_date - @date_from)*options[:zoom])
chris@22 368
chris@22 369 # Make sure negative i_left doesn't overflow the subject
chris@22 370 if i_left > 0
chris@22 371 options[:pdf].SetX(options[:subject_width] + i_left)
chris@22 372 options[:pdf].SetFillColor(50,50,200)
chris@22 373 options[:pdf].Cell(2, 2, "", 0, 0, "", 1)
chris@22 374
chris@22 375 options[:pdf].SetY(options[:top]+1.5)
chris@22 376 options[:pdf].SetX(options[:subject_width] + i_left + 3)
chris@22 377 options[:pdf].Cell(30, 2, "#{project.name}")
chris@22 378 end
chris@22 379 end
chris@22 380 else
chris@22 381 ActiveRecord::Base.logger.debug "Gantt#line_for_project was not given a project with a start_date"
chris@22 382 ''
chris@22 383 end
chris@22 384 end
chris@22 385
chris@22 386 def subject_for_version(version, options)
chris@22 387 case options[:format]
chris@22 388 when :html
chris@22 389 output = ''
chris@22 390 output << "<div class='version-name' style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:#{options[:indent]}px;overflow:hidden;'><small> "
chris@22 391 if version.is_a? Version
chris@22 392 output << "<span class='icon icon-package #{version.behind_schedule? ? 'version-behind-schedule' : ''} #{version.overdue? ? 'version-overdue' : ''}'>"
chris@22 393 output << view.link_to_version(version)
chris@22 394 output << '</span>'
chris@22 395 else
chris@22 396 ActiveRecord::Base.logger.debug "Gantt#subject_for_version was not given a version"
chris@22 397 ''
chris@22 398 end
chris@22 399 output << "</small></div>"
chris@22 400
chris@22 401 output
chris@22 402 when :image
chris@22 403 options[:image].fill('black')
chris@22 404 options[:image].stroke('transparent')
chris@22 405 options[:image].stroke_width(1)
chris@22 406 options[:image].text(options[:indent], options[:top] + 2, version.to_s_with_project)
chris@22 407 when :pdf
chris@22 408 options[:pdf].SetY(options[:top])
chris@22 409 options[:pdf].SetX(15)
chris@22 410
chris@22 411 char_limit = PDF::MaxCharactorsForSubject - options[:indent]
chris@22 412 options[:pdf].Cell(options[:subject_width]-15, 5, (" " * options[:indent]) +"#{version.to_s_with_project}".sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR")
chris@22 413
chris@22 414 options[:pdf].SetY(options[:top])
chris@22 415 options[:pdf].SetX(options[:subject_width])
chris@22 416 options[:pdf].Cell(options[:g_width], 5, "", "LR")
chris@22 417 end
chris@22 418 end
chris@22 419
chris@22 420 def line_for_version(version, options)
chris@22 421 # Skip versions that don't have a start_date
chris@37 422 if version.is_a?(Version) && version.start_date && version.due_date
chris@22 423 options[:zoom] ||= 1
chris@22 424 options[:g_width] ||= (self.date_to - self.date_from + 1) * options[:zoom]
chris@22 425
chris@22 426 case options[:format]
chris@22 427 when :html
chris@22 428 output = ''
chris@22 429 i_left = ((version.start_date - self.date_from)*options[:zoom]).floor
chris@22 430 # TODO: or version.fixed_issues.collect(&:start_date).min
chris@22 431 start_date = version.fixed_issues.minimum('start_date') if version.fixed_issues.present?
chris@22 432 start_date ||= self.date_from
chris@22 433 start_left = ((start_date - self.date_from)*options[:zoom]).floor
chris@22 434
chris@22 435 i_end_date = ((version.due_date <= self.date_to) ? version.due_date : self.date_to )
chris@22 436 i_done_date = start_date + ((version.due_date - start_date+1)* version.completed_pourcent/100).floor
chris@22 437 i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
chris@22 438 i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
chris@22 439
chris@22 440 i_late_date = [i_end_date, Date.today].min if start_date < Date.today
chris@22 441
chris@22 442 i_width = (i_left - start_left + 1).floor - 2 # total width of the issue (- 2 for left and right borders)
chris@22 443 d_width = ((i_done_date - start_date)*options[:zoom]).floor - 2 # done width
chris@22 444 l_width = i_late_date ? ((i_late_date - start_date+1)*options[:zoom]).floor - 2 : 0 # delay width
chris@22 445
chris@22 446 i_end = ((i_end_date - self.date_from) * options[:zoom]).floor # Ending pixel
chris@22 447
chris@22 448 # Bar graphic
chris@22 449
chris@22 450 # Make sure that negative i_left and i_width don't
chris@22 451 # overflow the subject
chris@22 452 if i_width > 0 && i_left <= options[:g_width]
chris@22 453 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ i_width }px;' class='task milestone_todo'>&nbsp;</div>"
chris@22 454 end
chris@22 455 if l_width > 0 && i_left <= options[:g_width]
chris@22 456 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ l_width }px;' class='task milestone_late'>&nbsp;</div>"
chris@22 457 end
chris@22 458 if d_width > 0 && i_left <= options[:g_width]
chris@22 459 output<< "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:#{ d_width }px;' class='task milestone_done'>&nbsp;</div>"
chris@22 460 end
chris@22 461
chris@22 462
chris@22 463 # Starting diamond
chris@22 464 if start_left <= options[:g_width] && start_left > 0
chris@22 465 output << "<div style='top:#{ options[:top] }px;left:#{ start_left }px;width:15px;' class='task milestone starting'>&nbsp;</div>"
chris@22 466 output << "<div style='top:#{ options[:top] }px;left:#{ start_left + 12 }px;background:#fff;' class='task'>"
chris@22 467 output << "</div>"
chris@22 468 end
chris@22 469
chris@22 470 # Ending diamond
chris@22 471 # Don't show items too far ahead
chris@22 472 if i_left <= options[:g_width] && i_end > 0
chris@22 473 output << "<div style='top:#{ options[:top] }px;left:#{ i_end }px;width:15px;' class='task milestone ending'>&nbsp;</div>"
chris@22 474 end
chris@22 475
chris@22 476 # Display the Version name and %
chris@22 477 if i_end <= options[:g_width]
chris@22 478 # Display the status even if it's floated off to the left
chris@22 479 status_px = i_end + 12 # 12px for the diamond
chris@22 480 status_px = 0 if status_px <= 0
chris@22 481
chris@22 482 output << "<div style='top:#{ options[:top] }px;left:#{ status_px }px;' class='task label version-name'>"
chris@22 483 output << h("#{version.project} -") unless @project && @project == version.project
chris@22 484 output << "<strong>#{h version } #{h version.completed_pourcent.to_i.to_s}%</strong>"
chris@22 485 output << "</div>"
chris@22 486 end
chris@22 487
chris@22 488 output
chris@22 489 when :image
chris@22 490 options[:image].stroke('transparent')
chris@22 491 i_left = options[:subject_width] + ((version.start_date - @date_from)*options[:zoom]).floor
chris@22 492
chris@22 493 # Make sure negative i_left doesn't overflow the subject
chris@22 494 if i_left > options[:subject_width]
chris@22 495 options[:image].fill('green')
chris@22 496 options[:image].rectangle(i_left, options[:top], i_left + 6, options[:top] - 6)
chris@22 497 options[:image].fill('black')
chris@22 498 options[:image].text(i_left + 11, options[:top] + 1, version.name)
chris@22 499 end
chris@22 500 when :pdf
chris@22 501 options[:pdf].SetY(options[:top]+1.5)
chris@22 502 i_left = ((version.start_date - @date_from)*options[:zoom])
chris@22 503
chris@22 504 # Make sure negative i_left doesn't overflow the subject
chris@22 505 if i_left > 0
chris@22 506 options[:pdf].SetX(options[:subject_width] + i_left)
chris@22 507 options[:pdf].SetFillColor(50,200,50)
chris@22 508 options[:pdf].Cell(2, 2, "", 0, 0, "", 1)
chris@22 509
chris@22 510 options[:pdf].SetY(options[:top]+1.5)
chris@22 511 options[:pdf].SetX(options[:subject_width] + i_left + 3)
chris@22 512 options[:pdf].Cell(30, 2, "#{version.name}")
chris@22 513 end
chris@22 514 end
chris@22 515 else
chris@22 516 ActiveRecord::Base.logger.debug "Gantt#line_for_version was not given a version with a start_date"
chris@22 517 ''
chris@22 518 end
chris@22 519 end
chris@22 520
chris@22 521 def subject_for_issue(issue, options)
chris@22 522 case options[:format]
chris@22 523 when :html
chris@22 524 output = ''
chris@22 525 output << "<div class='tooltip'>"
chris@22 526 output << "<div class='issue-subject' style='position: absolute;line-height:1.2em;height:16px;top:#{options[:top]}px;left:#{options[:indent]}px;overflow:hidden;'><small> "
chris@22 527 if issue.is_a? Issue
chris@22 528 css_classes = []
chris@22 529 css_classes << 'issue-overdue' if issue.overdue?
chris@22 530 css_classes << 'issue-behind-schedule' if issue.behind_schedule?
chris@22 531 css_classes << 'icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to
chris@22 532
chris@22 533 if issue.assigned_to.present?
chris@22 534 assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name
chris@22 535 output << view.avatar(issue.assigned_to, :class => 'gravatar icon-gravatar', :size => 10, :title => assigned_string)
chris@22 536 end
chris@22 537 output << "<span class='#{css_classes.join(' ')}'>"
chris@22 538 output << view.link_to_issue(issue)
chris@22 539 output << '</span>'
chris@22 540 else
chris@22 541 ActiveRecord::Base.logger.debug "Gantt#subject_for_issue was not given an issue"
chris@22 542 ''
chris@22 543 end
chris@22 544 output << "</small></div>"
chris@22 545
chris@22 546 # Tooltip
chris@22 547 if issue.is_a? Issue
chris@22 548 output << "<span class='tip' style='position: absolute;top:#{ options[:top].to_i + 16 }px;left:#{ options[:indent].to_i + 20 }px;'>"
chris@22 549 output << view.render_issue_tooltip(issue)
chris@22 550 output << "</span>"
chris@22 551 end
chris@22 552
chris@22 553 output << "</div>"
chris@22 554 output
chris@22 555 when :image
chris@22 556 options[:image].fill('black')
chris@22 557 options[:image].stroke('transparent')
chris@22 558 options[:image].stroke_width(1)
chris@22 559 options[:image].text(options[:indent], options[:top] + 2, issue.subject)
chris@22 560 when :pdf
chris@22 561 options[:pdf].SetY(options[:top])
chris@22 562 options[:pdf].SetX(15)
chris@22 563
chris@22 564 char_limit = PDF::MaxCharactorsForSubject - options[:indent]
chris@22 565 options[:pdf].Cell(options[:subject_width]-15, 5, (" " * options[:indent]) +"#{issue.tracker} #{issue.id}: #{issue.subject}".sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR")
chris@22 566
chris@22 567 options[:pdf].SetY(options[:top])
chris@22 568 options[:pdf].SetX(options[:subject_width])
chris@22 569 options[:pdf].Cell(options[:g_width], 5, "", "LR")
chris@22 570 end
chris@22 571 end
chris@22 572
chris@22 573 def line_for_issue(issue, options)
chris@22 574 # Skip issues that don't have a due_before (due_date or version's due_date)
chris@22 575 if issue.is_a?(Issue) && issue.due_before
chris@22 576 case options[:format]
chris@22 577 when :html
chris@22 578 output = ''
chris@22 579 # Handle nil start_dates, rare but can happen.
chris@22 580 i_start_date = if issue.start_date && issue.start_date >= self.date_from
chris@22 581 issue.start_date
chris@22 582 else
chris@22 583 self.date_from
chris@22 584 end
chris@22 585
chris@22 586 i_end_date = ((issue.due_before && issue.due_before <= self.date_to) ? issue.due_before : self.date_to )
chris@22 587 i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
chris@22 588 i_done_date = (i_done_date <= self.date_from ? self.date_from : i_done_date )
chris@22 589 i_done_date = (i_done_date >= self.date_to ? self.date_to : i_done_date )
chris@22 590
chris@22 591 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
chris@22 592
chris@22 593 i_left = ((i_start_date - self.date_from)*options[:zoom]).floor
chris@22 594 i_width = ((i_end_date - i_start_date + 1)*options[:zoom]).floor - 2 # total width of the issue (- 2 for left and right borders)
chris@22 595 d_width = ((i_done_date - i_start_date)*options[:zoom]).floor - 2 # done width
chris@22 596 l_width = i_late_date ? ((i_late_date - i_start_date+1)*options[:zoom]).floor - 2 : 0 # delay width
chris@22 597 css = "task " + (issue.leaf? ? 'leaf' : 'parent')
chris@22 598
chris@22 599 # Make sure that negative i_left and i_width don't
chris@22 600 # overflow the subject
chris@22 601 if i_width > 0
chris@22 602 output << "<div style='top:#{ options[:top] }px;left:#{ i_left }px;width:#{ i_width }px;' class='#{css} task_todo'>&nbsp;</div>"
chris@22 603 end
chris@22 604 if l_width > 0
chris@22 605 output << "<div style='top:#{ options[:top] }px;left:#{ i_left }px;width:#{ l_width }px;' class='#{css} task_late'>&nbsp;</div>"
chris@22 606 end
chris@22 607 if d_width > 0
chris@22 608 output<< "<div style='top:#{ options[:top] }px;left:#{ i_left }px;width:#{ d_width }px;' class='#{css} task_done'>&nbsp;</div>"
chris@22 609 end
chris@22 610
chris@22 611 # Display the status even if it's floated off to the left
chris@22 612 status_px = i_left + i_width + 5
chris@22 613 status_px = 5 if status_px <= 0
chris@22 614
chris@22 615 output << "<div style='top:#{ options[:top] }px;left:#{ status_px }px;' class='#{css} label issue-name'>"
chris@22 616 output << issue.status.name
chris@22 617 output << ' '
chris@22 618 output << (issue.done_ratio).to_i.to_s
chris@22 619 output << "%"
chris@22 620 output << "</div>"
chris@22 621
chris@22 622 output << "<div class='tooltip' style='position: absolute;top:#{ options[:top] }px;left:#{ i_left }px;width:#{ i_width }px;height:12px;'>"
chris@22 623 output << '<span class="tip">'
chris@22 624 output << view.render_issue_tooltip(issue)
chris@22 625 output << "</span></div>"
chris@22 626 output
chris@22 627
chris@22 628 when :image
chris@22 629 # Handle nil start_dates, rare but can happen.
chris@22 630 i_start_date = if issue.start_date && issue.start_date >= @date_from
chris@22 631 issue.start_date
chris@22 632 else
chris@22 633 @date_from
chris@22 634 end
chris@22 635
chris@22 636 i_end_date = (issue.due_before <= date_to ? issue.due_before : date_to )
chris@22 637 i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
chris@22 638 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
chris@22 639 i_done_date = (i_done_date >= date_to ? date_to : i_done_date )
chris@22 640 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
chris@22 641
chris@22 642 i_left = options[:subject_width] + ((i_start_date - @date_from)*options[:zoom]).floor
chris@22 643 i_width = ((i_end_date - i_start_date + 1)*options[:zoom]).floor # total width of the issue
chris@22 644 d_width = ((i_done_date - i_start_date)*options[:zoom]).floor # done width
chris@22 645 l_width = i_late_date ? ((i_late_date - i_start_date+1)*options[:zoom]).floor : 0 # delay width
chris@22 646
chris@22 647
chris@22 648 # Make sure that negative i_left and i_width don't
chris@22 649 # overflow the subject
chris@22 650 if i_width > 0
chris@22 651 options[:image].fill('grey')
chris@22 652 options[:image].rectangle(i_left, options[:top], i_left + i_width, options[:top] - 6)
chris@22 653 options[:image].fill('red')
chris@22 654 options[:image].rectangle(i_left, options[:top], i_left + l_width, options[:top] - 6) if l_width > 0
chris@22 655 options[:image].fill('blue')
chris@22 656 options[:image].rectangle(i_left, options[:top], i_left + d_width, options[:top] - 6) if d_width > 0
chris@22 657 end
chris@22 658
chris@22 659 # Show the status and % done next to the subject if it overflows
chris@22 660 options[:image].fill('black')
chris@22 661 if i_width > 0
chris@22 662 options[:image].text(i_left + i_width + 5,options[:top] + 1, "#{issue.status.name} #{issue.done_ratio}%")
chris@22 663 else
chris@22 664 options[:image].text(options[:subject_width] + 5,options[:top] + 1, "#{issue.status.name} #{issue.done_ratio}%")
chris@22 665 end
chris@22 666
chris@22 667 when :pdf
chris@22 668 options[:pdf].SetY(options[:top]+1.5)
chris@22 669 # Handle nil start_dates, rare but can happen.
chris@22 670 i_start_date = if issue.start_date && issue.start_date >= @date_from
chris@22 671 issue.start_date
chris@22 672 else
chris@22 673 @date_from
chris@22 674 end
chris@22 675
chris@22 676 i_end_date = (issue.due_before <= @date_to ? issue.due_before : @date_to )
chris@22 677
chris@22 678 i_done_date = i_start_date + ((issue.due_before - i_start_date+1)*issue.done_ratio/100).floor
chris@22 679 i_done_date = (i_done_date <= @date_from ? @date_from : i_done_date )
chris@22 680 i_done_date = (i_done_date >= @date_to ? @date_to : i_done_date )
chris@22 681
chris@22 682 i_late_date = [i_end_date, Date.today].min if i_start_date < Date.today
chris@22 683
chris@22 684 i_left = ((i_start_date - @date_from)*options[:zoom])
chris@22 685 i_width = ((i_end_date - i_start_date + 1)*options[:zoom])
chris@22 686 d_width = ((i_done_date - i_start_date)*options[:zoom])
chris@22 687 l_width = ((i_late_date - i_start_date+1)*options[:zoom]) if i_late_date
chris@22 688 l_width ||= 0
chris@22 689
chris@22 690 # Make sure that negative i_left and i_width don't
chris@22 691 # overflow the subject
chris@22 692 if i_width > 0
chris@22 693 options[:pdf].SetX(options[:subject_width] + i_left)
chris@22 694 options[:pdf].SetFillColor(200,200,200)
chris@22 695 options[:pdf].Cell(i_width, 2, "", 0, 0, "", 1)
chris@22 696 end
chris@22 697
chris@22 698 if l_width > 0
chris@22 699 options[:pdf].SetY(options[:top]+1.5)
chris@22 700 options[:pdf].SetX(options[:subject_width] + i_left)
chris@22 701 options[:pdf].SetFillColor(255,100,100)
chris@22 702 options[:pdf].Cell(l_width, 2, "", 0, 0, "", 1)
chris@22 703 end
chris@22 704 if d_width > 0
chris@22 705 options[:pdf].SetY(options[:top]+1.5)
chris@22 706 options[:pdf].SetX(options[:subject_width] + i_left)
chris@22 707 options[:pdf].SetFillColor(100,100,255)
chris@22 708 options[:pdf].Cell(d_width, 2, "", 0, 0, "", 1)
chris@22 709 end
chris@22 710
chris@22 711 options[:pdf].SetY(options[:top]+1.5)
chris@22 712
chris@22 713 # Make sure that negative i_left and i_width don't
chris@22 714 # overflow the subject
chris@22 715 if (i_left + i_width) >= 0
chris@22 716 options[:pdf].SetX(options[:subject_width] + i_left + i_width)
chris@22 717 else
chris@22 718 options[:pdf].SetX(options[:subject_width])
chris@22 719 end
chris@22 720 options[:pdf].Cell(30, 2, "#{issue.status} #{issue.done_ratio}%")
chris@22 721 end
chris@22 722 else
chris@22 723 ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before"
chris@22 724 ''
chris@22 725 end
chris@22 726 end
chris@22 727
Chris@0 728 # Generates a gantt image
Chris@0 729 # Only defined if RMagick is avalaible
chris@22 730 def to_image(format='PNG')
Chris@0 731 date_to = (@date_from >> @months)-1
Chris@0 732 show_weeks = @zoom > 1
Chris@0 733 show_days = @zoom > 2
Chris@0 734
Chris@1 735 subject_width = 400
Chris@0 736 header_heigth = 18
Chris@0 737 # width of one day in pixels
Chris@0 738 zoom = @zoom*2
Chris@0 739 g_width = (@date_to - @date_from + 1)*zoom
chris@22 740 g_height = 20 * number_of_rows + 30
Chris@0 741 headers_heigth = (show_weeks ? 2*header_heigth : header_heigth)
Chris@0 742 height = g_height + headers_heigth
Chris@0 743
Chris@0 744 imgl = Magick::ImageList.new
Chris@0 745 imgl.new_image(subject_width+g_width+1, height)
Chris@0 746 gc = Magick::Draw.new
Chris@0 747
Chris@0 748 # Subjects
chris@22 749 subjects(:image => gc, :top => (headers_heigth + 20), :indent => 4, :format => :image)
Chris@0 750
Chris@0 751 # Months headers
Chris@0 752 month_f = @date_from
Chris@0 753 left = subject_width
Chris@0 754 @months.times do
Chris@0 755 width = ((month_f >> 1) - month_f) * zoom
Chris@0 756 gc.fill('white')
Chris@0 757 gc.stroke('grey')
Chris@0 758 gc.stroke_width(1)
Chris@0 759 gc.rectangle(left, 0, left + width, height)
Chris@0 760 gc.fill('black')
Chris@0 761 gc.stroke('transparent')
Chris@0 762 gc.stroke_width(1)
Chris@0 763 gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}")
Chris@0 764 left = left + width
Chris@0 765 month_f = month_f >> 1
Chris@0 766 end
Chris@0 767
Chris@0 768 # Weeks headers
Chris@0 769 if show_weeks
Chris@0 770 left = subject_width
Chris@0 771 height = header_heigth
Chris@0 772 if @date_from.cwday == 1
Chris@0 773 # date_from is monday
Chris@0 774 week_f = date_from
Chris@0 775 else
Chris@0 776 # find next monday after date_from
Chris@0 777 week_f = @date_from + (7 - @date_from.cwday + 1)
Chris@0 778 width = (7 - @date_from.cwday + 1) * zoom
Chris@0 779 gc.fill('white')
Chris@0 780 gc.stroke('grey')
Chris@0 781 gc.stroke_width(1)
Chris@0 782 gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1)
Chris@0 783 left = left + width
Chris@0 784 end
Chris@0 785 while week_f <= date_to
Chris@0 786 width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom
Chris@0 787 gc.fill('white')
Chris@0 788 gc.stroke('grey')
Chris@0 789 gc.stroke_width(1)
Chris@0 790 gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1)
Chris@0 791 gc.fill('black')
Chris@0 792 gc.stroke('transparent')
Chris@0 793 gc.stroke_width(1)
Chris@0 794 gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s)
Chris@0 795 left = left + width
Chris@0 796 week_f = week_f+7
Chris@0 797 end
Chris@0 798 end
Chris@0 799
Chris@0 800 # Days details (week-end in grey)
Chris@0 801 if show_days
Chris@0 802 left = subject_width
Chris@0 803 height = g_height + header_heigth - 1
Chris@0 804 wday = @date_from.cwday
Chris@0 805 (date_to - @date_from + 1).to_i.times do
Chris@0 806 width = zoom
Chris@0 807 gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white')
Chris@0 808 gc.stroke('grey')
Chris@0 809 gc.stroke_width(1)
Chris@0 810 gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1)
Chris@0 811 left = left + width
Chris@0 812 wday = wday + 1
Chris@0 813 wday = 1 if wday > 7
Chris@0 814 end
Chris@0 815 end
Chris@0 816
Chris@0 817 # border
Chris@0 818 gc.fill('transparent')
Chris@0 819 gc.stroke('grey')
Chris@0 820 gc.stroke_width(1)
Chris@0 821 gc.rectangle(0, 0, subject_width+g_width, headers_heigth)
Chris@0 822 gc.stroke('black')
Chris@0 823 gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1)
Chris@0 824
Chris@0 825 # content
Chris@0 826 top = headers_heigth + 20
chris@22 827
chris@22 828 lines(:image => gc, :top => top, :zoom => zoom, :subject_width => subject_width, :format => :image)
Chris@0 829
Chris@0 830 # today red line
Chris@0 831 if Date.today >= @date_from and Date.today <= date_to
Chris@0 832 gc.stroke('red')
Chris@0 833 x = (Date.today-@date_from+1)*zoom + subject_width
Chris@0 834 gc.line(x, headers_heigth, x, headers_heigth + g_height-1)
Chris@0 835 end
Chris@0 836
Chris@0 837 gc.draw(imgl)
Chris@0 838 imgl.format = format
Chris@0 839 imgl.to_blob
Chris@0 840 end if Object.const_defined?(:Magick)
chris@22 841
chris@22 842 def to_pdf
chris@22 843 pdf = ::Redmine::Export::PDF::IFPDF.new(current_language)
chris@22 844 pdf.SetTitle("#{l(:label_gantt)} #{project}")
chris@22 845 pdf.AliasNbPages
chris@22 846 pdf.footer_date = format_date(Date.today)
chris@22 847 pdf.AddPage("L")
chris@22 848 pdf.SetFontStyle('B',12)
chris@22 849 pdf.SetX(15)
chris@22 850 pdf.Cell(PDF::LeftPaneWidth, 20, project.to_s)
chris@22 851 pdf.Ln
chris@22 852 pdf.SetFontStyle('B',9)
chris@22 853
chris@22 854 subject_width = PDF::LeftPaneWidth
chris@22 855 header_heigth = 5
chris@22 856
chris@22 857 headers_heigth = header_heigth
chris@22 858 show_weeks = false
chris@22 859 show_days = false
chris@22 860
chris@22 861 if self.months < 7
chris@22 862 show_weeks = true
chris@22 863 headers_heigth = 2*header_heigth
chris@22 864 if self.months < 3
chris@22 865 show_days = true
chris@22 866 headers_heigth = 3*header_heigth
chris@22 867 end
chris@22 868 end
chris@22 869
chris@22 870 g_width = PDF.right_pane_width
chris@22 871 zoom = (g_width) / (self.date_to - self.date_from + 1)
chris@22 872 g_height = 120
chris@22 873 t_height = g_height + headers_heigth
chris@22 874
chris@22 875 y_start = pdf.GetY
chris@22 876
chris@22 877 # Months headers
chris@22 878 month_f = self.date_from
chris@22 879 left = subject_width
chris@22 880 height = header_heigth
chris@22 881 self.months.times do
chris@22 882 width = ((month_f >> 1) - month_f) * zoom
chris@22 883 pdf.SetY(y_start)
chris@22 884 pdf.SetX(left)
chris@22 885 pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
chris@22 886 left = left + width
chris@22 887 month_f = month_f >> 1
chris@22 888 end
chris@22 889
chris@22 890 # Weeks headers
chris@22 891 if show_weeks
chris@22 892 left = subject_width
chris@22 893 height = header_heigth
chris@22 894 if self.date_from.cwday == 1
chris@22 895 # self.date_from is monday
chris@22 896 week_f = self.date_from
chris@22 897 else
chris@22 898 # find next monday after self.date_from
chris@22 899 week_f = self.date_from + (7 - self.date_from.cwday + 1)
chris@22 900 width = (7 - self.date_from.cwday + 1) * zoom-1
chris@22 901 pdf.SetY(y_start + header_heigth)
chris@22 902 pdf.SetX(left)
chris@22 903 pdf.Cell(width + 1, height, "", "LTR")
chris@22 904 left = left + width+1
chris@22 905 end
chris@22 906 while week_f <= self.date_to
chris@22 907 width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom
chris@22 908 pdf.SetY(y_start + header_heigth)
chris@22 909 pdf.SetX(left)
chris@22 910 pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
chris@22 911 left = left + width
chris@22 912 week_f = week_f+7
chris@22 913 end
chris@22 914 end
chris@22 915
chris@22 916 # Days headers
chris@22 917 if show_days
chris@22 918 left = subject_width
chris@22 919 height = header_heigth
chris@22 920 wday = self.date_from.cwday
chris@22 921 pdf.SetFontStyle('B',7)
chris@22 922 (self.date_to - self.date_from + 1).to_i.times do
chris@22 923 width = zoom
chris@22 924 pdf.SetY(y_start + 2 * header_heigth)
chris@22 925 pdf.SetX(left)
chris@22 926 pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
chris@22 927 left = left + width
chris@22 928 wday = wday + 1
chris@22 929 wday = 1 if wday > 7
chris@22 930 end
chris@22 931 end
chris@22 932
chris@22 933 pdf.SetY(y_start)
chris@22 934 pdf.SetX(15)
chris@22 935 pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
chris@22 936
chris@22 937 # Tasks
chris@22 938 top = headers_heigth + y_start
chris@22 939 pdf_subjects_and_lines(pdf, {
chris@22 940 :top => top,
chris@22 941 :zoom => zoom,
chris@22 942 :subject_width => subject_width,
chris@22 943 :g_width => g_width
chris@22 944 })
chris@22 945
chris@22 946
chris@22 947 pdf.Line(15, top, subject_width+g_width, top)
chris@22 948 pdf.Output
chris@22 949
chris@22 950
chris@22 951 end
Chris@0 952
Chris@0 953 private
chris@22 954
chris@22 955 # Renders both the subjects and lines of the Gantt chart for the
chris@22 956 # PDF format
chris@22 957 def pdf_subjects_and_lines(pdf, options = {})
chris@22 958 subject_options = {:indent => 0, :indent_increment => 5, :top_increment => 3, :render => :subject, :format => :pdf, :pdf => pdf}.merge(options)
chris@22 959 line_options = {:indent => 0, :indent_increment => 5, :top_increment => 3, :render => :line, :format => :pdf, :pdf => pdf}.merge(options)
chris@22 960
chris@22 961 if @project
chris@22 962 render_project(@project, subject_options)
chris@22 963 render_project(@project, line_options)
Chris@0 964 else
chris@22 965 Project.roots.each do |project|
chris@22 966 render_project(project, subject_options)
chris@22 967 render_project(project, line_options)
Chris@0 968 end
Chris@0 969 end
Chris@0 970 end
chris@22 971
Chris@0 972 end
Chris@0 973 end
Chris@0 974 end