Project

General

Profile

Actions

Defect #23645

closed

Gantt bars for single-day tasks may be rendered wrongly in PDF

Added by Daniel Ritz over 8 years ago. Updated almost 5 years ago.

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

0%

Estimated time:
Resolution:
Affected version:

Description

When a task starts and ends on the same day, it can happen that the bar in the PDF is rendered wrong, i.e. it's rendered from the start day to the right end of the page.

The problem is in lib/redmine/helpers/gantt.rb. When #pdf_task is called, coords[:bar_end] - coords[:bar_start] happens to be 0. The cause for this is the zoom factor applied in #coordindates and the subsequent #floor. By adding some Rails.logger statements I got this:

coords[start]: 92/1, zoom: 36/73
coords[start]: 45
coords[bar_start]: 92/1, zoom: 36/73
coords[bar_start]: 45
coords[end]: 92/1, zoom: 36/73
coords[end]: 45
coords[bar_end]: 93/1, zoom: 36/73
coords[bar_end]: 45

Each value shown before/after applying zoom. While before zoom, the values where 92/93, the became 45/45 afterwards.

The attached patch fixes the PDF rendering problem by making sure, the with used in the RDMCell() call is at least 0.


Files

gantt-single-day-task-pdf-rendering.patch (1.71 KB) gantt-single-day-task-pdf-rendering.patch Daniel Ritz, 2016-08-23 18:48
gannt_1daytask.JPG (55.3 KB) gannt_1daytask.JPG Sutamin Lynfiled, 2017-01-02 16:53
pdf-vs-png.png (47.3 KB) pdf-vs-png.png Daniel Ritz, 2017-01-04 11:42
set-huge-months.png (235 KB) set-huge-months.png Yuichi HARADA, 2020-03-19 08:25
actual-pdf.png (332 KB) actual-pdf.png Yuichi HARADA, 2020-03-19 08:25

Related issues

Has duplicate Redmine - Defect #32916: Bar length is wrong when exporting gantt chart to PDFClosed

Actions
Actions #1

Updated by Sutamin Lynfiled almost 8 years ago

LGTM. I hope for early adoption.

Actions #2

Updated by Go MAEDA almost 8 years ago

I have not been able to reproduce the problem yet.
Could you please describe the detailed steps to reproduce the problem and upload screenshots (before fix and after fix) ?

Actions #3

Updated by Daniel Ritz almost 8 years ago

Sorry, I have no easy reproducer. I used a dump of our productive DB while working on the fix...

Attached is a screenshot with comparing the Gantt rendered correctly as PNG and incorrectly as PDF. After the fix, the PDF looks correct too (no screenshot taken).
Tasks 3-7 shown on the screenshot are single-day tasks and should all render the same.

Actions #4

Updated by Yuichi HARADA almost 5 years ago

Daniel Ritz wrote:

When a task starts and ends on the same day, it can happen that the bar in the PDF is rendered wrong, i.e. it's rendered from the start day to the right end of the page.

I have confirmed.
If you set a huge value to the Gantt display months, all Gantt bars for issues with the extremely short the start date and due date will appear in the PDF this way.

The attached patch fixes the PDF rendering problem by making sure, the with used in the RDMCell() call is at least 0.

I think gantt-single-day-task-pdf-rendering.patch should be incorporated. This problem will be solved.

Actions #5

Updated by Go MAEDA almost 5 years ago

  • Target version set to 4.0.7

Setting the target version to 4.0.7.

Actions #6

Updated by Go MAEDA almost 5 years ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch. Thank you for your contribution.

Actions #7

Updated by Go MAEDA almost 5 years ago

  • Tracker changed from Patch to Defect
  • Subject changed from Fix Gantt PDF rendering for single-day tasks to Gantt bars for single-day tasks may be rendered wrongly in PDF
Actions #8

Updated by Mischa The Evil over 4 years ago

  • Has duplicate Defect #32916: Bar length is wrong when exporting gantt chart to PDF added
Actions

Also available in: Atom PDF