Defect #32916 closed
Bar length is wrong when exporting gantt chart to PDF
Added by Anonymous almost 7 years ago.
Updated over 6 years ago.
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.)
Calculation error of start and end points? Or error due to Windows environment?
Same for Redmine 4.0.4 and earlier.
Files
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
Status changed from New to Resolved
Related to #23645 (Gantt bars for single-day tasks may be rendered wrongly in PDF)
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)?
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.
Is duplicate of Defect #23645 : Gantt bars for single-day tasks may be rendered wrongly in PDF added
Status changed from Needs feedback to Closed
Assignee deleted (Anonymous )
Resolution set to Duplicate
Thanks for the feedback. Closing as such.
Also available in: PDF
Atom