Redmine の ガントチャートの PDF 出力に縦線を出してみた

--- lib/redmine/helpers/gantt.rb.org	Mon Mar 07 20:41:58 2011
+++ lib/redmine/helpers/gantt.rb	Thu Apr 07 18:24:09 2011
@@ -259,0 +260 @@
+          vertical_line_pdf(options)
@@ -261,0 +263,21 @@
+      
+      def vertical_line_pdf(options)
+        left = options[:subject_width]
+        day = 0
+        options[:pdf].SetFontStyle('B',7)
+        width = options[:zoom]
+        options[:pdf].SetDrawColor(200,200,200)
+        (self.date_to - self.date_from).to_i.times do 
+          options[:pdf].SetY(options[:top_start])
+          options[:pdf].SetX(left)
+          options[:pdf].Cell(width, options[:top] - options[:top_start], "", "R", 0, "C")
+          if Time.now.beginning_of_day == self.date_from.since(day.days)
+            options[:pdf].SetDrawColor(255, 0, 0)
+            options[:pdf].Line(left + width / 2, options[:top_start], left + width / 2, options[:top])
+            options[:pdf].SetDrawColor(200,200,200)
+          end
+          left = left + width
+          day = day + 1
+        end
+        options[:pdf].SetDrawColor(0, 0, 0)
+      end
@@ -529,0 +552 @@
+        show_day_num = false
@@ -536 +559,2 @@
-            headers_heigth = 3*header_heigth
+            show_day_num = true
+            headers_heigth = 4*header_heigth
@@ -584,0 +609,27 @@
+
+        # Day num headers
+        if show_day_num
+          left = subject_width
+          height = header_heigth
+          wday = self.date_from.cwday
+          pdf.SetFontStyle('B',7)
+          day_num = self.date_from
+          (self.date_to - self.date_from + 1).to_i.times do
+            width =  zoom 
+            pdf.SetY(y_start + 2 * header_heigth)
+            pdf.SetX(left)
+            case(wday)
+            when 6
+              pdf.SetTextColor(0, 0, 255)
+            when 7
+              pdf.SetTextColor(255, 0, 0)
+            else
+              pdf.SetTextColor(0, 0, 0)
+            end
+            pdf.Cell(width, height, day_num.day.to_s, "LTR", 0, "C")
+            left = left + width
+            day_num = day_num + 1
+            wday = wday + 1
+            wday = 1 if wday > 7
+          end
+        end
@@ -594 +645 @@
-            pdf.SetY(y_start + 2 * header_heigth)
+            pdf.SetY(y_start + 3 * header_heigth)
@@ -595,0 +647,8 @@
+            case(wday)
+            when 6
+              pdf.SetTextColor(0, 0, 255)
+            when 7
+              pdf.SetTextColor(255, 0, 0)
+            else
+              pdf.SetTextColor(0, 0, 0)
+            end
@@ -602 +661,2 @@
-        
+
+        pdf.SetTextColor(0, 0, 0)
@@ -610,0 +671 @@
+          :top_start => top,
@@ -704,0 +766 @@
+          vertical_line_pdf(options)
@@ -706 +768 @@
-          options[:top] = 15
+          options[:top] = options[:top_start] = 15