Class: Redmine::Helpers::Gantt
- Inherits:
-
Object
- Object
- Redmine::Helpers::Gantt
- Includes:
- ERB::Util, I18n
- Defined in:
- lib/redmine/helpers/gantt.rb
Overview
Simple class to handle gantt chart data
Defined Under Namespace
Classes: PDF
Instance Attribute Summary collapse
-
#date_from ⇒ Object
readonly
Returns the value of attribute date_from.
-
#date_to ⇒ Object
readonly
Returns the value of attribute date_to.
-
#max_rows ⇒ Object
readonly
Returns the value of attribute max_rows.
-
#month_from ⇒ Object
readonly
Returns the value of attribute month_from.
-
#months ⇒ Object
readonly
Returns the value of attribute months.
-
#project ⇒ Object
Returns the value of attribute project.
-
#query ⇒ Object
Returns the value of attribute query.
-
#truncated ⇒ Object
readonly
Returns the value of attribute truncated.
-
#view ⇒ Object
Returns the value of attribute view.
-
#year_from ⇒ Object
readonly
Returns the value of attribute year_from.
-
#zoom ⇒ Object
readonly
Returns the value of attribute zoom.
Instance Method Summary collapse
- #common_params ⇒ Object
-
#initialize(options = {}) ⇒ Gantt
constructor
A new instance of Gantt.
-
#issues ⇒ Object
Returns issues that will be rendered.
- #line_for_issue(issue, options) ⇒ Object
- #line_for_project(project, options) ⇒ Object
- #line_for_version(version, options) ⇒ Object
-
#lines(options = {}) ⇒ Object
Renders the lines of the Gantt chart, the right side.
-
#number_of_rows ⇒ Object
Returns the number of rows that will be rendered on the Gantt chart.
-
#number_of_rows_on_project(project) ⇒ Object
Returns the number of rows that will be used to list a project on the Gantt chart.
- #params ⇒ Object
- #params_next ⇒ Object
- #params_previous ⇒ Object
-
#project_issues(project) ⇒ Object
Returns the issues that belong to
project
. -
#project_versions(project) ⇒ Object
Returns the distinct versions of the issues that belong to
project
. -
#projects ⇒ Object
Return all the project nodes that will be displayed.
- #render(options = {}) ⇒ Object
- #render_end(options = {}) ⇒ Object
- #render_issues(issues, options = {}) ⇒ Object
- #render_project(project, options = {}) ⇒ Object
- #render_version(project, version, options = {}) ⇒ Object
- #subject_for_issue(issue, options) ⇒ Object
- #subject_for_project(project, options) ⇒ Object
- #subject_for_version(version, options) ⇒ Object
-
#subjects(options = {}) ⇒ Object
Renders the subjects of the Gantt chart, the left side.
-
#to_image(format = 'PNG') ⇒ Object
Generates a gantt image Only defined if RMagick is avalaible.
- #to_pdf ⇒ Object
-
#version_issues(project, version) ⇒ Object
Returns the issues that belong to
project
and are assigned toversion
.
Methods included from I18n
#current_language, #day_name, #find_language, #format_date, #format_time, included, #l, #l_hours, #l_or_humanize, #ll, #month_name, #set_language_if_valid, #valid_languages
Constructor Details
#initialize(options = {}) ⇒ Gantt
Returns a new instance of Gantt.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/redmine/helpers/gantt.rb', line 42 def initialize(={}) = .dup if [:year] && [:year].to_i >0 @year_from = [:year].to_i if [:month] && [:month].to_i >=1 && [:month].to_i <= 12 @month_from = [:month].to_i else @month_from = 1 end else @month_from ||= Date.today.month @year_from ||= Date.today.year end zoom = ([:zoom] || User.current.pref[:gantt_zoom]).to_i @zoom = (zoom > 0 && zoom < 5) ? zoom : 2 months = ([:months] || User.current.pref[:gantt_months]).to_i @months = (months > 0 && months < 25) ? months : 6 # Save gantt parameters as user preference (zoom and months count) if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] || @months != User.current.pref[:gantt_months])) User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months User.current.preference.save end @date_from = Date.civil(@year_from, @month_from, 1) @date_to = (@date_from >> @months) - 1 @subjects = '' @lines = '' @number_of_rows = nil @issue_ancestors = [] @truncated = false if .has_key?(:max_rows) @max_rows = [:max_rows] else @max_rows = Setting.gantt_items_limit.blank? ? nil : Setting.gantt_items_limit.to_i end end |
Instance Attribute Details
#date_from ⇒ Object (readonly)
Returns the value of attribute date_from.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def date_from @date_from end |
#date_to ⇒ Object (readonly)
Returns the value of attribute date_to.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def date_to @date_to end |
#max_rows ⇒ Object (readonly)
Returns the value of attribute max_rows.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def max_rows @max_rows end |
#month_from ⇒ Object (readonly)
Returns the value of attribute month_from.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def month_from @month_from end |
#months ⇒ Object (readonly)
Returns the value of attribute months.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def months @months end |
#project ⇒ Object
Returns the value of attribute project.
39 40 41 |
# File 'lib/redmine/helpers/gantt.rb', line 39 def project @project end |
#query ⇒ Object
Returns the value of attribute query.
38 39 40 |
# File 'lib/redmine/helpers/gantt.rb', line 38 def query @query end |
#truncated ⇒ Object (readonly)
Returns the value of attribute truncated.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def truncated @truncated end |
#view ⇒ Object
Returns the value of attribute view.
40 41 42 |
# File 'lib/redmine/helpers/gantt.rb', line 40 def view @view end |
#year_from ⇒ Object (readonly)
Returns the value of attribute year_from.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def year_from @year_from end |
#zoom ⇒ Object (readonly)
Returns the value of attribute zoom.
37 38 39 |
# File 'lib/redmine/helpers/gantt.rb', line 37 def zoom @zoom end |
Instance Method Details
#common_params ⇒ Object
85 86 87 |
# File 'lib/redmine/helpers/gantt.rb', line 85 def common_params { :controller => 'gantts', :action => 'show', :project_id => @project } end |
#issues ⇒ Object
Returns issues that will be rendered
133 134 135 136 137 138 139 |
# File 'lib/redmine/helpers/gantt.rb', line 133 def issues @issues ||= @query.issues( :include => [:assigned_to, :tracker, :priority, :category, :fixed_version], :order => "#{Project.table_name}.lft ASC, #{Issue.table_name}.id ASC", :limit => @max_rows ) end |
#line_for_issue(issue, options) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/redmine/helpers/gantt.rb', line 373 def line_for_issue(issue, ) # Skip issues that don't have a due_before (due_date or version's due_date) if issue.is_a?(Issue) && issue.due_before coords = coordinates(issue.start_date, issue.due_before, issue.done_ratio, [:zoom]) label = "#{ issue.status.name } #{ issue.done_ratio }%" case [:format] when :html html_task(, coords, :css => "task " + (issue.leaf? ? 'leaf' : 'parent'), :label => label, :issue => issue, :markers => !issue.leaf?) when :image image_task(, coords, :label => label) when :pdf pdf_task(, coords, :label => label) end else ActiveRecord::Base.logger.debug "GanttHelper#line_for_issue was not given an issue with a due_before" '' end end |
#line_for_project(project, options) ⇒ Object
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File 'lib/redmine/helpers/gantt.rb', line 275 def line_for_project(project, ) # Skip versions that don't have a start_date or due date if project.is_a?(Project) && project.start_date && project.due_date [:zoom] ||= 1 [:g_width] ||= (self.date_to - self.date_from + 1) * [:zoom] coords = coordinates(project.start_date, project.due_date, nil, [:zoom]) label = h(project) case [:format] when :html html_task(, coords, :css => "project task", :label => label, :markers => true) when :image image_task(, coords, :label => label, :markers => true, :height => 3) when :pdf pdf_task(, coords, :label => label, :markers => true, :height => 0.8) end else ActiveRecord::Base.logger.debug "Gantt#line_for_project was not given a project with a start_date" '' end end |
#line_for_version(version, options) ⇒ Object
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 |
# File 'lib/redmine/helpers/gantt.rb', line 313 def line_for_version(version, ) # Skip versions that don't have a start_date if version.is_a?(Version) && version.start_date && version.due_date [:zoom] ||= 1 [:g_width] ||= (self.date_to - self.date_from + 1) * [:zoom] coords = coordinates(version.start_date, version.due_date, version.completed_pourcent, [:zoom]) label = "#{h version } #{h version.completed_pourcent.to_i.to_s}%" label = h("#{version.project} -") + label unless @project && @project == version.project case [:format] when :html html_task(, coords, :css => "version task", :label => label, :markers => true) when :image image_task(, coords, :label => label, :markers => true, :height => 3) when :pdf pdf_task(, coords, :label => label, :markers => true, :height => 0.8) end else ActiveRecord::Base.logger.debug "Gantt#line_for_version was not given a version with a start_date" '' end end |
#lines(options = {}) ⇒ Object
Renders the lines of the Gantt chart, the right side
127 128 129 130 |
# File 'lib/redmine/helpers/gantt.rb', line 127 def lines(={}) render(.merge(:only => :lines)) unless @lines_rendered @lines end |
#number_of_rows ⇒ Object
Returns the number of rows that will be rendered on the Gantt chart
102 103 104 105 106 107 |
# File 'lib/redmine/helpers/gantt.rb', line 102 def number_of_rows return @number_of_rows if @number_of_rows rows = projects.inject(0) {|total, p| total += number_of_rows_on_project(p)} rows > @max_rows ? @max_rows : rows end |
#number_of_rows_on_project(project) ⇒ Object
Returns the number of rows that will be used to list a project on the Gantt chart. This will recurse for each subproject.
111 112 113 114 115 116 117 118 |
# File 'lib/redmine/helpers/gantt.rb', line 111 def number_of_rows_on_project(project) return 0 unless projects.include?(project) count = 1 count += project_issues(project).size count += project_versions(project).size count end |
#params ⇒ Object
89 90 91 |
# File 'lib/redmine/helpers/gantt.rb', line 89 def params common_params.merge({ :zoom => zoom, :year => year_from, :month => month_from, :months => months }) end |
#params_next ⇒ Object
97 98 99 |
# File 'lib/redmine/helpers/gantt.rb', line 97 def params_next common_params.merge({:year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months }) end |
#params_previous ⇒ Object
93 94 95 |
# File 'lib/redmine/helpers/gantt.rb', line 93 def params_previous common_params.merge({:year => (date_from << months).year, :month => (date_from << months).month, :zoom => zoom, :months => months }) end |
#project_issues(project) ⇒ Object
Returns the issues that belong to project
159 160 161 162 |
# File 'lib/redmine/helpers/gantt.rb', line 159 def project_issues(project) @issues_by_project ||= issues.group_by(&:project) @issues_by_project[project] || [] end |
#project_versions(project) ⇒ Object
Returns the distinct versions of the issues that belong to project
165 166 167 |
# File 'lib/redmine/helpers/gantt.rb', line 165 def project_versions(project) project_issues(project).collect(&:fixed_version).compact.uniq end |
#projects ⇒ Object
Return all the project nodes that will be displayed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/redmine/helpers/gantt.rb', line 142 def projects return @projects if @projects ids = issues.collect(&:project).uniq.collect(&:id) if ids.any? # All issues projects and their visible ancestors @projects = Project.visible.all( :joins => "LEFT JOIN #{Project.table_name} child ON #{Project.table_name}.lft <= child.lft AND #{Project.table_name}.rgt >= child.rgt", :conditions => ["child.id IN (?)", ids], :order => "#{Project.table_name}.lft ASC" ).uniq else @projects = [] end end |
#render(options = {}) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/redmine/helpers/gantt.rb', line 174 def render(={}) = {:top => 0, :top_increment => 20, :indent_increment => 20, :render => :subject, :format => :html}.merge() indent = [:indent] || 4 @subjects = '' unless [:only] == :lines @lines = '' unless [:only] == :subjects @number_of_rows = 0 Project.project_tree(projects) do |project, level| [:indent] = indent + level * [:indent_increment] render_project(project, ) break if abort? end @subjects_rendered = true unless [:only] == :lines @lines_rendered = true unless [:only] == :subjects render_end() end |
#render_end(options = {}) ⇒ Object
253 254 255 256 257 258 |
# File 'lib/redmine/helpers/gantt.rb', line 253 def render_end(={}) case [:format] when :pdf [:pdf].Line(15, [:top], PDF::TotalWidth, [:top]) end end |
#render_issues(issues, options = {}) ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/redmine/helpers/gantt.rb', line 219 def render_issues(issues, ={}) @issue_ancestors = [] issues.each do |i| subject_for_issue(i, ) unless [:only] == :lines line_for_issue(i, ) unless [:only] == :subjects [:top] += [:top_increment] @number_of_rows += 1 break if abort? end [:indent] -= ([:indent_increment] * @issue_ancestors.size) end |
#render_project(project, options = {}) ⇒ Object
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/redmine/helpers/gantt.rb', line 194 def render_project(project, ={}) subject_for_project(project, ) unless [:only] == :lines line_for_project(project, ) unless [:only] == :subjects [:top] += [:top_increment] [:indent] += [:indent_increment] @number_of_rows += 1 return if abort? issues = project_issues(project).select {|i| i.fixed_version.nil?} sort_issues!(issues) if issues render_issues(issues, ) return if abort? end versions = project_versions(project) versions.each do |version| render_version(project, version, ) end # Remove indent to hit the next sibling [:indent] -= [:indent_increment] end |
#render_version(project, version, options = {}) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/redmine/helpers/gantt.rb', line 234 def render_version(project, version, ={}) # Version header subject_for_version(version, ) unless [:only] == :lines line_for_version(version, ) unless [:only] == :subjects [:top] += [:top_increment] @number_of_rows += 1 return if abort? issues = version_issues(project, version) if issues sort_issues!(issues) # Indent issues [:indent] += [:indent_increment] render_issues(issues, ) [:indent] -= [:indent_increment] end end |
#subject_for_issue(issue, options) ⇒ Object
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/redmine/helpers/gantt.rb', line 337 def subject_for_issue(issue, ) while @issue_ancestors.any? && !issue.is_descendant_of?(@issue_ancestors.last) @issue_ancestors.pop [:indent] -= [:indent_increment] end output = case [:format] when :html css_classes = '' css_classes << ' issue-overdue' if issue.overdue? css_classes << ' issue-behind-schedule' if issue.behind_schedule? css_classes << ' icon icon-issue' unless Setting.gravatar_enabled? && issue.assigned_to subject = "<span class='#{css_classes}'>" if issue.assigned_to.present? assigned_string = l(:field_assigned_to) + ": " + issue.assigned_to.name subject << view.avatar(issue.assigned_to, :class => 'gravatar icon-gravatar', :size => 10, :title => assigned_string).to_s end subject << view.link_to_issue(issue) subject << '</span>' html_subject(, subject, :css => "issue-subject", :title => issue.subject) + "\n" when :image image_subject(, issue.subject) when :pdf pdf_new_page?() pdf_subject(, issue.subject) end unless issue.leaf? @issue_ancestors << issue [:indent] += [:indent_increment] end output end |
#subject_for_project(project, options) ⇒ Object
260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/redmine/helpers/gantt.rb', line 260 def subject_for_project(project, ) case [:format] when :html subject = "<span class='icon icon-projects #{project.overdue? ? 'project-overdue' : ''}'>" subject << view.link_to_project(project) subject << '</span>' html_subject(, subject, :css => "project-name") when :image image_subject(, project.name) when :pdf pdf_new_page?() pdf_subject(, project.name) end end |
#subject_for_version(version, options) ⇒ Object
298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/redmine/helpers/gantt.rb', line 298 def subject_for_version(version, ) case [:format] when :html subject = "<span class='icon icon-package #{version.behind_schedule? ? 'version-behind-schedule' : ''} #{version.overdue? ? 'version-overdue' : ''}'>" subject << view.link_to_version(version) subject << '</span>' html_subject(, subject, :css => "version-name") when :image image_subject(, version.to_s_with_project) when :pdf pdf_new_page?() pdf_subject(, version.to_s_with_project) end end |
#subjects(options = {}) ⇒ Object
Renders the subjects of the Gantt chart, the left side.
121 122 123 124 |
# File 'lib/redmine/helpers/gantt.rb', line 121 def subjects(={}) render(.merge(:only => :subjects)) unless @subjects_rendered @subjects end |
#to_image(format = 'PNG') ⇒ Object
Generates a gantt image Only defined if RMagick is avalaible
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
# File 'lib/redmine/helpers/gantt.rb', line 395 def to_image(format='PNG') date_to = (@date_from >> @months)-1 show_weeks = @zoom > 1 show_days = @zoom > 2 subject_width = 400 header_heigth = 18 # width of one day in pixels zoom = @zoom*2 g_width = (@date_to - @date_from + 1)*zoom g_height = 20 * number_of_rows + 30 headers_heigth = (show_weeks ? 2*header_heigth : header_heigth) height = g_height + headers_heigth imgl = Magick::ImageList.new imgl.new_image(subject_width+g_width+1, height) gc = Magick::Draw.new # Subjects gc.stroke('transparent') subjects(:image => gc, :top => (headers_heigth + 20), :indent => 4, :format => :image) # Months headers month_f = @date_from left = subject_width @months.times do width = ((month_f >> 1) - month_f) * zoom gc.fill('white') gc.stroke('grey') gc.stroke_width(1) gc.rectangle(left, 0, left + width, height) gc.fill('black') gc.stroke('transparent') gc.stroke_width(1) gc.text(left.round + 8, 14, "#{month_f.year}-#{month_f.month}") left = left + width month_f = month_f >> 1 end # Weeks headers if show_weeks left = subject_width height = header_heigth if @date_from.cwday == 1 # date_from is monday week_f = date_from else # find next monday after date_from week_f = @date_from + (7 - @date_from.cwday + 1) width = (7 - @date_from.cwday + 1) * zoom gc.fill('white') gc.stroke('grey') gc.stroke_width(1) gc.rectangle(left, header_heigth, left + width, 2*header_heigth + g_height-1) left = left + width end while week_f <= date_to width = (week_f + 6 <= date_to) ? 7 * zoom : (date_to - week_f + 1) * zoom gc.fill('white') gc.stroke('grey') gc.stroke_width(1) gc.rectangle(left.round, header_heigth, left.round + width, 2*header_heigth + g_height-1) gc.fill('black') gc.stroke('transparent') gc.stroke_width(1) gc.text(left.round + 2, header_heigth + 14, week_f.cweek.to_s) left = left + width week_f = week_f+7 end end # Days details (week-end in grey) if show_days left = subject_width height = g_height + header_heigth - 1 wday = @date_from.cwday (date_to - @date_from + 1).to_i.times do width = zoom gc.fill(wday == 6 || wday == 7 ? '#eee' : 'white') gc.stroke('#ddd') gc.stroke_width(1) gc.rectangle(left, 2*header_heigth, left + width, 2*header_heigth + g_height-1) left = left + width wday = wday + 1 wday = 1 if wday > 7 end end # border gc.fill('transparent') gc.stroke('grey') gc.stroke_width(1) gc.rectangle(0, 0, subject_width+g_width, headers_heigth) gc.stroke('black') gc.rectangle(0, 0, subject_width+g_width, g_height+ headers_heigth-1) # content top = headers_heigth + 20 gc.stroke('transparent') lines(:image => gc, :top => top, :zoom => zoom, :subject_width => subject_width, :format => :image) # today red line if Date.today >= @date_from and Date.today <= date_to gc.stroke('red') x = (Date.today-@date_from+1)*zoom + subject_width gc.line(x, headers_heigth, x, headers_heigth + g_height-1) end gc.draw(imgl) imgl.format = format imgl.to_blob end |
#to_pdf ⇒ Object
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/redmine/helpers/gantt.rb', line 509 def to_pdf pdf = ::Redmine::Export::PDF::IFPDF.new(current_language) pdf.SetTitle("#{l(:label_gantt)} #{project}") pdf.AliasNbPages pdf. = format_date(Date.today) pdf.AddPage("L") pdf.SetFontStyle('B',12) pdf.SetX(15) pdf.Cell(PDF::LeftPaneWidth, 20, project.to_s) pdf.Ln pdf.SetFontStyle('B',9) subject_width = PDF::LeftPaneWidth header_heigth = 5 headers_heigth = header_heigth show_weeks = false show_days = false if self.months < 7 show_weeks = true headers_heigth = 2*header_heigth if self.months < 3 show_days = true headers_heigth = 3*header_heigth end end g_width = PDF.right_pane_width zoom = (g_width) / (self.date_to - self.date_from + 1) g_height = 120 t_height = g_height + headers_heigth y_start = pdf.GetY # Months headers month_f = self.date_from left = subject_width height = header_heigth self.months.times do width = ((month_f >> 1) - month_f) * zoom pdf.SetY(y_start) pdf.SetX(left) pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C") left = left + width month_f = month_f >> 1 end # Weeks headers if show_weeks left = subject_width height = header_heigth if self.date_from.cwday == 1 # self.date_from is monday week_f = self.date_from else # find next monday after self.date_from week_f = self.date_from + (7 - self.date_from.cwday + 1) width = (7 - self.date_from.cwday + 1) * zoom-1 pdf.SetY(y_start + header_heigth) pdf.SetX(left) pdf.Cell(width + 1, height, "", "LTR") left = left + width+1 end while week_f <= self.date_to width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom pdf.SetY(y_start + header_heigth) pdf.SetX(left) pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C") left = left + width week_f = week_f+7 end end # Days headers if show_days left = subject_width height = header_heigth wday = self.date_from.cwday pdf.SetFontStyle('B',7) (self.date_to - self.date_from + 1).to_i.times do width = zoom pdf.SetY(y_start + 2 * header_heigth) pdf.SetX(left) pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C") left = left + width wday = wday + 1 wday = 1 if wday > 7 end end pdf.SetY(y_start) pdf.SetX(15) pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1) # Tasks top = headers_heigth + y_start = { :top => top, :zoom => zoom, :subject_width => subject_width, :g_width => g_width, :indent => 0, :indent_increment => 5, :top_increment => 5, :format => :pdf, :pdf => pdf } render() pdf.Output end |
#version_issues(project, version) ⇒ Object
Returns the issues that belong to project
and are assigned to version
170 171 172 |
# File 'lib/redmine/helpers/gantt.rb', line 170 def version_issues(project, version) project_issues(project).select {|issue| issue.fixed_version == version} end |