1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253 | 1×
1×
1×
1×
118×
118×
118×
118×
118×
118×
118×
118×
118×
118×
118×
118×
118×
1×
302×
302×
302×
302×
302×
302×
302×
302×
1255×
1255×
1215×
1215×
1215×
1066×
1066×
1066×
1066×
149×
149×
149×
149×
149×
1215×
1215×
1214×
1214×
1214×
1065×
40×
301×
301×
301×
301×
5836×
5836×
5791×
5791×
5791×
8×
8×
8×
5791×
5791×
5791×
5791×
5791×
5791×
71×
45×
301×
1×
294×
294×
1268×
1163×
1163×
1121×
1121×
294×
294×
294×
3469×
3349×
3349×
3175×
3175×
1×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
11302×
2336×
2336×
8966×
8966×
8966×
11302×
11302×
11302×
235×
11301×
11301×
11301×
11301×
11301×
1190×
11301×
5971×
5971×
5971×
5971×
72×
72×
55×
72×
54×
54×
54×
54×
54×
54×
5899×
1616×
924×
2632×
436×
60×
60×
60×
11301×
11301×
9998×
11301×
11301×
4446×
6855×
11301×
11301×
54×
54×
54×
54×
54×
54×
54×
54×
54×
54×
11301×
52×
52×
52×
52×
52×
52×
52×
52×
52×
52×
52×
11301×
11301×
99×
11301×
11301×
11301×
11301×
11301×
11301×
2335×
8966×
11301×
11301×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-pdf-export", "@syncfusion/ej2-base", "../base/utils"], function (require, exports, ej2_pdf_export_1, ej2_base_1, utils_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PdfTimeline = (function () {
function PdfTimeline(gantt) {
this.holidayCompleted = false;
this.fitHolidayCompleted = false;
this.timelineWidth = 0;
this.lastWidth = 0;
this.width = 0;
this.gantt = gantt;
this.parent = gantt.parent;
this.topTierPoint = new ej2_pdf_export_1.PointF();
this.bottomTierPoint = new ej2_pdf_export_1.PointF();
this.topTierIndex = 0;
this.bottomTierIndex = 0;
this.prevTopTierIndex = 0;
this.prevBottomTierIndex = 0;
}
PdfTimeline.prototype.drawTimeline = function (page, startPoint, detail) {
this.detailsTimeline = detail;
var remainWidth = (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ?
utils_1.pointToPixel(Math.floor(detail.totalWidth)) : Math.round(detail.totalWidth);
var renderWidth = 0;
this.topTierPoint.x = startPoint.x;
this.topTierPoint.y = startPoint.y;
this.prevTopTierIndex = this.topTierIndex;
this.prevBottomTierIndex = this.bottomTierIndex;
while (remainWidth > 0) {
var pHeader = this.topTier[this.topTierIndex];
if (this.topTier.length > this.topTierIndex) {
var isCompleted = false;
Eif (!this.topTier[this.topTierIndex].isFinished) {
if (remainWidth >= pHeader.width) {
renderWidth = pHeader.width;
pHeader.isFinished = true;
pHeader.completedWidth = renderWidth;
isCompleted = true;
}
else {
renderWidth = remainWidth;
isCompleted = false;
pHeader.isFinished = false;
pHeader.width = pHeader.width - remainWidth;
pHeader.completedWidth = renderWidth;
}
}
var reWidth = (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ? renderWidth : utils_1.pixelToPoint(renderWidth);
this.triggerQueryTimelinecell(page, this.topTierPoint.x, this.topTierPoint.y, this.topTierHeight, reWidth, pHeader.value, true, this.parent.timelineModule.isSingleTier &&
this.parent.timelineSettings.topTier.unit === 'Day' ? pHeader.startDate : null);
this.topTierPoint.x += reWidth;
remainWidth -= renderWidth;
if (isCompleted) {
this.topTierIndex++;
}
}
else {
remainWidth = 0;
}
}
remainWidth = Math.round(detail.totalWidth);
var height = this.parent.timelineModule.isSingleTier ? 0 : this.topTierHeight;
this.bottomTierPoint = new ej2_pdf_export_1.PointF(startPoint.x, utils_1.pixelToPoint(startPoint.y + height));
while (remainWidth > 0) {
var secondHeader = this.bottomTier[this.bottomTierIndex];
if (this.bottomTier.length > this.bottomTierIndex) {
var isCompleted = true;
var width = secondHeader.width;
if (remainWidth < width) {
width = remainWidth;
isCompleted = false;
secondHeader.completedWidth = width;
}
this.triggerQueryTimelinecell(page, this.bottomTierPoint.x, this.bottomTierPoint.y, this.bottomTierHeight, (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ? width : utils_1.pixelToPoint(width), secondHeader.value, false, secondHeader.startDate);
this.bottomTierPoint.x = (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ?
this.bottomTierPoint.x + width : this.bottomTierPoint.x + utils_1.pixelToPoint(width);
remainWidth -= width;
secondHeader.completedWidth = width;
this.bottomTierIndex++;
if (remainWidth > 0 && remainWidth < width) {
remainWidth = secondHeader.width - 1;
}
}
else {
remainWidth = 0;
}
}
this.timelineWidth = this.lastWidth;
};
PdfTimeline.prototype.drawPageTimeline = function (page, startPoint, detail) {
this.topTierPoint = ej2_base_1.extend({}, {}, startPoint, true);
for (var index = this.prevTopTierIndex; index <= this.topTierIndex; index++) {
if (this.topTier.length > index) {
var pHeader = this.topTier[index];
if (pHeader.completedWidth > 0) {
this.triggerQueryTimelinecell(page, this.topTierPoint.x, this.topTierPoint.y, this.topTierHeight, (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ? pHeader.completedWidth : utils_1.pixelToPoint(pHeader.completedWidth), pHeader.value, true, this.parent.timelineModule.isSingleTier &&
this.parent.timelineSettings.topTier.unit === 'Day' ? pHeader.startDate : null);
this.topTierPoint.x += (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ?
pHeader.completedWidth : utils_1.pixelToPoint(pHeader.completedWidth);
}
}
}
this.bottomTierPoint.x = startPoint.x;
this.bottomTierPoint.y = utils_1.pixelToPoint(startPoint.y + this.topTierHeight);
for (var index = this.prevBottomTierIndex; index <= this.bottomTierIndex; index++) {
if (this.bottomTier.length > index) {
var secondHeader = this.bottomTier[index];
if (secondHeader.completedWidth > 0) {
this.triggerQueryTimelinecell(page, this.bottomTierPoint.x, this.bottomTierPoint.y, this.bottomTierHeight, (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ? secondHeader.width : utils_1.pixelToPoint(secondHeader.width), secondHeader.value, false, secondHeader.startDate);
this.bottomTierPoint.x = (this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) ?
this.bottomTierPoint.x + secondHeader.width : this.bottomTierPoint.x + utils_1.pixelToPoint(secondHeader.width);
}
}
}
};
PdfTimeline.prototype.triggerQueryTimelinecell = function (page, x, y, height, width, value, isTopTier, currentDate) {
var _this = this;
var days = new Date(currentDate).getDay();
var graphics = page.graphics;
var timelineStyle = {};
var ganttStyle = this.gantt.ganttStyle;
timelineStyle.borderColor = new ej2_pdf_export_1.PdfColor(ganttStyle.timeline.borderColor);
timelineStyle.fontColor = new ej2_pdf_export_1.PdfColor(ganttStyle.timeline.fontColor);
timelineStyle.fontSize = ganttStyle.timeline.fontSize;
timelineStyle.fontStyle = ganttStyle.timeline.fontStyle;
timelineStyle.backgroundColor = new ej2_pdf_export_1.PdfColor(ganttStyle.timeline.backgroundColor);
Iif (ganttStyle.timeline.padding) {
timelineStyle.padding = ganttStyle.timeline.padding;
}
var format = new ej2_pdf_export_1.PdfStringFormat();
Eif (ej2_base_1.isNullOrUndefined(ganttStyle.timeline.format)) {
if (isTopTier) {
format.lineAlignment = ej2_pdf_export_1.PdfVerticalAlignment.Middle;
format.alignment = ej2_pdf_export_1.PdfTextAlignment.Left;
}
else {
format.lineAlignment = ej2_pdf_export_1.PdfVerticalAlignment.Middle;
format.alignment = ej2_pdf_export_1.PdfTextAlignment.Center;
format.wordWrap = ej2_pdf_export_1.PdfWordWrapType.Character;
}
}
else {
format = ganttStyle.timeline.format;
}
timelineStyle.format = format;
var eventArgs = {
timelineCell: timelineStyle,
value: value
};
if (this.parent.pdfQueryTimelineCellInfo) {
this.parent.trigger('pdfQueryTimelineCellInfo', eventArgs);
}
var e = eventArgs.timelineCell;
var rectPen;
var rectBrush = new ej2_pdf_export_1.PdfSolidBrush(eventArgs.timelineCell.backgroundColor);
var nonWorkingDays = this.parent.nonWorkingDayIndex;
if (this.parent.highlightWeekends && nonWorkingDays.indexOf(days) !== -1 && (this.parent.timelineModule.bottomTier === 'Day' || this.parent.timelineModule.bottomTier === 'None' && this.parent.timelineModule.topTier === 'Day')) {
rectBrush = new ej2_pdf_export_1.PdfSolidBrush(new ej2_pdf_export_1.PdfColor(238, 238, 238));
}
this.parent.holidays.map(function (item) {
var fromDate = new Date(item.from);
var toDate = new Date(item.to);
var timelinedate = new Date(currentDate);
if (fromDate <= timelinedate && toDate >= timelinedate && (_this.parent.timelineModule.bottomTier === 'Day' || (_this.parent.timelineModule.bottomTier === 'None' && _this.parent.timelineModule.topTier === 'Day'))) {
rectBrush = new ej2_pdf_export_1.PdfSolidBrush(new ej2_pdf_export_1.PdfColor(238, 238, 238));
if (fromDate.getTime() === timelinedate.getTime()) {
_this.holidayWidth = x;
}
if (toDate.getTime() === timelinedate.getTime()) {
_this.holidayLabel = item.label;
var changeDate = new Date(item.to);
changeDate.setDate(changeDate.getDate() + 1);
var day = _this.parent.dataOperation.getTaskWidth(fromDate, changeDate);
_this.holidayNumberOfDays = day / width;
_this.holidayCompleted = true;
}
}
else if (_this.parent.timelineModule.bottomTier !== 'Day') {
if (_this.detailsTimeline.startDate <= fromDate && _this.detailsTimeline.endDate >= fromDate) {
_this.parent.timelineModule.bottomTierCollection.map(function (items) {
if (items.startDate <= fromDate && items.endDate >= fromDate) {
if (items.startDate === currentDate) {
_this.fitHolidayCompleted = true;
_this.fromDataHoliday = item.from;
_this.holidayLabel = item.label;
}
}
});
}
}
});
var rectPen1 = new ej2_pdf_export_1.PdfPen(eventArgs.timelineCell.borderColor);
if (!this.parent.pdfExportModule.gantt.taskbar.isAutoFit()) {
this.lastWidth = x + width;
}
graphics.drawRectangle(rectPen1, rectBrush, x, y, width, utils_1.pixelToPoint(height));
if (!isTopTier && (this.parent.gridLines === 'Both' || this.parent.gridLines === 'Vertical')) {
rectPen = new ej2_pdf_export_1.PdfPen(eventArgs.timelineCell.borderColor);
}
else {
rectPen = null;
}
graphics.drawRectangle(rectPen, rectBrush, x, y + utils_1.pixelToPoint(height), width, page.getClientSize().height);
if (this.holidayCompleted) {
var state_1 = graphics.save();
var font1 = new ej2_pdf_export_1.PdfStandardFont(ej2_pdf_export_1.PdfFontFamily.Helvetica, 10);
var fontHieght = font1.height;
var fontSize = font1.size;
graphics.translateTransform(this.holidayWidth + width - ((fontSize / 2) * this.holidayNumberOfDays) -
fontHieght + (fontHieght / 2) + (width * this.holidayNumberOfDays) / 2, 40);
graphics.rotateTransform(-90);
graphics.translateTransform(-(page.getClientSize().height / 2), -40);
graphics.drawString(this.holidayLabel, font1, null, ej2_pdf_export_1.PdfBrushes.Black, 10, 10, null);
graphics.restore(state_1);
this.holidayCompleted = false;
}
if (this.fitHolidayCompleted) {
var holidayBrush = new ej2_pdf_export_1.PdfSolidBrush(new ej2_pdf_export_1.PdfColor(238, 238, 238));
var font1 = new ej2_pdf_export_1.PdfStandardFont(ej2_pdf_export_1.PdfFontFamily.Helvetica, 10);
var fontSize = font1.size;
graphics.drawRectangle(null, holidayBrush, x + (width / 2) - fontSize, y +
utils_1.pixelToPoint(height), fontSize, page.getClientSize().height);
var state_2 = graphics.save();
graphics.translateTransform(x + width + (width / 2) - fontSize, 40);
graphics.rotateTransform(-90);
graphics.translateTransform(-(page.getClientSize().height / 2), -40);
graphics.drawString(this.holidayLabel, font1, null, ej2_pdf_export_1.PdfBrushes.Black, 10, 10, null);
graphics.restore(state_2);
this.fitHolidayCompleted = false;
}
var font = new ej2_pdf_export_1.PdfStandardFont(ganttStyle.fontFamily, e.fontSize, e.fontStyle);
if (ganttStyle.font) {
font = ganttStyle.font;
}
var textBrush = new ej2_pdf_export_1.PdfSolidBrush(eventArgs.timelineCell.fontColor);
var pLeft = ganttStyle.timeline.padding ? eventArgs.timelineCell.padding.left : 0;
var pTop = ganttStyle.timeline.padding ? eventArgs.timelineCell.padding.top : 0;
var state = graphics.save();
graphics.setClip(new ej2_pdf_export_1.RectangleF(x, y, width, utils_1.pixelToPoint(height)));
if (isTopTier) {
x = x + pLeft + 4;
}
else {
x = x + pLeft;
}
graphics.drawString(eventArgs.value, font, null, textBrush, x, y + pTop, utils_1.pixelToPoint(width), utils_1.pixelToPoint(height), e.format);
graphics.restore(state);
};
return PdfTimeline;
}());
exports.PdfTimeline = PdfTimeline;
});
|