プロジェクト

全般

プロフィール

Vote #77753

完了

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

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Gantt_34
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
34
version_id:
159
issue_org_id:
23645
author_id:
48958
assigned_to_id:
332
comments:
8
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.


journals

LGTM. I hope for early adoption.
--------------------------------------------------------------------------------
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) ?
--------------------------------------------------------------------------------
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.

!pdf-vs-png.png!

--------------------------------------------------------------------------------
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.

!{width:600px;border:1px solid #ccc;}set-huge-months.png!

!{width:600px;border:1px solid #ccc;}actual-pdf.png!

> 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":https://www.redmine.org/attachments/download/16573/gantt-single-day-task-pdf-rendering.patch should be incorporated. This problem will be solved.
--------------------------------------------------------------------------------
Setting the target version to 4.0.7.
--------------------------------------------------------------------------------
Committed the patch. Thank you for your contribution.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

duplicates,Closed,32916,Bar length is wrong when exporting gantt chart to PDF

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0