Project

General

Profile

Actions

Defect #32916

closed

Bar length is wrong when exporting gantt chart to PDF

Added by Anonymous almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Gantt
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Duplicate
Affected version:

Description

When exporting a gantt chart to PDF, short (1 or 2 days) tasks are sometimes correct and sometimes incorrect, depending on the time period.
(The attached image is modified.)
Export gantt to PDF

Calculation error of start and end points?
Or error due to Windows environment?

Same for Redmine 4.0.4 and earlier.


Files

gc2pdf.png (80.9 KB) gc2pdf.png Export gantt to PDF Anonymous, 2020-01-29 06:11

Related issues

Is duplicate of Redmine - Defect #23645: Gantt bars for single-day tasks may be rendered wrongly in PDFClosedGo MAEDA

Actions
Actions #1

Updated by Anonymous almost 5 years ago

Improved bar length calculation accuracy for exporting to PDF (and png).
(modified patch code)

--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -632,7 +632,7 @@
           end
           if end_date < self.date_to
             coords[:end] = end_date - self.date_from
-            coords[:bar_end] = end_date - self.date_from + 1
+            coords[:bar_end] = calc_bar_end(coords[:bar_start], end_date, zoom)
           else
             coords[:bar_end] = self.date_to - self.date_from + 1
           end
@@ -640,16 +640,16 @@
             progress_date = calc_progress_date(start_date, end_date, progress)
             if progress_date > self.date_from && progress_date > start_date
               if progress_date < self.date_to
-                coords[:bar_progress_end] = progress_date - self.date_from
+                coords[:bar_progress_end] = calc_bar_end(coords[:bar_start], progress_date, zoom)
               else
                 coords[:bar_progress_end] = self.date_to - self.date_from + 1
               end
             end
             if progress_date <= User.current.today
-              late_date = [User.current.today, end_date].min + 1
+              late_date = [User.current.today, end_date].min
               if late_date > self.date_from && late_date > start_date
                 if late_date < self.date_to
-                  coords[:bar_late_end] = late_date - self.date_from
+                  coords[:bar_late_end] = calc_bar_end(coords[:bar_start], late_date, zoom)
                 else
                   coords[:bar_late_end] = self.date_to - self.date_from + 1
                 end
@@ -665,7 +665,16 @@
       end

       def calc_progress_date(start_date, end_date, progress)
-        start_date + (end_date - start_date + 1) * (progress / 100.0)
+        start_date + (end_date - start_date) * (progress / 100.0)
+      end
+
+      def calc_bar_end(start_date, end_date, zoom)
+        end_of_bar = end_date - self.date_from + 1
+        start_zoom = (start_date * zoom).floor
+        if (end_of_bar * zoom).floor <= start_zoom
+          end_of_bar = (start_zoom + 1) / zoom
+        end
+        end_of_bar
       end

       # Singleton class method is public
Actions #2

Updated by Anonymous over 4 years ago

  • Status changed from New to Resolved

Related to #23645 (Gantt bars for single-day tasks may be rendered wrongly in PDF)

Actions #3

Updated by Mischa The Evil over 4 years ago

  • Status changed from Resolved to Needs feedback
  • Assignee set to Anonymous

taca tadocolo wrote:

Related to #23645 (Gantt bars for single-day tasks may be rendered wrongly in PDF)

So the issue reported in this issue is solved by the changes for #23645? Can you confirm that is the case (also the png version of the gantt)?

Actions #4

Updated by Anonymous over 4 years ago

Mischa The Evil wrote:

taca tadocolo wrote:

Related to #23645 (Gantt bars for single-day tasks may be rendered wrongly in PDF)

So the issue reported in this issue is solved by the changes for #23645? Can you confirm that is the case (also the png version of the gantt)?

Yes, I confirmed this issue has been resolved in Redmine 4.1.1.

Actions #5

Updated by Mischa The Evil over 4 years ago

  • Is duplicate of Defect #23645: Gantt bars for single-day tasks may be rendered wrongly in PDF added
Actions #6

Updated by Mischa The Evil over 4 years ago

  • Status changed from Needs feedback to Closed
  • Assignee deleted (Anonymous)
  • Resolution set to Duplicate

Thanks for the feedback. Closing as such.

Actions

Also available in: Atom PDF