@hpcc-js/timeline 2.51.14 → 2.51.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1613 +1,1618 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@hpcc-js/api'), require('@hpcc-js/chart'), require('@hpcc-js/common'), require('@hpcc-js/html'), require('@hpcc-js/react'), require('@hpcc-js/layout')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@hpcc-js/api', '@hpcc-js/chart', '@hpcc-js/common', '@hpcc-js/html', '@hpcc-js/react', '@hpcc-js/layout'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@hpcc-js/timeline"] = {}, global["@hpcc-js/api"], global["@hpcc-js/chart"], global["@hpcc-js/common"], global["@hpcc-js/html"], global["@hpcc-js/react"], global["@hpcc-js/layout"]));
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@hpcc-js/api'), require('@hpcc-js/chart'), require('@hpcc-js/common'), require('@hpcc-js/html'), require('@hpcc-js/react'), require('@hpcc-js/layout')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@hpcc-js/api', '@hpcc-js/chart', '@hpcc-js/common', '@hpcc-js/html', '@hpcc-js/react', '@hpcc-js/layout'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@hpcc-js/timeline"] = {}, global["@hpcc-js/api"], global["@hpcc-js/chart"], global["@hpcc-js/common"], global["@hpcc-js/html"], global["@hpcc-js/react"], global["@hpcc-js/layout"]));
5
5
  })(this, (function (exports, api, chart, common, html, react, layout) { 'use strict';
6
6
 
7
- var PKG_NAME = "@hpcc-js/timeline";
8
- var PKG_VERSION = "2.51.14";
9
- var BUILD_VERSION = "2.104.28";
7
+ var PKG_NAME = "@hpcc-js/timeline";
8
+ var PKG_VERSION = "2.51.16";
9
+ var BUILD_VERSION = "2.104.32";
10
10
 
11
- /******************************************************************************
12
- Copyright (c) Microsoft Corporation.
13
-
14
- Permission to use, copy, modify, and/or distribute this software for any
15
- purpose with or without fee is hereby granted.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
- PERFORMANCE OF THIS SOFTWARE.
24
- ***************************************************************************** */
25
- /* global Reflect, Promise */
26
-
27
- var extendStatics = function(d, b) {
28
- extendStatics = Object.setPrototypeOf ||
29
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
31
- return extendStatics(d, b);
32
- };
33
-
34
- function __extends(d, b) {
35
- if (typeof b !== "function" && b !== null)
36
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
37
- extendStatics(d, b);
38
- function __() { this.constructor = d; }
39
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40
- }
41
-
42
- var __assign = function() {
43
- __assign = Object.assign || function __assign(t) {
44
- for (var s, i = 1, n = arguments.length; i < n; i++) {
45
- s = arguments[i];
46
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47
- }
48
- return t;
49
- };
50
- return __assign.apply(this, arguments);
51
- };
52
-
53
- function __spreadArray(to, from, pack) {
54
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
- if (ar || !(i in from)) {
56
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
- ar[i] = from[i];
58
- }
59
- }
60
- return to.concat(ar || Array.prototype.slice.call(from));
61
- }
11
+ /******************************************************************************
12
+ Copyright (c) Microsoft Corporation.
13
+
14
+ Permission to use, copy, modify, and/or distribute this software for any
15
+ purpose with or without fee is hereby granted.
62
16
 
63
- function styleInject(css, ref) {
64
- if ( ref === void 0 ) ref = {};
65
- var insertAt = ref.insertAt;
17
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
18
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
19
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
20
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
22
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23
+ PERFORMANCE OF THIS SOFTWARE.
24
+ ***************************************************************************** */
25
+ /* global Reflect, Promise, SuppressedError, Symbol */
66
26
 
67
- if (!css || typeof document === 'undefined') { return; }
27
+ var extendStatics = function(d, b) {
28
+ extendStatics = Object.setPrototypeOf ||
29
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
30
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
31
+ return extendStatics(d, b);
32
+ };
68
33
 
69
- var head = document.head || document.getElementsByTagName('head')[0];
70
- var style = document.createElement('style');
71
- style.type = 'text/css';
34
+ function __extends(d, b) {
35
+ if (typeof b !== "function" && b !== null)
36
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
37
+ extendStatics(d, b);
38
+ function __() { this.constructor = d; }
39
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
40
+ }
41
+
42
+ var __assign = function() {
43
+ __assign = Object.assign || function __assign(t) {
44
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
45
+ s = arguments[i];
46
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
47
+ }
48
+ return t;
49
+ };
50
+ return __assign.apply(this, arguments);
51
+ };
72
52
 
73
- if (insertAt === 'top') {
74
- if (head.firstChild) {
75
- head.insertBefore(style, head.firstChild);
76
- } else {
77
- head.appendChild(style);
53
+ function __spreadArray(to, from, pack) {
54
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
+ if (ar || !(i in from)) {
56
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
57
+ ar[i] = from[i];
78
58
  }
59
+ }
60
+ return to.concat(ar || Array.prototype.slice.call(from));
61
+ }
62
+
63
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
64
+ var e = new Error(message);
65
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
66
+ };
67
+
68
+ function styleInject(css, ref) {
69
+ if ( ref === void 0 ) ref = {};
70
+ var insertAt = ref.insertAt;
71
+
72
+ if (!css || typeof document === 'undefined') { return; }
73
+
74
+ var head = document.head || document.getElementsByTagName('head')[0];
75
+ var style = document.createElement('style');
76
+ style.type = 'text/css';
77
+
78
+ if (insertAt === 'top') {
79
+ if (head.firstChild) {
80
+ head.insertBefore(style, head.firstChild);
79
81
  } else {
80
82
  head.appendChild(style);
81
83
  }
84
+ } else {
85
+ head.appendChild(style);
86
+ }
82
87
 
83
- if (style.styleSheet) {
84
- style.styleSheet.cssText = css;
85
- } else {
86
- style.appendChild(document.createTextNode(css));
87
- }
88
+ if (style.styleSheet) {
89
+ style.styleSheet.cssText = css;
90
+ } else {
91
+ style.appendChild(document.createTextNode(css));
88
92
  }
93
+ }
89
94
 
90
- var css_248z = ".timeline_MiniGantt .line{fill:none;stroke:#d3d3d3;opacity:.7}.timeline_MiniGantt .common_TextBox .rect{fill:#87cefa;stroke:blue;opacity:.5}.timeline_MiniGantt .buckets .entity_shape rect{stroke:#333}.timeline_MiniGantt .buckets.selected .common_EntityRect .common_Shape>rect{stroke:red}.timeline_MiniGantt .common_TextBox .rect text{fill:#000;stroke:none}.timeline_MiniGantt .over{stroke:transparent;opacity:.8}.timeline_MiniGantt rect{shape-rendering:crispEdges}";
91
- styleInject(css_248z);
95
+ var css_248z = ".timeline_MiniGantt .line{fill:none;stroke:#d3d3d3;opacity:.7}.timeline_MiniGantt .common_TextBox .rect{fill:#87cefa;stroke:blue;opacity:.5}.timeline_MiniGantt .buckets .entity_shape rect{stroke:#333}.timeline_MiniGantt .buckets.selected .common_EntityRect .common_Shape>rect{stroke:red}.timeline_MiniGantt .common_TextBox .rect text{fill:#000;stroke:none}.timeline_MiniGantt .over{stroke:transparent;opacity:.8}.timeline_MiniGantt rect{shape-rendering:crispEdges}";
96
+ styleInject(css_248z);
92
97
 
93
- var MiniGantt = /** @class */ (function (_super) {
94
- __extends(MiniGantt, _super);
95
- function MiniGantt() {
96
- var _this = _super.call(this) || this;
97
- _this.localRect = common.local();
98
- _this.localEntityPin = common.local();
99
- _this._title_idx = 0;
100
- _this._startDate_idx = 1;
101
- _this._endDate_idx = 2;
102
- _this._icon_idx = -1;
103
- _this._color_idx = -1;
104
- _this._yoffset_idx = -1;
105
- api.ITooltip.call(_this);
106
- common.Utility.SimpleSelectionMixin.call(_this);
107
- _this._drawStartPos = "origin";
108
- _this.tooltipHTML(function (d) { return "<center>".concat(d[_this._title_idx], "</center><br>").concat(_this.tooltipFormatter(_this.brAxis.parse(d[_this._startDate_idx])), " -> ").concat(_this.tooltipFormatter(_this.brAxis.parse(d[_this._endDate_idx]))); });
109
- _this.tlAxis = new chart.Axis()
110
- .type("time");
111
- _this.brAxis = new chart.Axis()
112
- .type("time");
113
- _this.verticalBands = common.scaleBand()
114
- .paddingOuter(0.2)
115
- .paddingInner(0.2);
116
- return _this;
117
- }
118
- MiniGantt.prototype.isHorizontal = function () {
119
- return this.orientation() === "horizontal";
120
- };
121
- MiniGantt.prototype.fullExtent = function () {
122
- var _this = this;
123
- var data = __spreadArray(__spreadArray([], this.data().map(function (d) { return d[_this._startDate_idx]; }), true), this.data().filter(function (d) { return !!d[_this._endDate_idx]; }).map(function (d) { return d[_this._endDate_idx]; }), true);
124
- return common.extent(data);
125
- };
126
- MiniGantt.prototype.extent = function () {
127
- var extent = this.rootExtent ? [this.rootExtent[1], this.rootExtent[2]] : this.fullExtent();
128
- if (extent[0] !== undefined && extent[1] !== undefined) {
129
- if (extent[0] === extent[1] || this.centerOnMostRecent()) {
130
- var parser = common.timeParse(this.timePattern());
131
- var formatter = common.timeFormat(this.timePattern());
132
- var date1 = parser(extent[0]);
133
- var date2 = parser(extent[1]);
134
- if (extent[0] === extent[1]) {
135
- extent[0] = formatter(new Date(date1.setFullYear(date1.getFullYear() - 1)));
136
- extent[1] = formatter(new Date(date1.setFullYear(date1.getFullYear() + 2)));
137
- }
138
- else {
139
- var time1 = date1.getTime();
140
- var timeDiff = date2.getTime() - time1;
141
- extent[0] = formatter(date1);
142
- extent[1] = formatter(new Date(time1 + (timeDiff * 2)));
143
- }
144
- }
145
- }
146
- return extent;
147
- };
148
- MiniGantt.prototype.dataStartPos = function (d) {
149
- if (typeof this._dateCache[d[this._startDate_idx]] !== "undefined") {
150
- return this._dateCache[d[this._startDate_idx]];
151
- }
152
- var pos = this.brAxis.scalePos(d[this._startDate_idx]);
153
- this._dateCache[d[this._startDate_idx]] = pos;
154
- return pos;
155
- };
156
- MiniGantt.prototype.dataEndPos = function (d) {
157
- if (typeof this._dateCache[d[this._endDate_idx]] !== "undefined") {
158
- return this._dateCache[d[this._endDate_idx]];
159
- }
160
- var pos = this.brAxis.scalePos(d[this._endDate_idx]);
161
- this._dateCache[d[this._endDate_idx]] = pos;
162
- return pos;
163
- };
164
- MiniGantt.prototype.dataWidth = function (d) {
165
- return this.dataEndPos(d) - this.dataStartPos(d);
166
- };
167
- MiniGantt.prototype.resetZoom = function () {
168
- // Triggers a "zoomed" event ---
169
- this._zoom.transform(this.element(), common.zoomIdentity.translate(0, this.isHorizontal() ? 0 : this.height()));
170
- };
171
- MiniGantt.prototype.zoomed = function () {
172
- this.transform = common.d3Event().transform;
173
- this.render();
174
- };
175
- MiniGantt.prototype.enter = function (domNode, element) {
176
- var _this = this;
177
- _super.prototype.enter.call(this, domNode, element);
178
- this._zoom = common.zoom()
179
- .scaleExtent([0, this.maxZoom()])
180
- .on("zoom", function () {
181
- _this.zoomed();
182
- });
183
- this.background = element.append("rect")
184
- .attr("fill", "white")
185
- .attr("opacity", 0)
186
- .on("dblclick", function () {
187
- common.d3Event().stopPropagation();
188
- delete _this.rootExtent;
189
- _this.resetZoom();
190
- });
191
- this.gUpperContent = element.append("g").attr("class", "gUpperContent");
192
- this.gUpperAxis = element.append("g").attr("class", "gUpperAxis");
193
- this.gMiddleContent = element.append("g").attr("class", "gMiddleContent");
194
- this.gLowerAxis = element.append("g").attr("class", "gLowerAxis");
195
- this.gLowerContent = element.append("g").attr("class", "gLowerContent");
196
- this.tlAxis
197
- .target(this.gUpperAxis.node())
198
- .tickFormat(this.tickFormat())
199
- .guideTarget(this.gUpperAxis.append("g").node())
200
- .shrinkToFit("none")
201
- .overlapMode(this.tickFormat_exists() ? "stagger" : "none")
202
- .extend(0.1);
203
- this.brAxis
204
- .target(this.gLowerAxis.node())
205
- .tickFormat(this.tickFormat())
206
- .guideTarget(this.gLowerAxis.append("g").node())
207
- .shrinkToFit("none")
208
- .overlapMode(this.tickFormat_exists() ? "stagger" : "none")
209
- .extend(0.1);
210
- element.call(this._zoom);
211
- this._selection.widgetElement(this.gMiddleContent);
212
- };
213
- MiniGantt.prototype.update = function (domNode, element) {
214
- var _this = this;
215
- _super.prototype.update.call(this, domNode, element);
216
- this._dateCache = {};
217
- this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
218
- this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
219
- this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
220
- this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
221
- this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
222
- this._yoffset_idx = this.yOffsetColumn() !== null ? this.columns().indexOf(this.yOffsetColumn()) : this._yoffset_idx;
223
- if (this._prevIsHorizontal !== this.isHorizontal()) {
224
- this._prevIsHorizontal = this.isHorizontal();
225
- this.resetZoom();
226
- return;
227
- }
228
- this.tooltipFormatter = common.timeFormat(this.tooltipTimeFormat());
229
- var width = this.width();
230
- var height = this.height();
231
- this.background
232
- .attr("x", 0)
233
- .attr("y", 0)
234
- .attr("width", width)
235
- .attr("height", height);
236
- var extent = this.extent();
237
- this.tlAxis
238
- .x(width / 2)
239
- .orientation(this.isHorizontal() ? "top" : "left")
240
- .reverse(!this.isHorizontal())
241
- .timePattern(this.timePattern()) // "%Y-%m-%dT%H:%M:%S.%LZ"
242
- .width(width - 1)
243
- .low(extent[0])
244
- .high(extent[1])
245
- .updateScale();
246
- this.brAxis
247
- .x(width / 2)
248
- .y(height / 2)
249
- .orientation(this.isHorizontal() ? "bottom" : "right")
250
- .reverse(!this.isHorizontal())
251
- .timePattern(this.timePattern()) // "%Y-%m-%dT%H:%M:%S.%LZ"
252
- .width(width - 1)
253
- .height(height)
254
- .low(extent[0])
255
- .high(extent[1])
256
- .updateScale();
257
- if (this.transform) {
258
- var low = void 0;
259
- var hi = void 0;
260
- if (this.isHorizontal()) {
261
- low = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(0)));
262
- hi = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(width - 1)));
263
- }
264
- else {
265
- low = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(0)));
266
- hi = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(height - 1)));
267
- }
268
- this.tlAxis
269
- .low(low)
270
- .high(hi)
271
- .updateScale();
272
- this.brAxis
273
- .low(low)
274
- .high(hi)
275
- .updateScale();
276
- }
277
- var data = this.data().sort(this.isHorizontal() ? function (l, r) {
278
- var retVal = _this.brAxis.scalePos(l[1]) - _this.brAxis.scalePos(r[1]);
279
- if (retVal === 0) {
280
- return ("" + l[0]).localeCompare("" + r[0]);
281
- }
282
- return retVal;
283
- } : function (l, r) {
284
- return _this.brAxis.scalePos(r[1]) - _this.brAxis.scalePos(l[1]);
285
- });
286
- var events = data.filter(function (d) { return !d[_this._endDate_idx]; });
287
- var ranges = data.filter(function (d) { return !!d[_this._endDate_idx]; });
288
- this.tlAxis
289
- .render();
290
- this.brAxis
291
- .render();
292
- var brAxisBBox = this.brAxis.getBBox();
293
- var upperContentHeight = this.updateEntityPins(events);
294
- var lowerAxisHeight = brAxisBBox.height;
295
- var lowerHeight = height - upperContentHeight;
296
- var minYOffset = this._yoffset_idx !== -1 ? Math.min.apply(undefined, this.data().filter(function (row) { return !isNaN(row[_this._yoffset_idx]); }).map(function (row) { return row[_this._yoffset_idx]; })) : 0;
297
- if (events.length > 0 && ranges.length === 0) {
298
- // ONLY EVENTS
299
- this.tlAxis.visible(false);
300
- var y_offset = upperContentHeight / 4;
301
- if (y_offset > (height / 2) - lowerAxisHeight) {
302
- y_offset = (height / 2) - lowerAxisHeight;
303
- }
304
- var upperContentYOffset = (height / 2) + y_offset;
305
- var lowerAxisYOffset = ((height / 2) - lowerAxisHeight - y_offset) * -1;
306
- var halfMinYOffset = minYOffset !== 0 ? minYOffset / 2 : 0;
307
- this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentYOffset - halfMinYOffset, ")"));
308
- this.gLowerAxis.attr("transform", "translate(0, ".concat(lowerAxisYOffset - halfMinYOffset, ")"));
309
- }
310
- else if (events.length === 0 && ranges.length > 0) {
311
- // ONLY RANGES
312
- this.tlAxis.visible(true);
313
- this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
314
- this.gUpperAxis.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
315
- }
316
- else {
317
- upperContentHeight -= minYOffset;
318
- lowerHeight += minYOffset;
319
- // BOTH
320
- this.tlAxis.visible(true);
321
- this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
322
- this.gUpperAxis.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
323
- this.gMiddleContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
324
- }
325
- this.tlAxis
326
- .render();
327
- var tlAxisBBox = this.tlAxis.getBBox();
328
- var bucketData = [];
329
- var bucketIndex = {};
330
- for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) {
331
- var range = ranges_1[_i];
332
- for (var i = 0; i < bucketData.length; ++i) {
333
- var bucket = bucketData[i];
334
- if (bucket.endPos + this.overlapTolerence() <= this.dataStartPos(range)) {
335
- bucketIndex[range] = i;
336
- bucket.endPos = this.dataEndPos(range);
337
- break;
338
- }
339
- }
340
- if (bucketIndex[range] === undefined) {
341
- bucketIndex[range] = bucketData.length;
342
- bucketData.push({
343
- endPos: this.dataEndPos(range)
344
- });
345
- }
346
- }
347
- var vbLower = this.isHorizontal() ? 0 + tlAxisBBox.height : 0 + tlAxisBBox.width;
348
- var vbHigher = this.isHorizontal() ? lowerHeight - brAxisBBox.height : width - brAxisBBox.width;
349
- this.verticalBands
350
- .range([vbLower, vbHigher])
351
- .domain(bucketData.map(function (_d, i) { return i; }));
352
- if (ranges.length > 0) {
353
- this.updateEventRanges(events, ranges, bucketIndex, lowerHeight, tlAxisBBox, brAxisBBox, width);
354
- }
355
- };
356
- MiniGantt.prototype.updateEntityPins = function (events) {
357
- var event_height = 0;
358
- var context = this;
359
- var entityPins = this.gUpperContent.selectAll(".entity_pin").data(events, function (d) { return d[0] + ":" + d[1]; });
360
- var eventFontColor_idx = this.eventFontColorColumn() ? this.columns().indexOf(this.eventFontColorColumn()) : -1;
361
- var eventBorderColor_idx = this.eventBorderColorColumn() ? this.columns().indexOf(this.eventBorderColorColumn()) : -1;
362
- var eventBackgroundColor_idx = this.eventBackgroundColorColumn() ? this.columns().indexOf(this.eventBackgroundColorColumn()) : -1;
363
- var title_counts = {};
364
- for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
365
- var d = events_1[_i];
366
- var type = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : d[0];
367
- title_counts[type] = title_counts[type] ? title_counts[type] + 1 : 1;
368
- }
369
- var title_types = Object.keys(title_counts);
370
- var title_group_offset = context.eventGroupOffset();
371
- var entityPinsEnter = entityPins.enter().append("g")
372
- .attr("class", "entity_pin");
373
- entityPinsEnter.append("line")
374
- .attr("class", "entity_line");
375
- entityPinsEnter
376
- .on("mouseover", function (d) {
377
- common.select(this).raise();
378
- })
379
- .each(function (d, i) {
380
- var entityPin = new common.EntityPin()
381
- .target(this)
382
- .icon("")
383
- .iconOnlyShowOnHover(context.hideIconWhenCollapsed())
384
- .titleOnlyShowOnHover(context.hideTitleWhenCollapsed())
385
- .descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed())
386
- .annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed())
387
- .iconDiameter(18)
388
- .iconPaddingPercent(1)
389
- .titleFontSize(14)
390
- .descriptionColor("#333")
391
- .descriptionFontSize(15)
392
- .iconColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
393
- .titleColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
394
- .descriptionColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
395
- .backgroundShape("pin")
396
- .backgroundColorFill(eventFontColor_idx === -1 ? "#f8f8f8" : d[eventBackgroundColor_idx])
397
- .backgroundColorStroke(eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx])
398
- .cornerRadius(5)
399
- .arrowHeight(10)
400
- .arrowWidth(16);
401
- context.localEntityPin.set(this, entityPin);
402
- })
403
- .merge(entityPins)
404
- .each(function (d, i) {
405
- var entityPin = context.localEntityPin.get(this);
406
- var _title = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : entityPin.title();
407
- var x_offset = context.dataStartPos(d) - 0;
408
- var y_offset = ((title_types.indexOf(_title) % context.eventGroupMod()) * title_group_offset) - 5;
409
- if (typeof d[context._yoffset_idx] !== "undefined")
410
- y_offset += d[context._yoffset_idx] ? d[context._yoffset_idx] : 0;
411
- if (d[context._title_idx] !== entityPin.title() && d[context._startDate_idx] !== entityPin.description()) {
412
- var parsed_start_time = context.brAxis.parse(d[context._startDate_idx]);
413
- var formatted_start_time = context.tooltipFormatter(parsed_start_time);
414
- entityPin
415
- .x(x_offset)
416
- .y(y_offset)
417
- .iconOnlyShowOnHover(context.hideIconWhenCollapsed())
418
- .titleOnlyShowOnHover(context.hideTitleWhenCollapsed())
419
- .descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed())
420
- .annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed())
421
- .icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : entityPin.icon())
422
- .title(_title)
423
- .description(formatted_start_time)
424
- .animationFrameRender();
425
- }
426
- else {
427
- entityPin.move({ x: x_offset, y: y_offset });
428
- }
429
- var calc_height = entityPin.calcHeight();
430
- if (event_height < calc_height)
431
- event_height = calc_height;
432
- common.select(this).selectAll(".entity_line")
433
- .attr("x1", x_offset)
434
- .attr("x2", x_offset)
435
- .attr("y1", 0)
436
- .attr("y2", y_offset)
437
- .style("stroke", eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx])
438
- .style("stroke-width", 1);
439
- });
440
- entityPins.exit()
441
- .each(function (d, i) {
442
- var entityPin = context.localEntityPin.get(this);
443
- entityPin.target(null);
444
- })
445
- .remove();
446
- var event_offset = Math.abs(Math.min(events.length, context.eventGroupMod()) * context.eventGroupOffset());
447
- return event_height + event_offset;
448
- };
449
- MiniGantt.prototype.updateEventRanges = function (events, ranges, bucketIndex, eventRangeHeight, tlAxisBBox, brAxisBBox, width) {
450
- var _this = this;
451
- var context = this;
452
- var lines = this.gMiddleContent.selectAll(".line").data(events, function (d) {
453
- return d[context._title_idx];
454
- });
455
- lines.enter().append("line")
456
- .attr("class", "line")
457
- .merge(lines)
458
- .attr(this.isHorizontal() ? "x1" : "y1", function (d) { return _this.dataStartPos(d) - 0; })
459
- .attr(this.isHorizontal() ? "x2" : "y2", function (d) { return _this.dataStartPos(d) - 0; })
460
- .attr(this.isHorizontal() ? "y1" : "x1", this.isHorizontal() ? tlAxisBBox.height : tlAxisBBox.width)
461
- .attr(this.isHorizontal() ? "y2" : "x2", this.isHorizontal() ? eventRangeHeight - brAxisBBox.height : width - brAxisBBox.width);
462
- lines.exit().remove();
463
- var buckets = this.gMiddleContent.selectAll(".buckets").data(ranges, function (d) { return d[context._title_idx]; });
464
- buckets.enter().append("g")
465
- .attr("class", "buckets")
466
- .call(this._selection.enter.bind(this._selection))
467
- .each(function (d) {
468
- var entityRect = new common.EntityRect()
469
- .target(this)
470
- .iconDiameter(28)
471
- .iconPaddingPercent(0)
472
- .titleFontSize(28)
473
- .titleColor(context.rangeFontColor())
474
- .descriptionColor(context.rangeFontColor())
475
- .iconColor(context.rangeFontColor())
476
- .backgroundShape("rect")
477
- .backgroundColorFill(d[context._color_idx]);
478
- context.localRect.set(this, entityRect);
479
- context.enterEntityRect(entityRect, d);
480
- })
481
- .on("click", function (d) {
482
- context.click(context.rowToObj(d), "range", context._selection.selected(this));
483
- }, false)
484
- .on("dblclick", function (d) {
485
- context.rootExtent = d;
486
- context.resetZoom();
487
- context.dblclick(context.rowToObj(d), "range", context._selection.selected(this));
488
- }, true)
489
- .on("mouseout.tooltip", this.tooltip.hide)
490
- .on("mousemove.tooltip", this.tooltip.show)
491
- .merge(buckets)
492
- .attr("transform", function (d) { return context.isHorizontal() ?
493
- "translate(".concat(_this.dataStartPos(d), ", ").concat(_this.verticalBands(bucketIndex[d]), ") ") :
494
- "translate(".concat(_this.verticalBands(bucketIndex[d]), ", ").concat(_this.dataStartPos(d), ") "); })
495
- .each(function (d) {
496
- var textBox = context.localRect.get(this);
497
- var x = context.dataWidth(d) / 2;
498
- var y = context.verticalBands.bandwidth() / 2;
499
- var rectWidth = Math.max(context.dataWidth(d), 2);
500
- var rectHeight = Math.max(context.verticalBands.bandwidth(), 2);
501
- var fontHeightRatio = 0.618;
502
- var paddingRatio = ((1 - fontHeightRatio) / 2);
503
- var paddingSize = paddingRatio * rectHeight;
504
- var fontSize = rectHeight * fontHeightRatio;
505
- var iconSize = fontSize;
506
- textBox
507
- .pos(context.isHorizontal() ? { x: x, y: y } : { x: y, y: x })
508
- .fixedHeight(context.isHorizontal() ? rectHeight : rectWidth)
509
- .fixedWidth(context.isHorizontal() ? rectWidth : rectHeight)
510
- .icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : "")
511
- .title(typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : "")
512
- .padding(paddingSize)
513
- .iconDiameter(iconSize)
514
- .titleFontSize(fontSize);
515
- if (iconSize * 1.5 > rectWidth) {
516
- textBox.icon(null);
517
- }
518
- context.updateEntityRect(textBox, d[context._icon_idx]);
519
- textBox
520
- .render();
521
- });
522
- buckets.exit().remove();
523
- };
524
- MiniGantt.prototype.exit = function (domNode, element) {
525
- this.brAxis.target(null);
526
- this.tlAxis.target(null);
527
- _super.prototype.exit.call(this, domNode, element);
528
- };
529
- // Events ---
530
- MiniGantt.prototype.click = function (row, col, sel) {
531
- };
532
- MiniGantt.prototype.dblclick = function (row, col, sel) {
533
- };
534
- MiniGantt.prototype.enterEntityRect = function (textbox, d) {
535
- };
536
- MiniGantt.prototype.updateEntityRect = function (textbox, d) {
537
- };
538
- return MiniGantt;
539
- }(common.SVGWidget));
540
- MiniGantt.prototype._class += " timeline_MiniGantt";
541
- MiniGantt.prototype.implements(api.ITooltip.prototype);
542
- MiniGantt.prototype.mixin(common.Utility.SimpleSelectionMixin);
543
- MiniGantt.prototype.publish("timePattern", "%Y-%m-%d", "string", "timePattern");
544
- MiniGantt.prototype.publish("tickFormat", null, "string", "tickFormat", undefined, { optional: true });
545
- MiniGantt.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "tooltipTimeFormat");
546
- MiniGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
547
- MiniGantt.prototype.publish("orientation", "horizontal", "set", "orientation", ["horizontal", "vertical"]);
548
- MiniGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
549
- MiniGantt.prototype.publish("titleColumn", null, "string", "titleColumn");
550
- MiniGantt.prototype.publish("startDateColumn", null, "string", "startDateColumn");
551
- MiniGantt.prototype.publish("endDateColumn", null, "string", "endDateColumn");
552
- MiniGantt.prototype.publish("iconColumn", null, "string", "iconColumn");
553
- MiniGantt.prototype.publish("colorColumn", null, "string", "colorColumn");
554
- MiniGantt.prototype.publish("yOffsetColumn", null, "string", "yOffsetColumn");
555
- MiniGantt.prototype.publish("maxZoom", 16, "number", "maxZoom");
556
- MiniGantt.prototype.publish("eventGroupOffset", -50, "number", "eventGroupOffset");
557
- MiniGantt.prototype.publish("eventGroupMod", 5, "number", "eventGroupMod");
558
- MiniGantt.prototype.publish("eventFontColorColumn", null, "string", "eventFontColorColumn");
559
- MiniGantt.prototype.publish("eventBorderColorColumn", null, "string", "eventBorderColorColumn");
560
- MiniGantt.prototype.publish("eventBackgroundColorColumn", null, "string", "eventBackgroundColorColumn");
561
- MiniGantt.prototype.publish("hideIconWhenCollapsed", false, "boolean", "hideIconWhenCollapsed");
562
- MiniGantt.prototype.publish("hideTitleWhenCollapsed", false, "boolean", "hideTitleWhenCollapsed");
563
- MiniGantt.prototype.publish("hideDescriptionWhenCollapsed", false, "boolean", "hideDescriptionWhenCollapsed");
564
- MiniGantt.prototype.publish("hideAnnotationsWhenCollapsed", true, "boolean", "hideAnnotationsWhenCollapsed");
565
- MiniGantt.prototype.publish("centerOnMostRecent", false, "boolean", "If true, the timeline will be centered on the most recent data point");
98
+ var MiniGantt = /** @class */ (function (_super) {
99
+ __extends(MiniGantt, _super);
100
+ function MiniGantt() {
101
+ var _this = _super.call(this) || this;
102
+ _this.localRect = common.local();
103
+ _this.localEntityPin = common.local();
104
+ _this._title_idx = 0;
105
+ _this._startDate_idx = 1;
106
+ _this._endDate_idx = 2;
107
+ _this._icon_idx = -1;
108
+ _this._color_idx = -1;
109
+ _this._yoffset_idx = -1;
110
+ api.ITooltip.call(_this);
111
+ common.Utility.SimpleSelectionMixin.call(_this);
112
+ _this._drawStartPos = "origin";
113
+ _this.tooltipHTML(function (d) { return "<center>".concat(d[_this._title_idx], "</center><br>").concat(_this.tooltipFormatter(_this.brAxis.parse(d[_this._startDate_idx])), " -> ").concat(_this.tooltipFormatter(_this.brAxis.parse(d[_this._endDate_idx]))); });
114
+ _this.tlAxis = new chart.Axis()
115
+ .type("time");
116
+ _this.brAxis = new chart.Axis()
117
+ .type("time");
118
+ _this.verticalBands = common.scaleBand()
119
+ .paddingOuter(0.2)
120
+ .paddingInner(0.2);
121
+ return _this;
122
+ }
123
+ MiniGantt.prototype.isHorizontal = function () {
124
+ return this.orientation() === "horizontal";
125
+ };
126
+ MiniGantt.prototype.fullExtent = function () {
127
+ var _this = this;
128
+ var data = __spreadArray(__spreadArray([], this.data().map(function (d) { return d[_this._startDate_idx]; }), true), this.data().filter(function (d) { return !!d[_this._endDate_idx]; }).map(function (d) { return d[_this._endDate_idx]; }), true);
129
+ return common.extent(data);
130
+ };
131
+ MiniGantt.prototype.extent = function () {
132
+ var extent = this.rootExtent ? [this.rootExtent[1], this.rootExtent[2]] : this.fullExtent();
133
+ if (extent[0] !== undefined && extent[1] !== undefined) {
134
+ if (extent[0] === extent[1] || this.centerOnMostRecent()) {
135
+ var parser = common.timeParse(this.timePattern());
136
+ var formatter = common.timeFormat(this.timePattern());
137
+ var date1 = parser(extent[0]);
138
+ var date2 = parser(extent[1]);
139
+ if (extent[0] === extent[1]) {
140
+ extent[0] = formatter(new Date(date1.setFullYear(date1.getFullYear() - 1)));
141
+ extent[1] = formatter(new Date(date1.setFullYear(date1.getFullYear() + 2)));
142
+ }
143
+ else {
144
+ var time1 = date1.getTime();
145
+ var timeDiff = date2.getTime() - time1;
146
+ extent[0] = formatter(date1);
147
+ extent[1] = formatter(new Date(time1 + (timeDiff * 2)));
148
+ }
149
+ }
150
+ }
151
+ return extent;
152
+ };
153
+ MiniGantt.prototype.dataStartPos = function (d) {
154
+ if (typeof this._dateCache[d[this._startDate_idx]] !== "undefined") {
155
+ return this._dateCache[d[this._startDate_idx]];
156
+ }
157
+ var pos = this.brAxis.scalePos(d[this._startDate_idx]);
158
+ this._dateCache[d[this._startDate_idx]] = pos;
159
+ return pos;
160
+ };
161
+ MiniGantt.prototype.dataEndPos = function (d) {
162
+ if (typeof this._dateCache[d[this._endDate_idx]] !== "undefined") {
163
+ return this._dateCache[d[this._endDate_idx]];
164
+ }
165
+ var pos = this.brAxis.scalePos(d[this._endDate_idx]);
166
+ this._dateCache[d[this._endDate_idx]] = pos;
167
+ return pos;
168
+ };
169
+ MiniGantt.prototype.dataWidth = function (d) {
170
+ return this.dataEndPos(d) - this.dataStartPos(d);
171
+ };
172
+ MiniGantt.prototype.resetZoom = function () {
173
+ // Triggers a "zoomed" event ---
174
+ this._zoom.transform(this.element(), common.zoomIdentity.translate(0, this.isHorizontal() ? 0 : this.height()));
175
+ };
176
+ MiniGantt.prototype.zoomed = function () {
177
+ this.transform = common.d3Event().transform;
178
+ this.render();
179
+ };
180
+ MiniGantt.prototype.enter = function (domNode, element) {
181
+ var _this = this;
182
+ _super.prototype.enter.call(this, domNode, element);
183
+ this._zoom = common.zoom()
184
+ .scaleExtent([0, this.maxZoom()])
185
+ .on("zoom", function () {
186
+ _this.zoomed();
187
+ });
188
+ this.background = element.append("rect")
189
+ .attr("fill", "white")
190
+ .attr("opacity", 0)
191
+ .on("dblclick", function () {
192
+ common.d3Event().stopPropagation();
193
+ delete _this.rootExtent;
194
+ _this.resetZoom();
195
+ });
196
+ this.gUpperContent = element.append("g").attr("class", "gUpperContent");
197
+ this.gUpperAxis = element.append("g").attr("class", "gUpperAxis");
198
+ this.gMiddleContent = element.append("g").attr("class", "gMiddleContent");
199
+ this.gLowerAxis = element.append("g").attr("class", "gLowerAxis");
200
+ this.gLowerContent = element.append("g").attr("class", "gLowerContent");
201
+ this.tlAxis
202
+ .target(this.gUpperAxis.node())
203
+ .tickFormat(this.tickFormat())
204
+ .guideTarget(this.gUpperAxis.append("g").node())
205
+ .shrinkToFit("none")
206
+ .overlapMode(this.tickFormat_exists() ? "stagger" : "none")
207
+ .extend(0.1);
208
+ this.brAxis
209
+ .target(this.gLowerAxis.node())
210
+ .tickFormat(this.tickFormat())
211
+ .guideTarget(this.gLowerAxis.append("g").node())
212
+ .shrinkToFit("none")
213
+ .overlapMode(this.tickFormat_exists() ? "stagger" : "none")
214
+ .extend(0.1);
215
+ element.call(this._zoom);
216
+ this._selection.widgetElement(this.gMiddleContent);
217
+ };
218
+ MiniGantt.prototype.update = function (domNode, element) {
219
+ var _this = this;
220
+ _super.prototype.update.call(this, domNode, element);
221
+ this._dateCache = {};
222
+ this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
223
+ this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
224
+ this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
225
+ this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
226
+ this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
227
+ this._yoffset_idx = this.yOffsetColumn() !== null ? this.columns().indexOf(this.yOffsetColumn()) : this._yoffset_idx;
228
+ if (this._prevIsHorizontal !== this.isHorizontal()) {
229
+ this._prevIsHorizontal = this.isHorizontal();
230
+ this.resetZoom();
231
+ return;
232
+ }
233
+ this.tooltipFormatter = common.timeFormat(this.tooltipTimeFormat());
234
+ var width = this.width();
235
+ var height = this.height();
236
+ this.background
237
+ .attr("x", 0)
238
+ .attr("y", 0)
239
+ .attr("width", width)
240
+ .attr("height", height);
241
+ var extent = this.extent();
242
+ this.tlAxis
243
+ .x(width / 2)
244
+ .orientation(this.isHorizontal() ? "top" : "left")
245
+ .reverse(!this.isHorizontal())
246
+ .timePattern(this.timePattern()) // "%Y-%m-%dT%H:%M:%S.%LZ"
247
+ .width(width - 1)
248
+ .low(extent[0])
249
+ .high(extent[1])
250
+ .updateScale();
251
+ this.brAxis
252
+ .x(width / 2)
253
+ .y(height / 2)
254
+ .orientation(this.isHorizontal() ? "bottom" : "right")
255
+ .reverse(!this.isHorizontal())
256
+ .timePattern(this.timePattern()) // "%Y-%m-%dT%H:%M:%S.%LZ"
257
+ .width(width - 1)
258
+ .height(height)
259
+ .low(extent[0])
260
+ .high(extent[1])
261
+ .updateScale();
262
+ if (this.transform) {
263
+ var low = void 0;
264
+ var hi = void 0;
265
+ if (this.isHorizontal()) {
266
+ low = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(0)));
267
+ hi = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(width - 1)));
268
+ }
269
+ else {
270
+ low = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(0)));
271
+ hi = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(height - 1)));
272
+ }
273
+ this.tlAxis
274
+ .low(low)
275
+ .high(hi)
276
+ .updateScale();
277
+ this.brAxis
278
+ .low(low)
279
+ .high(hi)
280
+ .updateScale();
281
+ }
282
+ var data = this.data().sort(this.isHorizontal() ? function (l, r) {
283
+ var retVal = _this.brAxis.scalePos(l[1]) - _this.brAxis.scalePos(r[1]);
284
+ if (retVal === 0) {
285
+ return ("" + l[0]).localeCompare("" + r[0]);
286
+ }
287
+ return retVal;
288
+ } : function (l, r) {
289
+ return _this.brAxis.scalePos(r[1]) - _this.brAxis.scalePos(l[1]);
290
+ });
291
+ var events = data.filter(function (d) { return !d[_this._endDate_idx]; });
292
+ var ranges = data.filter(function (d) { return !!d[_this._endDate_idx]; });
293
+ this.tlAxis
294
+ .render();
295
+ this.brAxis
296
+ .render();
297
+ var brAxisBBox = this.brAxis.getBBox();
298
+ var upperContentHeight = this.updateEntityPins(events);
299
+ var lowerAxisHeight = brAxisBBox.height;
300
+ var lowerHeight = height - upperContentHeight;
301
+ var minYOffset = this._yoffset_idx !== -1 ? Math.min.apply(undefined, this.data().filter(function (row) { return !isNaN(row[_this._yoffset_idx]); }).map(function (row) { return row[_this._yoffset_idx]; })) : 0;
302
+ if (events.length > 0 && ranges.length === 0) {
303
+ // ONLY EVENTS
304
+ this.tlAxis.visible(false);
305
+ var y_offset = upperContentHeight / 4;
306
+ if (y_offset > (height / 2) - lowerAxisHeight) {
307
+ y_offset = (height / 2) - lowerAxisHeight;
308
+ }
309
+ var upperContentYOffset = (height / 2) + y_offset;
310
+ var lowerAxisYOffset = ((height / 2) - lowerAxisHeight - y_offset) * -1;
311
+ var halfMinYOffset = minYOffset !== 0 ? minYOffset / 2 : 0;
312
+ this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentYOffset - halfMinYOffset, ")"));
313
+ this.gLowerAxis.attr("transform", "translate(0, ".concat(lowerAxisYOffset - halfMinYOffset, ")"));
314
+ }
315
+ else if (events.length === 0 && ranges.length > 0) {
316
+ // ONLY RANGES
317
+ this.tlAxis.visible(true);
318
+ this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
319
+ this.gUpperAxis.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
320
+ }
321
+ else {
322
+ upperContentHeight -= minYOffset;
323
+ lowerHeight += minYOffset;
324
+ // BOTH
325
+ this.tlAxis.visible(true);
326
+ this.gUpperContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
327
+ this.gUpperAxis.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
328
+ this.gMiddleContent.attr("transform", "translate(0, ".concat(upperContentHeight, ")"));
329
+ }
330
+ this.tlAxis
331
+ .render();
332
+ var tlAxisBBox = this.tlAxis.getBBox();
333
+ var bucketData = [];
334
+ var bucketIndex = {};
335
+ for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) {
336
+ var range = ranges_1[_i];
337
+ for (var i = 0; i < bucketData.length; ++i) {
338
+ var bucket = bucketData[i];
339
+ if (bucket.endPos + this.overlapTolerence() <= this.dataStartPos(range)) {
340
+ bucketIndex[range] = i;
341
+ bucket.endPos = this.dataEndPos(range);
342
+ break;
343
+ }
344
+ }
345
+ if (bucketIndex[range] === undefined) {
346
+ bucketIndex[range] = bucketData.length;
347
+ bucketData.push({
348
+ endPos: this.dataEndPos(range)
349
+ });
350
+ }
351
+ }
352
+ var vbLower = this.isHorizontal() ? 0 + tlAxisBBox.height : 0 + tlAxisBBox.width;
353
+ var vbHigher = this.isHorizontal() ? lowerHeight - brAxisBBox.height : width - brAxisBBox.width;
354
+ this.verticalBands
355
+ .range([vbLower, vbHigher])
356
+ .domain(bucketData.map(function (_d, i) { return i; }));
357
+ if (ranges.length > 0) {
358
+ this.updateEventRanges(events, ranges, bucketIndex, lowerHeight, tlAxisBBox, brAxisBBox, width);
359
+ }
360
+ };
361
+ MiniGantt.prototype.updateEntityPins = function (events) {
362
+ var event_height = 0;
363
+ var context = this;
364
+ var entityPins = this.gUpperContent.selectAll(".entity_pin").data(events, function (d) { return d[0] + ":" + d[1]; });
365
+ var eventFontColor_idx = this.eventFontColorColumn() ? this.columns().indexOf(this.eventFontColorColumn()) : -1;
366
+ var eventBorderColor_idx = this.eventBorderColorColumn() ? this.columns().indexOf(this.eventBorderColorColumn()) : -1;
367
+ var eventBackgroundColor_idx = this.eventBackgroundColorColumn() ? this.columns().indexOf(this.eventBackgroundColorColumn()) : -1;
368
+ var title_counts = {};
369
+ for (var _i = 0, events_1 = events; _i < events_1.length; _i++) {
370
+ var d = events_1[_i];
371
+ var type = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : d[0];
372
+ title_counts[type] = title_counts[type] ? title_counts[type] + 1 : 1;
373
+ }
374
+ var title_types = Object.keys(title_counts);
375
+ var title_group_offset = context.eventGroupOffset();
376
+ var entityPinsEnter = entityPins.enter().append("g")
377
+ .attr("class", "entity_pin");
378
+ entityPinsEnter.append("line")
379
+ .attr("class", "entity_line");
380
+ entityPinsEnter
381
+ .on("mouseover", function (d) {
382
+ common.select(this).raise();
383
+ })
384
+ .each(function (d, i) {
385
+ var entityPin = new common.EntityPin()
386
+ .target(this)
387
+ .icon("")
388
+ .iconOnlyShowOnHover(context.hideIconWhenCollapsed())
389
+ .titleOnlyShowOnHover(context.hideTitleWhenCollapsed())
390
+ .descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed())
391
+ .annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed())
392
+ .iconDiameter(18)
393
+ .iconPaddingPercent(1)
394
+ .titleFontSize(14)
395
+ .descriptionColor("#333")
396
+ .descriptionFontSize(15)
397
+ .iconColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
398
+ .titleColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
399
+ .descriptionColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx])
400
+ .backgroundShape("pin")
401
+ .backgroundColorFill(eventFontColor_idx === -1 ? "#f8f8f8" : d[eventBackgroundColor_idx])
402
+ .backgroundColorStroke(eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx])
403
+ .cornerRadius(5)
404
+ .arrowHeight(10)
405
+ .arrowWidth(16);
406
+ context.localEntityPin.set(this, entityPin);
407
+ })
408
+ .merge(entityPins)
409
+ .each(function (d, i) {
410
+ var entityPin = context.localEntityPin.get(this);
411
+ var _title = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : entityPin.title();
412
+ var x_offset = context.dataStartPos(d) - 0;
413
+ var y_offset = ((title_types.indexOf(_title) % context.eventGroupMod()) * title_group_offset) - 5;
414
+ if (typeof d[context._yoffset_idx] !== "undefined")
415
+ y_offset += d[context._yoffset_idx] ? d[context._yoffset_idx] : 0;
416
+ if (d[context._title_idx] !== entityPin.title() && d[context._startDate_idx] !== entityPin.description()) {
417
+ var parsed_start_time = context.brAxis.parse(d[context._startDate_idx]);
418
+ var formatted_start_time = context.tooltipFormatter(parsed_start_time);
419
+ entityPin
420
+ .x(x_offset)
421
+ .y(y_offset)
422
+ .iconOnlyShowOnHover(context.hideIconWhenCollapsed())
423
+ .titleOnlyShowOnHover(context.hideTitleWhenCollapsed())
424
+ .descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed())
425
+ .annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed())
426
+ .icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : entityPin.icon())
427
+ .title(_title)
428
+ .description(formatted_start_time)
429
+ .animationFrameRender();
430
+ }
431
+ else {
432
+ entityPin.move({ x: x_offset, y: y_offset });
433
+ }
434
+ var calc_height = entityPin.calcHeight();
435
+ if (event_height < calc_height)
436
+ event_height = calc_height;
437
+ common.select(this).selectAll(".entity_line")
438
+ .attr("x1", x_offset)
439
+ .attr("x2", x_offset)
440
+ .attr("y1", 0)
441
+ .attr("y2", y_offset)
442
+ .style("stroke", eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx])
443
+ .style("stroke-width", 1);
444
+ });
445
+ entityPins.exit()
446
+ .each(function (d, i) {
447
+ var entityPin = context.localEntityPin.get(this);
448
+ entityPin.target(null);
449
+ })
450
+ .remove();
451
+ var event_offset = Math.abs(Math.min(events.length, context.eventGroupMod()) * context.eventGroupOffset());
452
+ return event_height + event_offset;
453
+ };
454
+ MiniGantt.prototype.updateEventRanges = function (events, ranges, bucketIndex, eventRangeHeight, tlAxisBBox, brAxisBBox, width) {
455
+ var _this = this;
456
+ var context = this;
457
+ var lines = this.gMiddleContent.selectAll(".line").data(events, function (d) {
458
+ return d[context._title_idx];
459
+ });
460
+ lines.enter().append("line")
461
+ .attr("class", "line")
462
+ .merge(lines)
463
+ .attr(this.isHorizontal() ? "x1" : "y1", function (d) { return _this.dataStartPos(d) - 0; })
464
+ .attr(this.isHorizontal() ? "x2" : "y2", function (d) { return _this.dataStartPos(d) - 0; })
465
+ .attr(this.isHorizontal() ? "y1" : "x1", this.isHorizontal() ? tlAxisBBox.height : tlAxisBBox.width)
466
+ .attr(this.isHorizontal() ? "y2" : "x2", this.isHorizontal() ? eventRangeHeight - brAxisBBox.height : width - brAxisBBox.width);
467
+ lines.exit().remove();
468
+ var buckets = this.gMiddleContent.selectAll(".buckets").data(ranges, function (d) { return d[context._title_idx]; });
469
+ buckets.enter().append("g")
470
+ .attr("class", "buckets")
471
+ .call(this._selection.enter.bind(this._selection))
472
+ .each(function (d) {
473
+ var entityRect = new common.EntityRect()
474
+ .target(this)
475
+ .iconDiameter(28)
476
+ .iconPaddingPercent(0)
477
+ .titleFontSize(28)
478
+ .titleColor(context.rangeFontColor())
479
+ .descriptionColor(context.rangeFontColor())
480
+ .iconColor(context.rangeFontColor())
481
+ .backgroundShape("rect")
482
+ .backgroundColorFill(d[context._color_idx]);
483
+ context.localRect.set(this, entityRect);
484
+ context.enterEntityRect(entityRect, d);
485
+ })
486
+ .on("click", function (d) {
487
+ context.click(context.rowToObj(d), "range", context._selection.selected(this));
488
+ }, false)
489
+ .on("dblclick", function (d) {
490
+ context.rootExtent = d;
491
+ context.resetZoom();
492
+ context.dblclick(context.rowToObj(d), "range", context._selection.selected(this));
493
+ }, true)
494
+ .on("mouseout.tooltip", this.tooltip.hide)
495
+ .on("mousemove.tooltip", this.tooltip.show)
496
+ .merge(buckets)
497
+ .attr("transform", function (d) { return context.isHorizontal() ?
498
+ "translate(".concat(_this.dataStartPos(d), ", ").concat(_this.verticalBands(bucketIndex[d]), ") ") :
499
+ "translate(".concat(_this.verticalBands(bucketIndex[d]), ", ").concat(_this.dataStartPos(d), ") "); })
500
+ .each(function (d) {
501
+ var textBox = context.localRect.get(this);
502
+ var x = context.dataWidth(d) / 2;
503
+ var y = context.verticalBands.bandwidth() / 2;
504
+ var rectWidth = Math.max(context.dataWidth(d), 2);
505
+ var rectHeight = Math.max(context.verticalBands.bandwidth(), 2);
506
+ var fontHeightRatio = 0.618;
507
+ var paddingRatio = ((1 - fontHeightRatio) / 2);
508
+ var paddingSize = paddingRatio * rectHeight;
509
+ var fontSize = rectHeight * fontHeightRatio;
510
+ var iconSize = fontSize;
511
+ textBox
512
+ .pos(context.isHorizontal() ? { x: x, y: y } : { x: y, y: x })
513
+ .fixedHeight(context.isHorizontal() ? rectHeight : rectWidth)
514
+ .fixedWidth(context.isHorizontal() ? rectWidth : rectHeight)
515
+ .icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : "")
516
+ .title(typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : "")
517
+ .padding(paddingSize)
518
+ .iconDiameter(iconSize)
519
+ .titleFontSize(fontSize);
520
+ if (iconSize * 1.5 > rectWidth) {
521
+ textBox.icon(null);
522
+ }
523
+ context.updateEntityRect(textBox, d[context._icon_idx]);
524
+ textBox
525
+ .render();
526
+ });
527
+ buckets.exit().remove();
528
+ };
529
+ MiniGantt.prototype.exit = function (domNode, element) {
530
+ this.brAxis.target(null);
531
+ this.tlAxis.target(null);
532
+ _super.prototype.exit.call(this, domNode, element);
533
+ };
534
+ // Events ---
535
+ MiniGantt.prototype.click = function (row, col, sel) {
536
+ };
537
+ MiniGantt.prototype.dblclick = function (row, col, sel) {
538
+ };
539
+ MiniGantt.prototype.enterEntityRect = function (textbox, d) {
540
+ };
541
+ MiniGantt.prototype.updateEntityRect = function (textbox, d) {
542
+ };
543
+ return MiniGantt;
544
+ }(common.SVGWidget));
545
+ MiniGantt.prototype._class += " timeline_MiniGantt";
546
+ MiniGantt.prototype.implements(api.ITooltip.prototype);
547
+ MiniGantt.prototype.mixin(common.Utility.SimpleSelectionMixin);
548
+ MiniGantt.prototype.publish("timePattern", "%Y-%m-%d", "string", "timePattern");
549
+ MiniGantt.prototype.publish("tickFormat", null, "string", "tickFormat", undefined, { optional: true });
550
+ MiniGantt.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "tooltipTimeFormat");
551
+ MiniGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
552
+ MiniGantt.prototype.publish("orientation", "horizontal", "set", "orientation", ["horizontal", "vertical"]);
553
+ MiniGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
554
+ MiniGantt.prototype.publish("titleColumn", null, "string", "titleColumn");
555
+ MiniGantt.prototype.publish("startDateColumn", null, "string", "startDateColumn");
556
+ MiniGantt.prototype.publish("endDateColumn", null, "string", "endDateColumn");
557
+ MiniGantt.prototype.publish("iconColumn", null, "string", "iconColumn");
558
+ MiniGantt.prototype.publish("colorColumn", null, "string", "colorColumn");
559
+ MiniGantt.prototype.publish("yOffsetColumn", null, "string", "yOffsetColumn");
560
+ MiniGantt.prototype.publish("maxZoom", 16, "number", "maxZoom");
561
+ MiniGantt.prototype.publish("eventGroupOffset", -50, "number", "eventGroupOffset");
562
+ MiniGantt.prototype.publish("eventGroupMod", 5, "number", "eventGroupMod");
563
+ MiniGantt.prototype.publish("eventFontColorColumn", null, "string", "eventFontColorColumn");
564
+ MiniGantt.prototype.publish("eventBorderColorColumn", null, "string", "eventBorderColorColumn");
565
+ MiniGantt.prototype.publish("eventBackgroundColorColumn", null, "string", "eventBackgroundColorColumn");
566
+ MiniGantt.prototype.publish("hideIconWhenCollapsed", false, "boolean", "hideIconWhenCollapsed");
567
+ MiniGantt.prototype.publish("hideTitleWhenCollapsed", false, "boolean", "hideTitleWhenCollapsed");
568
+ MiniGantt.prototype.publish("hideDescriptionWhenCollapsed", false, "boolean", "hideDescriptionWhenCollapsed");
569
+ MiniGantt.prototype.publish("hideAnnotationsWhenCollapsed", true, "boolean", "hideAnnotationsWhenCollapsed");
570
+ MiniGantt.prototype.publish("centerOnMostRecent", false, "boolean", "If true, the timeline will be centered on the most recent data point");
566
571
 
567
- var ReactGantt = /** @class */ (function (_super) {
568
- __extends(ReactGantt, _super);
569
- function ReactGantt(drawStartPosition) {
570
- if (drawStartPosition === void 0) { drawStartPosition = "origin"; }
571
- var _this = _super.call(this) || this;
572
- _this._selection = new common.Utility.Selection(_this);
573
- _this._title_idx = 0;
574
- _this._startDate_idx = 1;
575
- _this._endDate_idx = 2;
576
- _this._icon_idx = -1;
577
- _this._color_idx = -1;
578
- _this._series_idx = -1;
579
- _this._bucket_idx = -1;
580
- _this._yoffset_idx = -1;
581
- _this._rangeOptions = {
582
- rangePadding: 2,
583
- fontFamily: "Verdana",
584
- fontSize: 12,
585
- fill: "white",
586
- stroke: "black",
587
- textFill: "black",
588
- cornerRadius: 3,
589
- strokeWidth: 0
590
- };
591
- _this._rangeRenderer = react.LabelledRect;
592
- _this._transform = { k: 1, x: 0, y: 0 };
593
- _this._drawStartPos = drawStartPosition;
594
- _this.showToolbar_default(false);
595
- _this._tooltip = new html.HTMLTooltip();
596
- _this._tooltip
597
- .tooltipHTML(function (d) {
598
- return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(d[1], " -&gt; ").concat(d[2], "</div>");
599
- });
600
- _this._tooltip
601
- .followCursor(true);
602
- return _this;
603
- }
604
- ReactGantt.prototype.rangeRenderer = function (_) {
605
- if (!arguments.length)
606
- return this._rangeRenderer;
607
- this._rangeRenderer = _;
608
- return this._rangeRenderer;
609
- };
610
- ReactGantt.prototype.enter = function (domNode, element) {
611
- _super.prototype.enter.call(this, domNode, element);
612
- var context = this;
613
- element
614
- .on("click", function (d) {
615
- context._selection.clear();
616
- });
617
- this._tooltip.target(domNode);
618
- };
619
- ReactGantt.prototype.update = function (domNode, element) {
620
- var _this = this;
621
- _super.prototype.update.call(this, domNode, element);
622
- this.zoomExtent([0.05, this.maxZoom()]);
623
- this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
624
- this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
625
- this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
626
- this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
627
- this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
628
- this._series_idx = this.seriesColumn() !== null ? this.columns().indexOf(this.seriesColumn()) : this._series_idx;
629
- this._bucket_idx = this.bucketColumn() !== null ? this.columns().indexOf(this.bucketColumn()) : -1;
630
- var context = this;
631
- var w = this.width();
632
- var x0 = 0;
633
- var x1 = w;
634
- this._interpolateX = common.scaleLinear()
635
- .domain([this._minStart, this._maxEnd])
636
- .range([x0, x1]);
637
- this.data().sort(function (a, b) { return a[1] - b[1]; });
638
- if (this._series_idx > -1) {
639
- this._origIdxMap = {};
640
- this._dataBySeries = {};
641
- this._bucketsBySeries = {};
642
- this.data().forEach(function (dataRow, origIdx) {
643
- var seriesKey = dataRow[_this._series_idx];
644
- if (!_this._dataBySeries[seriesKey]) {
645
- _this._origIdxMap[seriesKey] = {};
646
- _this._dataBySeries[seriesKey] = [];
647
- }
648
- _this._dataBySeries[seriesKey].push({
649
- dataRow: dataRow,
650
- origIdx: origIdx
651
- });
652
- });
653
- var gutter_1 = this.gutter();
654
- var bucketOffset_1 = 0;
655
- var seriesKeys = Object.keys(this._dataBySeries);
656
- seriesKeys.forEach(function (seriesKey) {
657
- _this._dataBySeries[seriesKey].sort(function (a, b) { return a.dataRow[1] - b.dataRow[1]; });
658
- _this._bucketsBySeries[seriesKey] = _this.calcBuckets(_this._dataBySeries[seriesKey].map(function (n) { return n.dataRow; }), 1, 2);
659
- _this._bucketsBySeries[seriesKey].bucketHeight = _this.bucketHeight();
660
- _this._bucketsBySeries[seriesKey].bucketOffset = bucketOffset_1;
661
- bucketOffset_1 += (_this._bucketsBySeries[seriesKey].bucketHeight + _this.strokeWidth() + _this.gutter()) * (_this._bucketsBySeries[seriesKey].maxBucket + 1);
662
- _this._dataBySeries[seriesKey].forEach(function (n, i) {
663
- _this._origIdxMap[seriesKey][n.origIdx] = i;
664
- });
665
- });
666
- this._seriesBackgrounds = this._renderElement.selectAll(".series-background")
667
- .data(seriesKeys.map(function (key) {
668
- return _this._bucketsBySeries[key];
669
- }));
670
- this._seriesBackgrounds
671
- .join(function (enter) { return enter.append("rect")
672
- .attr("class", "series-background"); }, function (update) { return update; }, function (exit) { return exit
673
- .each(function (d) {
674
- delete d.element;
675
- })
676
- .remove(); })
677
- .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
678
- .each(function (d, i) {
679
- common.select(this)
680
- .attr("x", 0)
681
- .attr("y", d.bucketOffset - (gutter_1 / 2))
682
- .attr("width", w)
683
- .attr("height", ((d.bucketHeight + gutter_1) * (d.maxBucket + 1)) + gutter_1)
684
- .attr("fill", i % 2 ? context.oddSeriesBackground() : context.evenSeriesBackground());
685
- });
686
- }
687
- else {
688
- if (this._bucket_idx !== -1) {
689
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx, this._bucket_idx);
690
- }
691
- else {
692
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx);
693
- }
694
- }
695
- var interpedStart = this._interpolateX(this._minStart);
696
- this.zoomTo([interpedStart, 0], 1);
697
- var bucketHeight = this.bucketHeight();
698
- this.setRangeOptions();
699
- this._maxFontScale = (bucketHeight - (this.rangePadding() * 2));
700
- this.measureDataText();
701
- var itemSelection = this._renderElement.selectAll(".item")
702
- .data(this.data());
703
- var borderOffset1 = this.strokeWidth();
704
- var borderOffset2 = borderOffset1 * 2;
705
- itemSelection
706
- .join(function (enter) { return enter.append("g")
707
- .attr("class", "item")
708
- .on("click.selectionBag", function (d, i) {
709
- var _id = d.id === undefined ? i : d.id;
710
- if (context._selection.isSelected({ _id: _id, element: d.element })) {
711
- context._selection.clear();
712
- }
713
- else {
714
- context._selection.click({
715
- _id: _id,
716
- element: function () { return d.element; }
717
- }, common.d3Event);
718
- }
719
- context.selectionChanged();
720
- common.d3Event().stopPropagation();
721
- })
722
- .on("click", function (d) {
723
- var selected = d.element.classed("selected");
724
- if (d[context.columns().length]) {
725
- d.__lparam = d[context.columns().length];
726
- }
727
- context.click(d, "", selected);
728
- })
729
- .on("dblclick", function (d) {
730
- var selected = d.element.classed("selected");
731
- if (d[context.columns().length]) {
732
- d.__lparam = d[context.columns().length];
733
- }
734
- context.click(d, "", selected);
735
- })
736
- .on("mousein", function (d) {
737
- context.highlightItem(common.select(this), d);
738
- var selected = d.element.classed("selected");
739
- context.mousein(d, "", selected);
740
- })
741
- .on("mouseover", function (d) {
742
- var d3evt = common.d3Event();
743
- context._tooltip._triggerElement = d.element;
744
- context._tooltip._cursorLoc = [
745
- d3evt.clientX,
746
- d3evt.clientY
747
- ];
748
- context._tooltip
749
- .data(d)
750
- .visible(true)
751
- .fitContent(true)
752
- .render();
753
- context.highlightItem(common.select(this), d);
754
- var selected = d.element.classed("selected");
755
- context.mouseover(d, "", selected);
756
- })
757
- .on("mouseout", function (d) {
758
- context._tooltip
759
- .visible(false)
760
- .render();
761
- context.highlightItem(null, null);
762
- var selected = d.element.classed("selected");
763
- context.mouseout(d, "", selected);
764
- })
765
- .each(function (d, i) {
766
- d.that = this;
767
- d.element = common.select(this);
768
- d.x = context._interpolateX(d[1]);
769
- var endX = context._interpolateX(d[2]);
770
- if (context._series_idx > -1) {
771
- var seriesKey = d[context._series_idx];
772
- var bucket = context._bucketsBySeries[seriesKey].bucketMap[context._origIdxMap[seriesKey][i]];
773
- d.y = context._bucketsBySeries[seriesKey].interpolateY(bucket) + context._bucketsBySeries[seriesKey].bucketOffset;
774
- }
775
- else {
776
- var _i = context._bucket_idx === -1 ? i : d[context._bucket_idx];
777
- d.y = context._buckets.interpolateY(context._buckets.bucketMap[_i]);
778
- }
779
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
780
- d.props.width = endX - d.x;
781
- d.props.height = bucketHeight;
782
- d.x += borderOffset1;
783
- d.y += borderOffset1;
784
- d.props.width -= borderOffset2;
785
- d.props.height -= borderOffset2;
786
- d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
787
- }); }, function (update) { return update; }, function (exit) { return exit
788
- .each(function (d) {
789
- delete d.element;
790
- })
791
- .remove(); })
792
- .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
793
- .each(function (d, i) {
794
- d.that = this;
795
- if (context._series_idx > -1) {
796
- var seriesKey = d[context._series_idx];
797
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions, seriesKey);
798
- }
799
- else {
800
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions);
801
- }
802
- })
803
- .on("dblclick.zoom", function (d) {
804
- var x1 = _this._interpolateX(d[1]);
805
- var x2 = _this._interpolateX(d[2]);
806
- var xRange = x2 - x1;
807
- var xScale = w / xRange;
808
- _this.zoomTo([
809
- -x1 * xScale,
810
- 0
811
- ], xScale);
812
- });
813
- element.on("dblclick.zoom", null);
814
- };
815
- ReactGantt.prototype.renderRangeElement = function (d, i, transformEach, options, seriesKey) {
816
- if (transformEach === void 0) { transformEach = false; }
817
- if (options === void 0) { options = {}; }
818
- var borderOffset1 = options.strokeWidth;
819
- var borderOffset2 = borderOffset1 * 2;
820
- var padding = options.rangePadding;
821
- var endX;
822
- var x = isNaN(this._transform.x) ? 0 : this._transform.x;
823
- var k = isNaN(this._transform.k) ? 1 : this._transform.k;
824
- var b;
825
- var bucketHeight = this.bucketHeight();
826
- d.that.setAttribute("data-series", seriesKey);
827
- if (this._color_idx > -1) {
828
- d.that.setAttribute("data-color", d[this._color_idx]);
829
- }
830
- if (seriesKey !== undefined) {
831
- b = this._bucketsBySeries[seriesKey].bucketMap[this._origIdxMap[seriesKey][i]];
832
- d.that.setAttribute("data-b", b);
833
- d.that.setAttribute("data-bucketOffset", this._bucketsBySeries[seriesKey].bucketOffset);
834
- d.y = this._bucketsBySeries[seriesKey].interpolateY(b) + this._bucketsBySeries[seriesKey].bucketOffset;
835
- d.that.setAttribute("data-dy", d.y);
836
- }
837
- else {
838
- b = this._buckets.bucketMap[i];
839
- d.y = this._buckets.interpolateY(b);
840
- }
841
- if (this._color_idx > -1) {
842
- options.fill = d[this._color_idx];
843
- }
844
- if (!transformEach) {
845
- d.x = this._interpolateX(d[1]);
846
- endX = this._interpolateX(d[2]);
847
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
848
- d.props.width = (endX - d.x) / k;
849
- }
850
- else {
851
- d.x = this._interpolateX(d[1]) * k;
852
- endX = this._interpolateX(d[2]) * k;
853
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
854
- d.props.width = (endX - d.x) / k;
855
- d.x += x;
856
- d.props.width *= k;
857
- }
858
- d.props.height = bucketHeight;
859
- if (seriesKey === undefined && this._buckets.bucketScale < 1) {
860
- d.props.height = this._buckets.bucketScale * bucketHeight;
861
- }
862
- if (d.element === undefined && d.that) {
863
- d.element = common.select(d.that);
864
- }
865
- d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
866
- d.x += borderOffset1;
867
- d.y += borderOffset1;
868
- d.props.width -= borderOffset2;
869
- d.props.height -= borderOffset2;
870
- d.props.width = d.props.width < 1 ? 1 : d.props.width;
871
- d.props.height = d.props.height < 1 ? 1 : d.props.height;
872
- var text = this.truncateText(d.props.text, d.props.width - padding, this._maxFontScale);
873
- if (text !== d.props.text) {
874
- text = this.truncateText(d.props.text, d.props.width - padding);
875
- }
876
- else {
877
- d.props.fontSize = this._maxFontScale * options.fontSize;
878
- }
879
- if (seriesKey === undefined && this._buckets.bucketScale < 1) {
880
- d.props.fontSize = Math.min(this._maxFontScale, this._buckets.bucketScale) * options.fontSize;
881
- }
882
- if (!this._maxY || this._maxY < d.y + d.props.height) {
883
- this._maxY = d.y + d.props.height;
884
- }
885
- if (!this._maxX || this._maxX < d.x + d.props.width) {
886
- this._maxX = d.x + d.props.width;
887
- }
888
- react.render(this._rangeRenderer, __assign(__assign(__assign({}, options), d.props), { text: text }), d.that);
889
- };
890
- ReactGantt.prototype.setRangeOptions = function () {
891
- this._rangeOptions = {
892
- rangePadding: this.rangePadding(),
893
- fontFamily: this.fontFamily(),
894
- fontSize: this.fontSize(),
895
- strokeWidth: this.strokeWidth(),
896
- fill: this.fill(),
897
- stroke: this.stroke(),
898
- textFill: this.rangeFontColor(),
899
- cornerRadius: this.cornerRadius(),
900
- };
901
- };
902
- ReactGantt.prototype.zoomed = function (transform) {
903
- var _this = this;
904
- this._transform = transform;
905
- switch (this.renderMode()) {
906
- case "scale-all":
907
- this._zoomScale = transform.k;
908
- this._zoomTranslate = [transform.x, 0];
909
- this._zoomG.attr("transform", "translate(".concat(transform.x, " ").concat(0, ")scale(").concat(transform.k, " 1)"));
910
- break;
911
- default:
912
- var options_1 = this._rangeOptions;
913
- this.data().forEach(function (d, i) {
914
- if (_this._color_idx > -1) {
915
- options_1.fill = d[_this._color_idx];
916
- }
917
- if (_this._series_idx > -1) {
918
- var seriesKey = d[_this._series_idx];
919
- _this.renderRangeElement(d, i, true, options_1, seriesKey);
920
- }
921
- else {
922
- _this.renderRangeElement(d, i, true, options_1);
923
- }
924
- });
925
- }
926
- this.zoomedHook(transform);
927
- };
928
- ReactGantt.prototype.zoomedHook = function (transform) {
929
- };
930
- ReactGantt.prototype.calcBuckets = function (data, startKey, endKey, bucketKey) {
931
- var bucketMap = {};
932
- var bucketKeyMap = {};
933
- var tol = this.overlapTolerence();
934
- var buckets = [{ end: -Infinity }];
935
- var maxBucket = 0;
936
- if (bucketKey !== undefined) {
937
- data.forEach(function (d, i) {
938
- bucketMap[i] = d[bucketKey];
939
- bucketKeyMap[d[bucketKey]] = true;
940
- });
941
- maxBucket = Object.keys(bucketKeyMap).length;
942
- }
943
- else {
944
- data.forEach(function (d, i) {
945
- for (var i2 = 0; i2 < buckets.length; ++i2) {
946
- if (i === 0 || buckets[i2][endKey] + tol <= d[startKey]) {
947
- bucketMap[i] = i2;
948
- if (maxBucket < i2)
949
- maxBucket = i2;
950
- buckets[i2][endKey] = d[endKey];
951
- break;
952
- }
953
- }
954
- if (bucketMap[i] === undefined) {
955
- bucketMap[i] = buckets.length;
956
- var b = {};
957
- b[endKey] = d[endKey];
958
- buckets.push(b);
959
- }
960
- if (maxBucket < bucketMap[i])
961
- maxBucket = bucketMap[i];
962
- });
963
- }
964
- var height = (maxBucket + 1) * (this.bucketHeight() + this.gutter());
965
- return {
966
- bucketMap: bucketMap,
967
- maxBucket: maxBucket,
968
- bucketScale: this.height() / height,
969
- interpolateY: common.scaleLinear()
970
- .domain([0, maxBucket + 1])
971
- .range([0, Math.min(this.height(), height)])
972
- };
973
- };
974
- ReactGantt.prototype.data = function (_) {
975
- var _a, _b;
976
- var retVal = _super.prototype.data.apply(this, arguments);
977
- if (arguments.length > 0) {
978
- this._minStart = (_a = Math.min.apply(Math, this.data().map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
979
- this._maxEnd = (_b = Math.max.apply(Math, this.data().map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
980
- this.measureDataText(true);
981
- }
982
- return retVal;
983
- };
984
- ReactGantt.prototype.measureDataText = function (forceMeasure) {
985
- if (forceMeasure === void 0) { forceMeasure = false; }
986
- var textWidths = {};
987
- var characterWidths = {};
988
- var fontFamily = this.fontFamily();
989
- var fontSize = this.fontSize();
990
- var bucketHeight = this.bucketHeight();
991
- if (bucketHeight) {
992
- this._maxFontScale = (bucketHeight - (this.rangePadding() * 2)) / fontSize;
993
- }
994
- if (forceMeasure || this._prevFontFamily !== fontFamily || this._prevFontSize !== fontSize) {
995
- characterWidths["."] = common.Utility.textSize(".", fontFamily, fontSize).width;
996
- this.data().forEach(function (d) {
997
- if (!textWidths[d[0]]) {
998
- textWidths[d[0]] = common.Utility.textSize(d[0], fontFamily, fontSize).width;
999
- }
1000
- d[0].split("").forEach(function (char) {
1001
- if (!characterWidths[char]) {
1002
- characterWidths[char] = common.Utility.textSize(char, fontFamily, fontSize).width;
1003
- }
1004
- });
1005
- });
1006
- this._textWidths = textWidths;
1007
- this._characterWidths = characterWidths;
1008
- }
1009
- this._prevFontFamily = fontFamily;
1010
- this._prevFontSize = fontSize;
1011
- };
1012
- ReactGantt.prototype.truncateText = function (text, width, scale) {
1013
- if (scale === void 0) { scale = 1; }
1014
- var textFits = this._textWidths[text] * scale < width;
1015
- if (textFits) {
1016
- return text;
1017
- }
1018
- var ret = "";
1019
- var sum = 0;
1020
- var _width = width - (this._characterWidths["."] * 3);
1021
- for (var _a = 0, text_1 = text; _a < text_1.length; _a++) {
1022
- var char = text_1[_a];
1023
- sum += this._characterWidths[char];
1024
- if (sum < _width) {
1025
- ret += char;
1026
- }
1027
- else {
1028
- break;
1029
- }
1030
- }
1031
- return _width < 0 ? "" : ret + "...";
1032
- };
1033
- ReactGantt.prototype.resize = function (_size) {
1034
- var retVal;
1035
- if (this.fitWidthToContent() || this.fitHeightToContent()) {
1036
- retVal = _super.prototype.resize.call(this, {
1037
- width: _size.width,
1038
- height: this._maxY
1039
- });
1040
- }
1041
- else {
1042
- retVal = _super.prototype.resize.apply(this, arguments);
1043
- }
1044
- return retVal;
1045
- };
1046
- ReactGantt.prototype.selectionChanged = function () {
1047
- };
1048
- ReactGantt.prototype.highlightItem = function (_element, d) {
1049
- };
1050
- ReactGantt.prototype.click = function (row, _col, sel) {
1051
- };
1052
- ReactGantt.prototype.dblclick = function (row, _col, sel) {
1053
- };
1054
- ReactGantt.prototype.mousein = function (row, _col, sel) {
1055
- };
1056
- ReactGantt.prototype.mouseover = function (row, _col, sel) {
1057
- };
1058
- ReactGantt.prototype.mouseout = function (row, _col, sel) {
1059
- };
1060
- return ReactGantt;
1061
- }(common.SVGZoomWidget));
1062
- ReactGantt.prototype._class += " timeline_ReactGantt";
1063
- ReactGantt.prototype.publish("fitWidthToContent", false, "boolean", "If true, resize will simply reapply the bounding box width");
1064
- ReactGantt.prototype.publish("fitHeightToContent", false, "boolean", "If true, resize will simply reapply the bounding box height");
1065
- ReactGantt.prototype.publish("titleColumn", null, "string", "Column name to for the title");
1066
- ReactGantt.prototype.publish("startDateColumn", null, "string", "Column name to for the start date");
1067
- ReactGantt.prototype.publish("endDateColumn", null, "string", "Column name to for the end date");
1068
- ReactGantt.prototype.publish("iconColumn", null, "string", "Column name to for the icon");
1069
- ReactGantt.prototype.publish("colorColumn", null, "string", "Column name to for the color");
1070
- ReactGantt.prototype.publish("seriesColumn", null, "string", "Column name to for the series identifier");
1071
- ReactGantt.prototype.publish("bucketColumn", null, "string", "Column name to for the bucket identifier");
1072
- ReactGantt.prototype.publish("renderMode", "default", "set", "Render modes vary in features and performance", ["default", "scale-all"]);
1073
- ReactGantt.prototype.publish("rangePadding", 3, "number", "Padding within each range rectangle (pixels)");
1074
- ReactGantt.prototype.publish("fill", "#1f77b4", "string", "Background color of range rectangle");
1075
- ReactGantt.prototype.publish("stroke", null, "string", "Color of range rectangle border");
1076
- ReactGantt.prototype.publish("strokeWidth", null, "number", "Width of range rectangle border (pixels)");
1077
- ReactGantt.prototype.publish("cornerRadius", 3, "number", "Space between range buckets (pixels)");
1078
- ReactGantt.prototype.publish("fontFamily", null, "string", "Font family within range rectangle", null, { optional: true });
1079
- ReactGantt.prototype.publish("fontSize", 10, "number", "Size of font within range rectangle (pixels)");
1080
- ReactGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
1081
- ReactGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1082
- ReactGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1083
- ReactGantt.prototype.publish("bucketHeight", 100, "number", "Max height of range element (pixels)");
1084
- ReactGantt.prototype.publish("gutter", 2, "number", "Space between range buckets (pixels)");
1085
- ReactGantt.prototype.publish("maxZoom", 16, "number", "Maximum zoom");
1086
- ReactGantt.prototype.publish("evenSeriesBackground", "#FFFFFF", "html-color", "Background color of even series rows");
1087
- ReactGantt.prototype.publish("oddSeriesBackground", "#DDDDDD", "html-color", "Background color of odd series rows");
572
+ var ReactGantt = /** @class */ (function (_super) {
573
+ __extends(ReactGantt, _super);
574
+ function ReactGantt(drawStartPosition) {
575
+ if (drawStartPosition === void 0) { drawStartPosition = "origin"; }
576
+ var _this = _super.call(this) || this;
577
+ _this._selection = new common.Utility.Selection(_this);
578
+ _this._title_idx = 0;
579
+ _this._startDate_idx = 1;
580
+ _this._endDate_idx = 2;
581
+ _this._icon_idx = -1;
582
+ _this._color_idx = -1;
583
+ _this._series_idx = -1;
584
+ _this._bucket_idx = -1;
585
+ _this._yoffset_idx = -1;
586
+ _this._rangeOptions = {
587
+ rangePadding: 2,
588
+ fontFamily: "Verdana",
589
+ fontSize: 12,
590
+ fill: "white",
591
+ stroke: "black",
592
+ textFill: "black",
593
+ cornerRadius: 3,
594
+ strokeWidth: 0
595
+ };
596
+ _this._rangeRenderer = react.LabelledRect;
597
+ _this._transform = { k: 1, x: 0, y: 0 };
598
+ _this._drawStartPos = drawStartPosition;
599
+ _this.showToolbar_default(false);
600
+ _this._tooltip = new html.HTMLTooltip();
601
+ _this._tooltip
602
+ .tooltipHTML(function (d) {
603
+ return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(d[1], " -&gt; ").concat(d[2], "</div>");
604
+ });
605
+ _this._tooltip
606
+ .followCursor(true);
607
+ return _this;
608
+ }
609
+ ReactGantt.prototype.rangeRenderer = function (_) {
610
+ if (!arguments.length)
611
+ return this._rangeRenderer;
612
+ this._rangeRenderer = _;
613
+ return this._rangeRenderer;
614
+ };
615
+ ReactGantt.prototype.enter = function (domNode, element) {
616
+ _super.prototype.enter.call(this, domNode, element);
617
+ var context = this;
618
+ element
619
+ .on("click", function (d) {
620
+ context._selection.clear();
621
+ });
622
+ this._tooltip.target(domNode);
623
+ };
624
+ ReactGantt.prototype.update = function (domNode, element) {
625
+ var _this = this;
626
+ _super.prototype.update.call(this, domNode, element);
627
+ this.zoomExtent([0.05, this.maxZoom()]);
628
+ this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
629
+ this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
630
+ this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
631
+ this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
632
+ this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
633
+ this._series_idx = this.seriesColumn() !== null ? this.columns().indexOf(this.seriesColumn()) : this._series_idx;
634
+ this._bucket_idx = this.bucketColumn() !== null ? this.columns().indexOf(this.bucketColumn()) : -1;
635
+ var context = this;
636
+ var w = this.width();
637
+ var x0 = 0;
638
+ var x1 = w;
639
+ this._interpolateX = common.scaleLinear()
640
+ .domain([this._minStart, this._maxEnd])
641
+ .range([x0, x1]);
642
+ this.data().sort(function (a, b) { return a[1] - b[1]; });
643
+ if (this._series_idx > -1) {
644
+ this._origIdxMap = {};
645
+ this._dataBySeries = {};
646
+ this._bucketsBySeries = {};
647
+ this.data().forEach(function (dataRow, origIdx) {
648
+ var seriesKey = dataRow[_this._series_idx];
649
+ if (!_this._dataBySeries[seriesKey]) {
650
+ _this._origIdxMap[seriesKey] = {};
651
+ _this._dataBySeries[seriesKey] = [];
652
+ }
653
+ _this._dataBySeries[seriesKey].push({
654
+ dataRow: dataRow,
655
+ origIdx: origIdx
656
+ });
657
+ });
658
+ var gutter_1 = this.gutter();
659
+ var bucketOffset_1 = 0;
660
+ var seriesKeys = Object.keys(this._dataBySeries);
661
+ seriesKeys.forEach(function (seriesKey) {
662
+ _this._dataBySeries[seriesKey].sort(function (a, b) { return a.dataRow[1] - b.dataRow[1]; });
663
+ _this._bucketsBySeries[seriesKey] = _this.calcBuckets(_this._dataBySeries[seriesKey].map(function (n) { return n.dataRow; }), 1, 2);
664
+ _this._bucketsBySeries[seriesKey].bucketHeight = _this.bucketHeight();
665
+ _this._bucketsBySeries[seriesKey].bucketOffset = bucketOffset_1;
666
+ bucketOffset_1 += (_this._bucketsBySeries[seriesKey].bucketHeight + _this.strokeWidth() + _this.gutter()) * (_this._bucketsBySeries[seriesKey].maxBucket + 1);
667
+ _this._dataBySeries[seriesKey].forEach(function (n, i) {
668
+ _this._origIdxMap[seriesKey][n.origIdx] = i;
669
+ });
670
+ });
671
+ this._seriesBackgrounds = this._renderElement.selectAll(".series-background")
672
+ .data(seriesKeys.map(function (key) {
673
+ return _this._bucketsBySeries[key];
674
+ }));
675
+ this._seriesBackgrounds
676
+ .join(function (enter) { return enter.append("rect")
677
+ .attr("class", "series-background"); }, function (update) { return update; }, function (exit) { return exit
678
+ .each(function (d) {
679
+ delete d.element;
680
+ })
681
+ .remove(); })
682
+ .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
683
+ .each(function (d, i) {
684
+ common.select(this)
685
+ .attr("x", 0)
686
+ .attr("y", d.bucketOffset - (gutter_1 / 2))
687
+ .attr("width", w)
688
+ .attr("height", ((d.bucketHeight + gutter_1) * (d.maxBucket + 1)) + gutter_1)
689
+ .attr("fill", i % 2 ? context.oddSeriesBackground() : context.evenSeriesBackground());
690
+ });
691
+ }
692
+ else {
693
+ if (this._bucket_idx !== -1) {
694
+ this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx, this._bucket_idx);
695
+ }
696
+ else {
697
+ this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx);
698
+ }
699
+ }
700
+ var interpedStart = this._interpolateX(this._minStart);
701
+ this.zoomTo([interpedStart, 0], 1);
702
+ var bucketHeight = this.bucketHeight();
703
+ this.setRangeOptions();
704
+ this._maxFontScale = (bucketHeight - (this.rangePadding() * 2));
705
+ this.measureDataText();
706
+ var itemSelection = this._renderElement.selectAll(".item")
707
+ .data(this.data());
708
+ var borderOffset1 = this.strokeWidth();
709
+ var borderOffset2 = borderOffset1 * 2;
710
+ itemSelection
711
+ .join(function (enter) { return enter.append("g")
712
+ .attr("class", "item")
713
+ .on("click.selectionBag", function (d, i) {
714
+ var _id = d.id === undefined ? i : d.id;
715
+ if (context._selection.isSelected({ _id: _id, element: d.element })) {
716
+ context._selection.clear();
717
+ }
718
+ else {
719
+ context._selection.click({
720
+ _id: _id,
721
+ element: function () { return d.element; }
722
+ }, common.d3Event);
723
+ }
724
+ context.selectionChanged();
725
+ common.d3Event().stopPropagation();
726
+ })
727
+ .on("click", function (d) {
728
+ var selected = d.element.classed("selected");
729
+ if (d[context.columns().length]) {
730
+ d.__lparam = d[context.columns().length];
731
+ }
732
+ context.click(d, "", selected);
733
+ })
734
+ .on("dblclick", function (d) {
735
+ var selected = d.element.classed("selected");
736
+ if (d[context.columns().length]) {
737
+ d.__lparam = d[context.columns().length];
738
+ }
739
+ context.click(d, "", selected);
740
+ })
741
+ .on("mousein", function (d) {
742
+ context.highlightItem(common.select(this), d);
743
+ var selected = d.element.classed("selected");
744
+ context.mousein(d, "", selected);
745
+ })
746
+ .on("mouseover", function (d) {
747
+ var d3evt = common.d3Event();
748
+ context._tooltip._triggerElement = d.element;
749
+ context._tooltip._cursorLoc = [
750
+ d3evt.clientX,
751
+ d3evt.clientY
752
+ ];
753
+ context._tooltip
754
+ .data(d)
755
+ .visible(true)
756
+ .fitContent(true)
757
+ .render();
758
+ context.highlightItem(common.select(this), d);
759
+ var selected = d.element.classed("selected");
760
+ context.mouseover(d, "", selected);
761
+ })
762
+ .on("mouseout", function (d) {
763
+ context._tooltip
764
+ .visible(false)
765
+ .render();
766
+ context.highlightItem(null, null);
767
+ var selected = d.element.classed("selected");
768
+ context.mouseout(d, "", selected);
769
+ })
770
+ .each(function (d, i) {
771
+ d.that = this;
772
+ d.element = common.select(this);
773
+ d.x = context._interpolateX(d[1]);
774
+ var endX = context._interpolateX(d[2]);
775
+ if (context._series_idx > -1) {
776
+ var seriesKey = d[context._series_idx];
777
+ var bucket = context._bucketsBySeries[seriesKey].bucketMap[context._origIdxMap[seriesKey][i]];
778
+ d.y = context._bucketsBySeries[seriesKey].interpolateY(bucket) + context._bucketsBySeries[seriesKey].bucketOffset;
779
+ }
780
+ else {
781
+ var _i = context._bucket_idx === -1 ? i : d[context._bucket_idx];
782
+ d.y = context._buckets.interpolateY(context._buckets.bucketMap[_i]);
783
+ }
784
+ d.props = __assign(__assign({}, d[3]), { text: d[0] });
785
+ d.props.width = endX - d.x;
786
+ d.props.height = bucketHeight;
787
+ d.x += borderOffset1;
788
+ d.y += borderOffset1;
789
+ d.props.width -= borderOffset2;
790
+ d.props.height -= borderOffset2;
791
+ d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
792
+ }); }, function (update) { return update; }, function (exit) { return exit
793
+ .each(function (d) {
794
+ delete d.element;
795
+ })
796
+ .remove(); })
797
+ .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
798
+ .each(function (d, i) {
799
+ d.that = this;
800
+ if (context._series_idx > -1) {
801
+ var seriesKey = d[context._series_idx];
802
+ d.x = context.renderRangeElement(d, i, false, context._rangeOptions, seriesKey);
803
+ }
804
+ else {
805
+ d.x = context.renderRangeElement(d, i, false, context._rangeOptions);
806
+ }
807
+ })
808
+ .on("dblclick.zoom", function (d) {
809
+ var x1 = _this._interpolateX(d[1]);
810
+ var x2 = _this._interpolateX(d[2]);
811
+ var xRange = x2 - x1;
812
+ var xScale = w / xRange;
813
+ _this.zoomTo([
814
+ -x1 * xScale,
815
+ 0
816
+ ], xScale);
817
+ });
818
+ element.on("dblclick.zoom", null);
819
+ };
820
+ ReactGantt.prototype.renderRangeElement = function (d, i, transformEach, options, seriesKey) {
821
+ if (transformEach === void 0) { transformEach = false; }
822
+ if (options === void 0) { options = {}; }
823
+ var borderOffset1 = options.strokeWidth;
824
+ var borderOffset2 = borderOffset1 * 2;
825
+ var padding = options.rangePadding;
826
+ var endX;
827
+ var x = isNaN(this._transform.x) ? 0 : this._transform.x;
828
+ var k = isNaN(this._transform.k) ? 1 : this._transform.k;
829
+ var b;
830
+ var bucketHeight = this.bucketHeight();
831
+ d.that.setAttribute("data-series", seriesKey);
832
+ if (this._color_idx > -1) {
833
+ d.that.setAttribute("data-color", d[this._color_idx]);
834
+ }
835
+ if (seriesKey !== undefined) {
836
+ b = this._bucketsBySeries[seriesKey].bucketMap[this._origIdxMap[seriesKey][i]];
837
+ d.that.setAttribute("data-b", b);
838
+ d.that.setAttribute("data-bucketOffset", this._bucketsBySeries[seriesKey].bucketOffset);
839
+ d.y = this._bucketsBySeries[seriesKey].interpolateY(b) + this._bucketsBySeries[seriesKey].bucketOffset;
840
+ d.that.setAttribute("data-dy", d.y);
841
+ }
842
+ else {
843
+ b = this._buckets.bucketMap[i];
844
+ d.y = this._buckets.interpolateY(b);
845
+ }
846
+ if (this._color_idx > -1) {
847
+ options.fill = d[this._color_idx];
848
+ }
849
+ if (!transformEach) {
850
+ d.x = this._interpolateX(d[1]);
851
+ endX = this._interpolateX(d[2]);
852
+ d.props = __assign(__assign({}, d[3]), { text: d[0] });
853
+ d.props.width = (endX - d.x) / k;
854
+ }
855
+ else {
856
+ d.x = this._interpolateX(d[1]) * k;
857
+ endX = this._interpolateX(d[2]) * k;
858
+ d.props = __assign(__assign({}, d[3]), { text: d[0] });
859
+ d.props.width = (endX - d.x) / k;
860
+ d.x += x;
861
+ d.props.width *= k;
862
+ }
863
+ d.props.height = bucketHeight;
864
+ if (seriesKey === undefined && this._buckets.bucketScale < 1) {
865
+ d.props.height = this._buckets.bucketScale * bucketHeight;
866
+ }
867
+ if (d.element === undefined && d.that) {
868
+ d.element = common.select(d.that);
869
+ }
870
+ d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
871
+ d.x += borderOffset1;
872
+ d.y += borderOffset1;
873
+ d.props.width -= borderOffset2;
874
+ d.props.height -= borderOffset2;
875
+ d.props.width = d.props.width < 1 ? 1 : d.props.width;
876
+ d.props.height = d.props.height < 1 ? 1 : d.props.height;
877
+ var text = this.truncateText(d.props.text, d.props.width - padding, this._maxFontScale);
878
+ if (text !== d.props.text) {
879
+ text = this.truncateText(d.props.text, d.props.width - padding);
880
+ }
881
+ else {
882
+ d.props.fontSize = this._maxFontScale * options.fontSize;
883
+ }
884
+ if (seriesKey === undefined && this._buckets.bucketScale < 1) {
885
+ d.props.fontSize = Math.min(this._maxFontScale, this._buckets.bucketScale) * options.fontSize;
886
+ }
887
+ if (!this._maxY || this._maxY < d.y + d.props.height) {
888
+ this._maxY = d.y + d.props.height;
889
+ }
890
+ if (!this._maxX || this._maxX < d.x + d.props.width) {
891
+ this._maxX = d.x + d.props.width;
892
+ }
893
+ react.render(this._rangeRenderer, __assign(__assign(__assign({}, options), d.props), { text: text }), d.that);
894
+ };
895
+ ReactGantt.prototype.setRangeOptions = function () {
896
+ this._rangeOptions = {
897
+ rangePadding: this.rangePadding(),
898
+ fontFamily: this.fontFamily(),
899
+ fontSize: this.fontSize(),
900
+ strokeWidth: this.strokeWidth(),
901
+ fill: this.fill(),
902
+ stroke: this.stroke(),
903
+ textFill: this.rangeFontColor(),
904
+ cornerRadius: this.cornerRadius(),
905
+ };
906
+ };
907
+ ReactGantt.prototype.zoomed = function (transform) {
908
+ var _this = this;
909
+ this._transform = transform;
910
+ switch (this.renderMode()) {
911
+ case "scale-all":
912
+ this._zoomScale = transform.k;
913
+ this._zoomTranslate = [transform.x, 0];
914
+ this._zoomG.attr("transform", "translate(".concat(transform.x, " ").concat(0, ")scale(").concat(transform.k, " 1)"));
915
+ break;
916
+ default:
917
+ var options_1 = this._rangeOptions;
918
+ this.data().forEach(function (d, i) {
919
+ if (_this._color_idx > -1) {
920
+ options_1.fill = d[_this._color_idx];
921
+ }
922
+ if (_this._series_idx > -1) {
923
+ var seriesKey = d[_this._series_idx];
924
+ _this.renderRangeElement(d, i, true, options_1, seriesKey);
925
+ }
926
+ else {
927
+ _this.renderRangeElement(d, i, true, options_1);
928
+ }
929
+ });
930
+ }
931
+ this.zoomedHook(transform);
932
+ };
933
+ ReactGantt.prototype.zoomedHook = function (transform) {
934
+ };
935
+ ReactGantt.prototype.calcBuckets = function (data, startKey, endKey, bucketKey) {
936
+ var bucketMap = {};
937
+ var bucketKeyMap = {};
938
+ var tol = this.overlapTolerence();
939
+ var buckets = [{ end: -Infinity }];
940
+ var maxBucket = 0;
941
+ if (bucketKey !== undefined) {
942
+ data.forEach(function (d, i) {
943
+ bucketMap[i] = d[bucketKey];
944
+ bucketKeyMap[d[bucketKey]] = true;
945
+ });
946
+ maxBucket = Object.keys(bucketKeyMap).length;
947
+ }
948
+ else {
949
+ data.forEach(function (d, i) {
950
+ for (var i2 = 0; i2 < buckets.length; ++i2) {
951
+ if (i === 0 || buckets[i2][endKey] + tol <= d[startKey]) {
952
+ bucketMap[i] = i2;
953
+ if (maxBucket < i2)
954
+ maxBucket = i2;
955
+ buckets[i2][endKey] = d[endKey];
956
+ break;
957
+ }
958
+ }
959
+ if (bucketMap[i] === undefined) {
960
+ bucketMap[i] = buckets.length;
961
+ var b = {};
962
+ b[endKey] = d[endKey];
963
+ buckets.push(b);
964
+ }
965
+ if (maxBucket < bucketMap[i])
966
+ maxBucket = bucketMap[i];
967
+ });
968
+ }
969
+ var height = (maxBucket + 1) * (this.bucketHeight() + this.gutter());
970
+ return {
971
+ bucketMap: bucketMap,
972
+ maxBucket: maxBucket,
973
+ bucketScale: this.height() / height,
974
+ interpolateY: common.scaleLinear()
975
+ .domain([0, maxBucket + 1])
976
+ .range([0, Math.min(this.height(), height)])
977
+ };
978
+ };
979
+ ReactGantt.prototype.data = function (_) {
980
+ var _a, _b;
981
+ var retVal = _super.prototype.data.apply(this, arguments);
982
+ if (arguments.length > 0) {
983
+ this._minStart = (_a = Math.min.apply(Math, this.data().map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
984
+ this._maxEnd = (_b = Math.max.apply(Math, this.data().map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
985
+ this.measureDataText(true);
986
+ }
987
+ return retVal;
988
+ };
989
+ ReactGantt.prototype.measureDataText = function (forceMeasure) {
990
+ if (forceMeasure === void 0) { forceMeasure = false; }
991
+ var textWidths = {};
992
+ var characterWidths = {};
993
+ var fontFamily = this.fontFamily();
994
+ var fontSize = this.fontSize();
995
+ var bucketHeight = this.bucketHeight();
996
+ if (bucketHeight) {
997
+ this._maxFontScale = (bucketHeight - (this.rangePadding() * 2)) / fontSize;
998
+ }
999
+ if (forceMeasure || this._prevFontFamily !== fontFamily || this._prevFontSize !== fontSize) {
1000
+ characterWidths["."] = common.Utility.textSize(".", fontFamily, fontSize).width;
1001
+ this.data().forEach(function (d) {
1002
+ if (!textWidths[d[0]]) {
1003
+ textWidths[d[0]] = common.Utility.textSize(d[0], fontFamily, fontSize).width;
1004
+ }
1005
+ d[0].split("").forEach(function (char) {
1006
+ if (!characterWidths[char]) {
1007
+ characterWidths[char] = common.Utility.textSize(char, fontFamily, fontSize).width;
1008
+ }
1009
+ });
1010
+ });
1011
+ this._textWidths = textWidths;
1012
+ this._characterWidths = characterWidths;
1013
+ }
1014
+ this._prevFontFamily = fontFamily;
1015
+ this._prevFontSize = fontSize;
1016
+ };
1017
+ ReactGantt.prototype.truncateText = function (text, width, scale) {
1018
+ if (scale === void 0) { scale = 1; }
1019
+ var textFits = this._textWidths[text] * scale < width;
1020
+ if (textFits) {
1021
+ return text;
1022
+ }
1023
+ var ret = "";
1024
+ var sum = 0;
1025
+ var _width = width - (this._characterWidths["."] * 3);
1026
+ for (var _a = 0, text_1 = text; _a < text_1.length; _a++) {
1027
+ var char = text_1[_a];
1028
+ sum += this._characterWidths[char];
1029
+ if (sum < _width) {
1030
+ ret += char;
1031
+ }
1032
+ else {
1033
+ break;
1034
+ }
1035
+ }
1036
+ return _width < 0 ? "" : ret + "...";
1037
+ };
1038
+ ReactGantt.prototype.resize = function (_size) {
1039
+ var retVal;
1040
+ if (this.fitWidthToContent() || this.fitHeightToContent()) {
1041
+ retVal = _super.prototype.resize.call(this, {
1042
+ width: _size.width,
1043
+ height: this._maxY
1044
+ });
1045
+ }
1046
+ else {
1047
+ retVal = _super.prototype.resize.apply(this, arguments);
1048
+ }
1049
+ return retVal;
1050
+ };
1051
+ ReactGantt.prototype.selectionChanged = function () {
1052
+ };
1053
+ ReactGantt.prototype.highlightItem = function (_element, d) {
1054
+ };
1055
+ ReactGantt.prototype.click = function (row, _col, sel) {
1056
+ };
1057
+ ReactGantt.prototype.dblclick = function (row, _col, sel) {
1058
+ };
1059
+ ReactGantt.prototype.mousein = function (row, _col, sel) {
1060
+ };
1061
+ ReactGantt.prototype.mouseover = function (row, _col, sel) {
1062
+ };
1063
+ ReactGantt.prototype.mouseout = function (row, _col, sel) {
1064
+ };
1065
+ return ReactGantt;
1066
+ }(common.SVGZoomWidget));
1067
+ ReactGantt.prototype._class += " timeline_ReactGantt";
1068
+ ReactGantt.prototype.publish("fitWidthToContent", false, "boolean", "If true, resize will simply reapply the bounding box width");
1069
+ ReactGantt.prototype.publish("fitHeightToContent", false, "boolean", "If true, resize will simply reapply the bounding box height");
1070
+ ReactGantt.prototype.publish("titleColumn", null, "string", "Column name to for the title");
1071
+ ReactGantt.prototype.publish("startDateColumn", null, "string", "Column name to for the start date");
1072
+ ReactGantt.prototype.publish("endDateColumn", null, "string", "Column name to for the end date");
1073
+ ReactGantt.prototype.publish("iconColumn", null, "string", "Column name to for the icon");
1074
+ ReactGantt.prototype.publish("colorColumn", null, "string", "Column name to for the color");
1075
+ ReactGantt.prototype.publish("seriesColumn", null, "string", "Column name to for the series identifier");
1076
+ ReactGantt.prototype.publish("bucketColumn", null, "string", "Column name to for the bucket identifier");
1077
+ ReactGantt.prototype.publish("renderMode", "default", "set", "Render modes vary in features and performance", ["default", "scale-all"]);
1078
+ ReactGantt.prototype.publish("rangePadding", 3, "number", "Padding within each range rectangle (pixels)");
1079
+ ReactGantt.prototype.publish("fill", "#1f77b4", "string", "Background color of range rectangle");
1080
+ ReactGantt.prototype.publish("stroke", null, "string", "Color of range rectangle border");
1081
+ ReactGantt.prototype.publish("strokeWidth", null, "number", "Width of range rectangle border (pixels)");
1082
+ ReactGantt.prototype.publish("cornerRadius", 3, "number", "Space between range buckets (pixels)");
1083
+ ReactGantt.prototype.publish("fontFamily", null, "string", "Font family within range rectangle", null, { optional: true });
1084
+ ReactGantt.prototype.publish("fontSize", 10, "number", "Size of font within range rectangle (pixels)");
1085
+ ReactGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
1086
+ ReactGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1087
+ ReactGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1088
+ ReactGantt.prototype.publish("bucketHeight", 100, "number", "Max height of range element (pixels)");
1089
+ ReactGantt.prototype.publish("gutter", 2, "number", "Space between range buckets (pixels)");
1090
+ ReactGantt.prototype.publish("maxZoom", 16, "number", "Maximum zoom");
1091
+ ReactGantt.prototype.publish("evenSeriesBackground", "#FFFFFF", "html-color", "Background color of even series rows");
1092
+ ReactGantt.prototype.publish("oddSeriesBackground", "#DDDDDD", "html-color", "Background color of odd series rows");
1088
1093
 
1089
- var ReactAxisGantt = /** @class */ (function (_super) {
1090
- __extends(ReactAxisGantt, _super);
1091
- function ReactAxisGantt() {
1092
- var _this = _super.call(this) || this;
1093
- _this._topAxis = new chart.Axis("center")
1094
- .orientation("top")
1095
- .type("linear")
1096
- .shrinkToFit("none")
1097
- .overlapMode("hide")
1098
- .extend(0)
1099
- .tickFormat("d");
1100
- _this._gantt = new ReactGantt("center")
1101
- .stroke("#000000");
1102
- _this._bottomAxis = new chart.Axis("center")
1103
- .orientation("bottom")
1104
- .type("linear")
1105
- .shrinkToFit("none")
1106
- .overlapMode("hide")
1107
- .extend(0)
1108
- .tickFormat("d");
1109
- _this._drawStartPos = "origin";
1110
- _this.rangeRenderer = function () {
1111
- var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1112
- if (!arguments.length)
1113
- return ret;
1114
- return this;
1115
- };
1116
- return _this;
1117
- }
1118
- ReactAxisGantt.prototype.resizeWrappers = function () {
1119
- var w = this.width();
1120
- var h = this.height();
1121
- var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1122
- var contentHeight = (h - (axisHeight * 2));
1123
- var borderOffset1 = this.strokeWidth();
1124
- this._topRect
1125
- .attr("height", axisHeight)
1126
- .attr("width", w)
1127
- .attr("fill", "transparent");
1128
- this._topAxisElement.attr("transform", "translate(0 0)");
1129
- this._topAxis.resize({ height: axisHeight, width: w });
1130
- this._contentRect
1131
- .attr("height", contentHeight)
1132
- .attr("width", w)
1133
- .attr("fill", "transparent");
1134
- this._contentElement.attr("transform", "translate(0 ".concat(axisHeight + borderOffset1, ")"));
1135
- this._gantt.resize({ height: contentHeight, width: w });
1136
- this._bottomRect
1137
- .attr("height", axisHeight)
1138
- .attr("width", w)
1139
- .attr("fill", "transparent");
1140
- this._bottomAxisElement.attr("transform", "translate(0 ".concat(axisHeight + contentHeight + borderOffset1, ")"));
1141
- this._bottomAxis.resize({ height: axisHeight, width: w });
1142
- };
1143
- ReactAxisGantt.prototype.enter = function (domNode, element) {
1144
- var _this = this;
1145
- _super.prototype.enter.call(this, domNode, element);
1146
- this._gantt.click = function (row, col, sel) {
1147
- _this.click(row, col, sel);
1148
- };
1149
- this._gantt.dblclick = function (row, col, sel) {
1150
- _this.dblclick(row, col, sel);
1151
- };
1152
- this._topAxisElement = element.append("g")
1153
- .attr("class", "top-axis-wrapper");
1154
- this._topRect = this._topAxisElement.append("rect")
1155
- .attr("class", "top-axis-rect");
1156
- this._contentElement = element.append("g")
1157
- .attr("class", "content-wrapper");
1158
- this._contentRect = this._contentElement.append("rect")
1159
- .attr("class", "content-rect");
1160
- this._bottomAxisElement = element.append("g")
1161
- .attr("class", "bottom-axis-wrapper");
1162
- this._bottomRect = this._bottomAxisElement.append("rect")
1163
- .attr("class", "top-axis-rect");
1164
- this._topAxis.target(this._topAxisElement.node());
1165
- this._gantt.target(this._contentElement.node()).bucketHeight(30);
1166
- this._bottomAxis.target(this._bottomAxisElement.node());
1167
- this.resizeWrappers();
1168
- this._gantt.zoomedHook = function (transform) {
1169
- _this.onzoom(transform);
1170
- };
1171
- };
1172
- ReactAxisGantt.prototype.onzoom = function (transform) {
1173
- var w = this.width();
1174
- var low = this._gantt._minStart;
1175
- var high = this._gantt._maxEnd;
1176
- var range = high - low;
1177
- var wpp = range / w;
1178
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1179
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1180
- this._topAxis
1181
- .fontFamily(this.axisFontFamily())
1182
- .fontSize(this.axisFontSize())
1183
- .tickLength(this.axisTickLength())
1184
- .low(nextLow)
1185
- .high(nextHigh)
1186
- .render();
1187
- this._bottomAxis
1188
- .fontFamily(this.axisFontFamily())
1189
- .fontSize(this.axisFontSize())
1190
- .tickLength(this.axisTickLength())
1191
- .low(nextLow)
1192
- .high(nextHigh)
1193
- .render();
1194
- };
1195
- ReactAxisGantt.prototype.update = function (domNode, element) {
1196
- _super.prototype.update.call(this, domNode, element);
1197
- this._topAxis.tickFormat(this.tickFormat()).render();
1198
- this._bottomAxis.tickFormat(this.tickFormat()).render();
1199
- this._gantt.render();
1200
- };
1201
- ReactAxisGantt.prototype.columns = function (_) {
1202
- var retVal = _super.prototype.columns.apply(this, arguments);
1203
- if (arguments.length > 0) {
1204
- this._gantt.columns(_);
1205
- }
1206
- return retVal;
1207
- };
1208
- ReactAxisGantt.prototype.data = function (_) {
1209
- var _a, _b;
1210
- var retVal = _super.prototype.data.apply(this, arguments);
1211
- if (arguments.length > 0) {
1212
- var ganttData = this.data().map(function (n) {
1213
- var ret = __spreadArray([], n, true);
1214
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1215
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1216
- return ret;
1217
- });
1218
- this._gantt._minStart = (_a = Math.min.apply(Math, ganttData.map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
1219
- this._gantt._maxEnd = (_b = Math.max.apply(Math, ganttData.map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
1220
- this._gantt.data(ganttData);
1221
- }
1222
- return retVal;
1223
- };
1224
- ReactAxisGantt.prototype.resize = function (_size) {
1225
- var retVal = _super.prototype.resize.apply(this, arguments);
1226
- if (this._topAxisElement) {
1227
- this.resizeWrappers();
1228
- }
1229
- return retVal;
1230
- };
1231
- ReactAxisGantt.prototype.click = function (row, col, sel) {
1232
- };
1233
- ReactAxisGantt.prototype.dblclick = function (row, col, sel) {
1234
- };
1235
- ReactAxisGantt.prototype.tooltip = function () {
1236
- return this._gantt._tooltip;
1237
- };
1238
- return ReactAxisGantt;
1239
- }(common.SVGWidget));
1240
- ReactAxisGantt.prototype._class += " timeline_ReactAxisGantt";
1241
- ReactAxisGantt.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1242
- ReactAxisGantt.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1243
- ReactAxisGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1244
- ReactAxisGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1245
- ReactAxisGantt.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1246
- ReactAxisGantt.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1247
- ReactAxisGantt.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1248
- ReactAxisGantt.prototype.publishProxy("gutter", "_gantt");
1249
- ReactAxisGantt.prototype.publishProxy("renderMode", "_gantt");
1250
- ReactAxisGantt.prototype.publishProxy("strokeWidth", "_gantt");
1251
- ReactAxisGantt.prototype.publishProxy("fontSize", "_gantt");
1252
- ReactAxisGantt.prototype.publishProxy("fontFamily", "_gantt");
1253
- ReactAxisGantt.prototype.publishProxy("stroke", "_gantt");
1254
- ReactAxisGantt.prototype.publishProxy("cornerRadius", "_gantt");
1255
- ReactAxisGantt.prototype.publishProxy("titleColumn", "_gantt");
1256
- ReactAxisGantt.prototype.publishProxy("startDateColumn", "_gantt");
1257
- ReactAxisGantt.prototype.publishProxy("endDateColumn", "_gantt");
1258
- ReactAxisGantt.prototype.publishProxy("iconColumn", "_gantt");
1259
- ReactAxisGantt.prototype.publishProxy("colorColumn", "_gantt");
1260
- ReactAxisGantt.prototype.publishProxy("bucketColumn", "_gantt");
1261
- ReactAxisGantt.prototype.publishProxy("maxZoom", "_gantt");
1262
- ReactAxisGantt.prototype.publishProxy("bucketHeight", "_gantt");
1094
+ var ReactAxisGantt = /** @class */ (function (_super) {
1095
+ __extends(ReactAxisGantt, _super);
1096
+ function ReactAxisGantt() {
1097
+ var _this = _super.call(this) || this;
1098
+ _this._topAxis = new chart.Axis("center")
1099
+ .orientation("top")
1100
+ .type("linear")
1101
+ .shrinkToFit("none")
1102
+ .overlapMode("hide")
1103
+ .extend(0)
1104
+ .tickFormat("d");
1105
+ _this._gantt = new ReactGantt("center")
1106
+ .stroke("#000000");
1107
+ _this._bottomAxis = new chart.Axis("center")
1108
+ .orientation("bottom")
1109
+ .type("linear")
1110
+ .shrinkToFit("none")
1111
+ .overlapMode("hide")
1112
+ .extend(0)
1113
+ .tickFormat("d");
1114
+ _this._drawStartPos = "origin";
1115
+ _this.rangeRenderer = function () {
1116
+ var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1117
+ if (!arguments.length)
1118
+ return ret;
1119
+ return this;
1120
+ };
1121
+ return _this;
1122
+ }
1123
+ ReactAxisGantt.prototype.resizeWrappers = function () {
1124
+ var w = this.width();
1125
+ var h = this.height();
1126
+ var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1127
+ var contentHeight = (h - (axisHeight * 2));
1128
+ var borderOffset1 = this.strokeWidth();
1129
+ this._topRect
1130
+ .attr("height", axisHeight)
1131
+ .attr("width", w)
1132
+ .attr("fill", "transparent");
1133
+ this._topAxisElement.attr("transform", "translate(0 0)");
1134
+ this._topAxis.resize({ height: axisHeight, width: w });
1135
+ this._contentRect
1136
+ .attr("height", contentHeight)
1137
+ .attr("width", w)
1138
+ .attr("fill", "transparent");
1139
+ this._contentElement.attr("transform", "translate(0 ".concat(axisHeight + borderOffset1, ")"));
1140
+ this._gantt.resize({ height: contentHeight, width: w });
1141
+ this._bottomRect
1142
+ .attr("height", axisHeight)
1143
+ .attr("width", w)
1144
+ .attr("fill", "transparent");
1145
+ this._bottomAxisElement.attr("transform", "translate(0 ".concat(axisHeight + contentHeight + borderOffset1, ")"));
1146
+ this._bottomAxis.resize({ height: axisHeight, width: w });
1147
+ };
1148
+ ReactAxisGantt.prototype.enter = function (domNode, element) {
1149
+ var _this = this;
1150
+ _super.prototype.enter.call(this, domNode, element);
1151
+ this._gantt.click = function (row, col, sel) {
1152
+ _this.click(row, col, sel);
1153
+ };
1154
+ this._gantt.dblclick = function (row, col, sel) {
1155
+ _this.dblclick(row, col, sel);
1156
+ };
1157
+ this._topAxisElement = element.append("g")
1158
+ .attr("class", "top-axis-wrapper");
1159
+ this._topRect = this._topAxisElement.append("rect")
1160
+ .attr("class", "top-axis-rect");
1161
+ this._contentElement = element.append("g")
1162
+ .attr("class", "content-wrapper");
1163
+ this._contentRect = this._contentElement.append("rect")
1164
+ .attr("class", "content-rect");
1165
+ this._bottomAxisElement = element.append("g")
1166
+ .attr("class", "bottom-axis-wrapper");
1167
+ this._bottomRect = this._bottomAxisElement.append("rect")
1168
+ .attr("class", "top-axis-rect");
1169
+ this._topAxis.target(this._topAxisElement.node());
1170
+ this._gantt.target(this._contentElement.node()).bucketHeight(30);
1171
+ this._bottomAxis.target(this._bottomAxisElement.node());
1172
+ this.resizeWrappers();
1173
+ this._gantt.zoomedHook = function (transform) {
1174
+ _this.onzoom(transform);
1175
+ };
1176
+ };
1177
+ ReactAxisGantt.prototype.onzoom = function (transform) {
1178
+ var w = this.width();
1179
+ var low = this._gantt._minStart;
1180
+ var high = this._gantt._maxEnd;
1181
+ var range = high - low;
1182
+ var wpp = range / w;
1183
+ var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1184
+ var nextHigh = Math.ceil((range / transform.k) + nextLow);
1185
+ this._topAxis
1186
+ .fontFamily(this.axisFontFamily())
1187
+ .fontSize(this.axisFontSize())
1188
+ .tickLength(this.axisTickLength())
1189
+ .low(nextLow)
1190
+ .high(nextHigh)
1191
+ .render();
1192
+ this._bottomAxis
1193
+ .fontFamily(this.axisFontFamily())
1194
+ .fontSize(this.axisFontSize())
1195
+ .tickLength(this.axisTickLength())
1196
+ .low(nextLow)
1197
+ .high(nextHigh)
1198
+ .render();
1199
+ };
1200
+ ReactAxisGantt.prototype.update = function (domNode, element) {
1201
+ _super.prototype.update.call(this, domNode, element);
1202
+ this._topAxis.tickFormat(this.tickFormat()).render();
1203
+ this._bottomAxis.tickFormat(this.tickFormat()).render();
1204
+ this._gantt.render();
1205
+ };
1206
+ ReactAxisGantt.prototype.columns = function (_) {
1207
+ var retVal = _super.prototype.columns.apply(this, arguments);
1208
+ if (arguments.length > 0) {
1209
+ this._gantt.columns(_);
1210
+ }
1211
+ return retVal;
1212
+ };
1213
+ ReactAxisGantt.prototype.data = function (_) {
1214
+ var _a, _b;
1215
+ var retVal = _super.prototype.data.apply(this, arguments);
1216
+ if (arguments.length > 0) {
1217
+ var ganttData = this.data().map(function (n) {
1218
+ var ret = __spreadArray([], n, true);
1219
+ ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1220
+ ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1221
+ return ret;
1222
+ });
1223
+ this._gantt._minStart = (_a = Math.min.apply(Math, ganttData.map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
1224
+ this._gantt._maxEnd = (_b = Math.max.apply(Math, ganttData.map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
1225
+ this._gantt.data(ganttData);
1226
+ }
1227
+ return retVal;
1228
+ };
1229
+ ReactAxisGantt.prototype.resize = function (_size) {
1230
+ var retVal = _super.prototype.resize.apply(this, arguments);
1231
+ if (this._topAxisElement) {
1232
+ this.resizeWrappers();
1233
+ }
1234
+ return retVal;
1235
+ };
1236
+ ReactAxisGantt.prototype.click = function (row, col, sel) {
1237
+ };
1238
+ ReactAxisGantt.prototype.dblclick = function (row, col, sel) {
1239
+ };
1240
+ ReactAxisGantt.prototype.tooltip = function () {
1241
+ return this._gantt._tooltip;
1242
+ };
1243
+ return ReactAxisGantt;
1244
+ }(common.SVGWidget));
1245
+ ReactAxisGantt.prototype._class += " timeline_ReactAxisGantt";
1246
+ ReactAxisGantt.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1247
+ ReactAxisGantt.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1248
+ ReactAxisGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1249
+ ReactAxisGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1250
+ ReactAxisGantt.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1251
+ ReactAxisGantt.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1252
+ ReactAxisGantt.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1253
+ ReactAxisGantt.prototype.publishProxy("gutter", "_gantt");
1254
+ ReactAxisGantt.prototype.publishProxy("renderMode", "_gantt");
1255
+ ReactAxisGantt.prototype.publishProxy("strokeWidth", "_gantt");
1256
+ ReactAxisGantt.prototype.publishProxy("fontSize", "_gantt");
1257
+ ReactAxisGantt.prototype.publishProxy("fontFamily", "_gantt");
1258
+ ReactAxisGantt.prototype.publishProxy("stroke", "_gantt");
1259
+ ReactAxisGantt.prototype.publishProxy("cornerRadius", "_gantt");
1260
+ ReactAxisGantt.prototype.publishProxy("titleColumn", "_gantt");
1261
+ ReactAxisGantt.prototype.publishProxy("startDateColumn", "_gantt");
1262
+ ReactAxisGantt.prototype.publishProxy("endDateColumn", "_gantt");
1263
+ ReactAxisGantt.prototype.publishProxy("iconColumn", "_gantt");
1264
+ ReactAxisGantt.prototype.publishProxy("colorColumn", "_gantt");
1265
+ ReactAxisGantt.prototype.publishProxy("bucketColumn", "_gantt");
1266
+ ReactAxisGantt.prototype.publishProxy("maxZoom", "_gantt");
1267
+ ReactAxisGantt.prototype.publishProxy("bucketHeight", "_gantt");
1263
1268
 
1264
- var ReactAxisGanttSeries = /** @class */ (function (_super) {
1265
- __extends(ReactAxisGanttSeries, _super);
1266
- function ReactAxisGanttSeries() {
1267
- var _this = _super.call(this) || this;
1268
- _this._topAxis = new chart.Axis("origin")
1269
- .orientation("top")
1270
- .type("linear")
1271
- .shrinkToFit("none")
1272
- .overlapMode("hide")
1273
- .extend(0)
1274
- .tickFormat("d");
1275
- _this._gantt = new ReactGantt("origin")
1276
- .stroke("#000000")
1277
- .fitHeightToContent(true);
1278
- _this._bottomAxis = new chart.Axis("origin")
1279
- .orientation("bottom")
1280
- .type("linear")
1281
- .shrinkToFit("none")
1282
- .overlapMode("hide")
1283
- .extend(0)
1284
- .tickFormat("d");
1285
- _this.centerOverflowX_default("hidden");
1286
- _this.centerOverflowY_default("auto");
1287
- return _this;
1288
- }
1289
- ReactAxisGanttSeries.prototype.rangeRenderer = function (_) {
1290
- var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1291
- if (!arguments.length)
1292
- return ret;
1293
- return this;
1294
- };
1295
- ReactAxisGanttSeries.prototype.resizeWrappers = function () {
1296
- var w = this.width();
1297
- var h = this.height();
1298
- var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1299
- var contentHeight = (h - (axisHeight * 2));
1300
- this.bottomHeight(axisHeight);
1301
- this._topWA.resize({
1302
- width: w,
1303
- height: axisHeight
1304
- });
1305
- this._centerWA.resize({
1306
- width: w,
1307
- height: contentHeight
1308
- });
1309
- this._bottomWA.resize({
1310
- width: w,
1311
- height: axisHeight
1312
- });
1313
- this.top().render();
1314
- this.bottom().render();
1315
- this.center().render();
1316
- };
1317
- ReactAxisGanttSeries.prototype.enter = function (domNode, element) {
1318
- var _this = this;
1319
- _super.prototype.enter.call(this, domNode, element);
1320
- this._gantt.click = function (row, col, sel) {
1321
- _this.click(row, col, sel);
1322
- };
1323
- this._gantt.dblclick = function (row, col, sel) {
1324
- _this.dblclick(row, col, sel);
1325
- };
1326
- this.top(this._topAxis);
1327
- this.center(this._gantt);
1328
- this.bottom(this._bottomAxis);
1329
- this.resizeWrappers();
1330
- this._gantt.zoomedHook = function (transform) {
1331
- _this.onzoom(transform);
1332
- };
1333
- };
1334
- ReactAxisGanttSeries.prototype.onzoom = function (transform) {
1335
- var w = this.width();
1336
- var low = this._gantt._minStart;
1337
- var high = this._gantt._maxEnd;
1338
- var range = high - low;
1339
- var wpp = range / w;
1340
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1341
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1342
- this._topAxis
1343
- .fontFamily(this.axisFontFamily())
1344
- .fontSize(this.axisFontSize())
1345
- .tickLength(this.axisTickLength())
1346
- .low(nextLow)
1347
- .high(nextHigh)
1348
- .lazyRender();
1349
- this._bottomAxis
1350
- .fontFamily(this.axisFontFamily())
1351
- .fontSize(this.axisFontSize())
1352
- .tickLength(this.axisTickLength())
1353
- .low(nextLow)
1354
- .high(nextHigh)
1355
- .lazyRender();
1356
- };
1357
- ReactAxisGanttSeries.prototype.update = function (domNode, element) {
1358
- _super.prototype.update.call(this, domNode, element);
1359
- this._topAxis.tickFormat(this.tickFormat()).render();
1360
- this._bottomAxis.tickFormat(this.tickFormat()).render();
1361
- this._gantt.render();
1362
- };
1363
- ReactAxisGanttSeries.prototype.columns = function (_) {
1364
- var retVal = _super.prototype.columns.apply(this, arguments);
1365
- if (arguments.length > 0) {
1366
- this._gantt.columns(_);
1367
- }
1368
- return retVal;
1369
- };
1370
- ReactAxisGanttSeries.prototype.data = function (_) {
1371
- var retVal = _super.prototype.data.apply(this, arguments);
1372
- if (arguments.length > 0) {
1373
- var ganttData = this.data().map(function (n) {
1374
- var ret = __spreadArray([], n, true);
1375
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1376
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1377
- return ret;
1378
- });
1379
- this._gantt._minStart = common.min(ganttData, function (n) { return n[1]; });
1380
- this._gantt._maxEnd = common.max(ganttData, function (n) { return n[2]; });
1381
- this._gantt.data(ganttData);
1382
- }
1383
- return retVal;
1384
- };
1385
- ReactAxisGanttSeries.prototype.resize = function (_size) {
1386
- var retVal = _super.prototype.resize.apply(this, arguments);
1387
- if (this._topAxisElement) {
1388
- this.resizeWrappers();
1389
- }
1390
- return retVal;
1391
- };
1392
- ReactAxisGanttSeries.prototype.click = function (row, col, sel) {
1393
- };
1394
- ReactAxisGanttSeries.prototype.dblclick = function (row, col, sel) {
1395
- };
1396
- ReactAxisGanttSeries.prototype.tooltip = function () {
1397
- return this._gantt._tooltip;
1398
- };
1399
- return ReactAxisGanttSeries;
1400
- }(layout.Border2));
1401
- ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
1402
- ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1403
- ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1404
- ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1405
- ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1406
- ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1407
- ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1408
- ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1409
- ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
1410
- ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
1411
- ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
1412
- ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
1413
- ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
1414
- ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
1415
- ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
1416
- ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
1417
- ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
1418
- ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
1419
- ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
1420
- ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
1421
- ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
1422
- ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
1423
- ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
1424
- ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
1425
- ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
1426
- ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");
1269
+ var ReactAxisGanttSeries = /** @class */ (function (_super) {
1270
+ __extends(ReactAxisGanttSeries, _super);
1271
+ function ReactAxisGanttSeries() {
1272
+ var _this = _super.call(this) || this;
1273
+ _this._topAxis = new chart.Axis("origin")
1274
+ .orientation("top")
1275
+ .type("linear")
1276
+ .shrinkToFit("none")
1277
+ .overlapMode("hide")
1278
+ .extend(0)
1279
+ .tickFormat("d");
1280
+ _this._gantt = new ReactGantt("origin")
1281
+ .stroke("#000000")
1282
+ .fitHeightToContent(true);
1283
+ _this._bottomAxis = new chart.Axis("origin")
1284
+ .orientation("bottom")
1285
+ .type("linear")
1286
+ .shrinkToFit("none")
1287
+ .overlapMode("hide")
1288
+ .extend(0)
1289
+ .tickFormat("d");
1290
+ _this.centerOverflowX_default("hidden");
1291
+ _this.centerOverflowY_default("auto");
1292
+ return _this;
1293
+ }
1294
+ ReactAxisGanttSeries.prototype.rangeRenderer = function (_) {
1295
+ var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1296
+ if (!arguments.length)
1297
+ return ret;
1298
+ return this;
1299
+ };
1300
+ ReactAxisGanttSeries.prototype.resizeWrappers = function () {
1301
+ var w = this.width();
1302
+ var h = this.height();
1303
+ var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1304
+ var contentHeight = (h - (axisHeight * 2));
1305
+ this.bottomHeight(axisHeight);
1306
+ this._topWA.resize({
1307
+ width: w,
1308
+ height: axisHeight
1309
+ });
1310
+ this._centerWA.resize({
1311
+ width: w,
1312
+ height: contentHeight
1313
+ });
1314
+ this._bottomWA.resize({
1315
+ width: w,
1316
+ height: axisHeight
1317
+ });
1318
+ this.top().render();
1319
+ this.bottom().render();
1320
+ this.center().render();
1321
+ };
1322
+ ReactAxisGanttSeries.prototype.enter = function (domNode, element) {
1323
+ var _this = this;
1324
+ _super.prototype.enter.call(this, domNode, element);
1325
+ this._gantt.click = function (row, col, sel) {
1326
+ _this.click(row, col, sel);
1327
+ };
1328
+ this._gantt.dblclick = function (row, col, sel) {
1329
+ _this.dblclick(row, col, sel);
1330
+ };
1331
+ this.top(this._topAxis);
1332
+ this.center(this._gantt);
1333
+ this.bottom(this._bottomAxis);
1334
+ this.resizeWrappers();
1335
+ this._gantt.zoomedHook = function (transform) {
1336
+ _this.onzoom(transform);
1337
+ };
1338
+ };
1339
+ ReactAxisGanttSeries.prototype.onzoom = function (transform) {
1340
+ var w = this.width();
1341
+ var low = this._gantt._minStart;
1342
+ var high = this._gantt._maxEnd;
1343
+ var range = high - low;
1344
+ var wpp = range / w;
1345
+ var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1346
+ var nextHigh = Math.ceil((range / transform.k) + nextLow);
1347
+ this._topAxis
1348
+ .fontFamily(this.axisFontFamily())
1349
+ .fontSize(this.axisFontSize())
1350
+ .tickLength(this.axisTickLength())
1351
+ .low(nextLow)
1352
+ .high(nextHigh)
1353
+ .lazyRender();
1354
+ this._bottomAxis
1355
+ .fontFamily(this.axisFontFamily())
1356
+ .fontSize(this.axisFontSize())
1357
+ .tickLength(this.axisTickLength())
1358
+ .low(nextLow)
1359
+ .high(nextHigh)
1360
+ .lazyRender();
1361
+ };
1362
+ ReactAxisGanttSeries.prototype.update = function (domNode, element) {
1363
+ _super.prototype.update.call(this, domNode, element);
1364
+ this._topAxis.tickFormat(this.tickFormat()).render();
1365
+ this._bottomAxis.tickFormat(this.tickFormat()).render();
1366
+ this._gantt.render();
1367
+ };
1368
+ ReactAxisGanttSeries.prototype.columns = function (_) {
1369
+ var retVal = _super.prototype.columns.apply(this, arguments);
1370
+ if (arguments.length > 0) {
1371
+ this._gantt.columns(_);
1372
+ }
1373
+ return retVal;
1374
+ };
1375
+ ReactAxisGanttSeries.prototype.data = function (_) {
1376
+ var retVal = _super.prototype.data.apply(this, arguments);
1377
+ if (arguments.length > 0) {
1378
+ var ganttData = this.data().map(function (n) {
1379
+ var ret = __spreadArray([], n, true);
1380
+ ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1381
+ ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1382
+ return ret;
1383
+ });
1384
+ this._gantt._minStart = common.min(ganttData, function (n) { return n[1]; });
1385
+ this._gantt._maxEnd = common.max(ganttData, function (n) { return n[2]; });
1386
+ this._gantt.data(ganttData);
1387
+ }
1388
+ return retVal;
1389
+ };
1390
+ ReactAxisGanttSeries.prototype.resize = function (_size) {
1391
+ var retVal = _super.prototype.resize.apply(this, arguments);
1392
+ if (this._topAxisElement) {
1393
+ this.resizeWrappers();
1394
+ }
1395
+ return retVal;
1396
+ };
1397
+ ReactAxisGanttSeries.prototype.click = function (row, col, sel) {
1398
+ };
1399
+ ReactAxisGanttSeries.prototype.dblclick = function (row, col, sel) {
1400
+ };
1401
+ ReactAxisGanttSeries.prototype.tooltip = function () {
1402
+ return this._gantt._tooltip;
1403
+ };
1404
+ return ReactAxisGanttSeries;
1405
+ }(layout.Border2));
1406
+ ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
1407
+ ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1408
+ ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1409
+ ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1410
+ ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1411
+ ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1412
+ ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1413
+ ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1414
+ ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
1415
+ ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
1416
+ ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
1417
+ ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
1418
+ ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
1419
+ ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
1420
+ ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
1421
+ ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
1422
+ ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
1423
+ ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
1424
+ ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
1425
+ ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
1426
+ ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
1427
+ ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
1428
+ ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
1429
+ ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
1430
+ ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
1431
+ ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");
1427
1432
 
1428
- var ReactTimeline = /** @class */ (function (_super) {
1429
- __extends(ReactTimeline, _super);
1430
- function ReactTimeline() {
1431
- var _this = _super.call(this) || this;
1432
- _this._drawStartPos = "origin";
1433
- _this._topAxis.type("time");
1434
- _this._bottomAxis.type("time");
1435
- _this.tooltipHTML(function (d) {
1436
- var parser = common.timeParse("%Q");
1437
- var startTime = parser(d[1]);
1438
- var endTime = parser(d[2]);
1439
- var formatter = common.timeFormat(_this.tooltipTimeFormat());
1440
- return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1441
- });
1442
- return _this;
1443
- }
1444
- ReactTimeline.prototype.update = function (domNode, element) {
1445
- _super.prototype.update.call(this, domNode, element);
1446
- if (this.timePattern_exists()) {
1447
- var minTimestamp_1 = Infinity;
1448
- var maxTimestamp_1 = -Infinity;
1449
- var lowDateStr_1 = "";
1450
- var highDateStr_1 = "";
1451
- this.data().map(function (n) {
1452
- var start = new Date(n[1]).getTime();
1453
- var end = new Date(n[2]).getTime();
1454
- if (minTimestamp_1 > start) {
1455
- minTimestamp_1 = start;
1456
- lowDateStr_1 = "" + n[1];
1457
- }
1458
- if (maxTimestamp_1 < end) {
1459
- maxTimestamp_1 = end;
1460
- highDateStr_1 = "" + n[2];
1461
- }
1462
- });
1463
- this._topAxis
1464
- .type("time")
1465
- .timePattern(this.timePattern())
1466
- .overlapMode("none")
1467
- .tickFormat(this._axisLabelFormatter)
1468
- .low(lowDateStr_1)
1469
- .high(highDateStr_1);
1470
- this._bottomAxis
1471
- .type("time")
1472
- .timePattern(this.timePattern())
1473
- .overlapMode("none")
1474
- .tickFormat(this._axisLabelFormatter)
1475
- .low(lowDateStr_1)
1476
- .high(highDateStr_1);
1477
- this._gantt._minStart = minTimestamp_1;
1478
- this._gantt._maxEnd = maxTimestamp_1;
1479
- }
1480
- };
1481
- ReactTimeline.prototype.tooltipHTML = function (callback) {
1482
- this._tooltipHTML = callback;
1483
- this.tooltip().tooltipHTML(this._tooltipHTML);
1484
- return this;
1485
- };
1486
- ReactTimeline.prototype.parseAxisValue = function (v) {
1487
- var parseTime = common.timeParse("%Q");
1488
- var parsedTime = parseTime(v);
1489
- var formatTime = common.timeFormat(this.timePattern());
1490
- return formatTime(parsedTime);
1491
- };
1492
- ReactTimeline.prototype.onzoom = function (transform) {
1493
- var w = this.width();
1494
- var low = this._gantt._minStart;
1495
- var high = this._gantt._maxEnd;
1496
- var range = high - low;
1497
- var wpp = range / w;
1498
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1499
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1500
- this._topAxis
1501
- .low(this.parseAxisValue(nextLow))
1502
- .high(this.parseAxisValue(nextHigh))
1503
- .render();
1504
- this._bottomAxis
1505
- .low(this.parseAxisValue(nextLow))
1506
- .high(this.parseAxisValue(nextHigh))
1507
- .render();
1508
- };
1509
- return ReactTimeline;
1510
- }(ReactAxisGantt));
1511
- ReactTimeline.prototype._class += " timeline_ReactTimeline";
1512
- ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1513
- ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1433
+ var ReactTimeline = /** @class */ (function (_super) {
1434
+ __extends(ReactTimeline, _super);
1435
+ function ReactTimeline() {
1436
+ var _this = _super.call(this) || this;
1437
+ _this._drawStartPos = "origin";
1438
+ _this._topAxis.type("time");
1439
+ _this._bottomAxis.type("time");
1440
+ _this.tooltipHTML(function (d) {
1441
+ var parser = common.timeParse("%Q");
1442
+ var startTime = parser(d[1]);
1443
+ var endTime = parser(d[2]);
1444
+ var formatter = common.timeFormat(_this.tooltipTimeFormat());
1445
+ return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1446
+ });
1447
+ return _this;
1448
+ }
1449
+ ReactTimeline.prototype.update = function (domNode, element) {
1450
+ _super.prototype.update.call(this, domNode, element);
1451
+ if (this.timePattern_exists()) {
1452
+ var minTimestamp_1 = Infinity;
1453
+ var maxTimestamp_1 = -Infinity;
1454
+ var lowDateStr_1 = "";
1455
+ var highDateStr_1 = "";
1456
+ this.data().map(function (n) {
1457
+ var start = new Date(n[1]).getTime();
1458
+ var end = new Date(n[2]).getTime();
1459
+ if (minTimestamp_1 > start) {
1460
+ minTimestamp_1 = start;
1461
+ lowDateStr_1 = "" + n[1];
1462
+ }
1463
+ if (maxTimestamp_1 < end) {
1464
+ maxTimestamp_1 = end;
1465
+ highDateStr_1 = "" + n[2];
1466
+ }
1467
+ });
1468
+ this._topAxis
1469
+ .type("time")
1470
+ .timePattern(this.timePattern())
1471
+ .overlapMode("none")
1472
+ .tickFormat(this._axisLabelFormatter)
1473
+ .low(lowDateStr_1)
1474
+ .high(highDateStr_1);
1475
+ this._bottomAxis
1476
+ .type("time")
1477
+ .timePattern(this.timePattern())
1478
+ .overlapMode("none")
1479
+ .tickFormat(this._axisLabelFormatter)
1480
+ .low(lowDateStr_1)
1481
+ .high(highDateStr_1);
1482
+ this._gantt._minStart = minTimestamp_1;
1483
+ this._gantt._maxEnd = maxTimestamp_1;
1484
+ }
1485
+ };
1486
+ ReactTimeline.prototype.tooltipHTML = function (callback) {
1487
+ this._tooltipHTML = callback;
1488
+ this.tooltip().tooltipHTML(this._tooltipHTML);
1489
+ return this;
1490
+ };
1491
+ ReactTimeline.prototype.parseAxisValue = function (v) {
1492
+ var parseTime = common.timeParse("%Q");
1493
+ var parsedTime = parseTime(v);
1494
+ var formatTime = common.timeFormat(this.timePattern());
1495
+ return formatTime(parsedTime);
1496
+ };
1497
+ ReactTimeline.prototype.onzoom = function (transform) {
1498
+ var w = this.width();
1499
+ var low = this._gantt._minStart;
1500
+ var high = this._gantt._maxEnd;
1501
+ var range = high - low;
1502
+ var wpp = range / w;
1503
+ var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1504
+ var nextHigh = Math.ceil((range / transform.k) + nextLow);
1505
+ this._topAxis
1506
+ .low(this.parseAxisValue(nextLow))
1507
+ .high(this.parseAxisValue(nextHigh))
1508
+ .render();
1509
+ this._bottomAxis
1510
+ .low(this.parseAxisValue(nextLow))
1511
+ .high(this.parseAxisValue(nextHigh))
1512
+ .render();
1513
+ };
1514
+ return ReactTimeline;
1515
+ }(ReactAxisGantt));
1516
+ ReactTimeline.prototype._class += " timeline_ReactTimeline";
1517
+ ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1518
+ ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1514
1519
 
1515
- var parseTime = common.timeParse("%Q");
1516
- var ReactTimelineSeries = /** @class */ (function (_super) {
1517
- __extends(ReactTimelineSeries, _super);
1518
- function ReactTimelineSeries() {
1519
- var _this = _super.call(this) || this;
1520
- _this._topAxis.type("time");
1521
- _this._bottomAxis.type("time");
1522
- _this.tooltipHTML(function (d) {
1523
- var startTime = parseTime(d[1]);
1524
- var endTime = parseTime(d[2]);
1525
- var formatter = common.timeFormat(_this.tooltipTimeFormat());
1526
- return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1527
- });
1528
- return _this;
1529
- }
1530
- ReactTimelineSeries.prototype.update = function (domNode, element) {
1531
- _super.prototype.update.call(this, domNode, element);
1532
- if (this.timePattern_exists()) {
1533
- var minTimestamp_1 = Infinity;
1534
- var maxTimestamp_1 = -Infinity;
1535
- var lowDateStr_1 = "";
1536
- var highDateStr_1 = "";
1537
- this.data().forEach(function (n) {
1538
- var start = new Date(n[1]).getTime();
1539
- var end = new Date(n[2]).getTime();
1540
- if (minTimestamp_1 > start) {
1541
- minTimestamp_1 = start;
1542
- lowDateStr_1 = "" + n[1];
1543
- }
1544
- if (maxTimestamp_1 < end) {
1545
- maxTimestamp_1 = end;
1546
- highDateStr_1 = "" + n[2];
1547
- }
1548
- });
1549
- this._topAxis
1550
- .type("time")
1551
- .timePattern(this.timePattern())
1552
- .overlapMode("none")
1553
- .tickFormat(this._axisLabelFormatter)
1554
- .low(lowDateStr_1)
1555
- .high(highDateStr_1);
1556
- this._bottomAxis
1557
- .type("time")
1558
- .timePattern(this.timePattern())
1559
- .overlapMode("none")
1560
- .tickFormat(this._axisLabelFormatter)
1561
- .low(lowDateStr_1)
1562
- .high(highDateStr_1);
1563
- this._gantt._minStart = minTimestamp_1;
1564
- this._gantt._maxEnd = maxTimestamp_1;
1565
- }
1566
- };
1567
- ReactTimelineSeries.prototype.tooltipHTML = function (callback) {
1568
- this._tooltipHTML = callback;
1569
- this.tooltip().tooltipHTML(this._tooltipHTML);
1570
- return this;
1571
- };
1572
- ReactTimelineSeries.prototype.parseAxisValue = function (v) {
1573
- var parsedTime = parseTime(v);
1574
- var formatTime = common.timeFormat(this.timePattern());
1575
- return formatTime(parsedTime);
1576
- };
1577
- ReactTimelineSeries.prototype.onzoom = function (transform) {
1578
- var w = this.width();
1579
- var low = this._gantt._minStart;
1580
- var high = this._gantt._maxEnd;
1581
- var range = high - low;
1582
- var wpp = range / w;
1583
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1584
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1585
- this._topAxis
1586
- .low(this.parseAxisValue(nextLow))
1587
- .high(this.parseAxisValue(nextHigh))
1588
- .render();
1589
- this._bottomAxis
1590
- .low(this.parseAxisValue(nextLow))
1591
- .high(this.parseAxisValue(nextHigh))
1592
- .render();
1593
- };
1594
- return ReactTimelineSeries;
1595
- }(ReactAxisGanttSeries));
1596
- ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
1597
- ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1598
- ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1520
+ var parseTime = common.timeParse("%Q");
1521
+ var ReactTimelineSeries = /** @class */ (function (_super) {
1522
+ __extends(ReactTimelineSeries, _super);
1523
+ function ReactTimelineSeries() {
1524
+ var _this = _super.call(this) || this;
1525
+ _this._topAxis.type("time");
1526
+ _this._bottomAxis.type("time");
1527
+ _this.tooltipHTML(function (d) {
1528
+ var startTime = parseTime(d[1]);
1529
+ var endTime = parseTime(d[2]);
1530
+ var formatter = common.timeFormat(_this.tooltipTimeFormat());
1531
+ return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1532
+ });
1533
+ return _this;
1534
+ }
1535
+ ReactTimelineSeries.prototype.update = function (domNode, element) {
1536
+ _super.prototype.update.call(this, domNode, element);
1537
+ if (this.timePattern_exists()) {
1538
+ var minTimestamp_1 = Infinity;
1539
+ var maxTimestamp_1 = -Infinity;
1540
+ var lowDateStr_1 = "";
1541
+ var highDateStr_1 = "";
1542
+ this.data().forEach(function (n) {
1543
+ var start = new Date(n[1]).getTime();
1544
+ var end = new Date(n[2]).getTime();
1545
+ if (minTimestamp_1 > start) {
1546
+ minTimestamp_1 = start;
1547
+ lowDateStr_1 = "" + n[1];
1548
+ }
1549
+ if (maxTimestamp_1 < end) {
1550
+ maxTimestamp_1 = end;
1551
+ highDateStr_1 = "" + n[2];
1552
+ }
1553
+ });
1554
+ this._topAxis
1555
+ .type("time")
1556
+ .timePattern(this.timePattern())
1557
+ .overlapMode("none")
1558
+ .tickFormat(this._axisLabelFormatter)
1559
+ .low(lowDateStr_1)
1560
+ .high(highDateStr_1);
1561
+ this._bottomAxis
1562
+ .type("time")
1563
+ .timePattern(this.timePattern())
1564
+ .overlapMode("none")
1565
+ .tickFormat(this._axisLabelFormatter)
1566
+ .low(lowDateStr_1)
1567
+ .high(highDateStr_1);
1568
+ this._gantt._minStart = minTimestamp_1;
1569
+ this._gantt._maxEnd = maxTimestamp_1;
1570
+ }
1571
+ };
1572
+ ReactTimelineSeries.prototype.tooltipHTML = function (callback) {
1573
+ this._tooltipHTML = callback;
1574
+ this.tooltip().tooltipHTML(this._tooltipHTML);
1575
+ return this;
1576
+ };
1577
+ ReactTimelineSeries.prototype.parseAxisValue = function (v) {
1578
+ var parsedTime = parseTime(v);
1579
+ var formatTime = common.timeFormat(this.timePattern());
1580
+ return formatTime(parsedTime);
1581
+ };
1582
+ ReactTimelineSeries.prototype.onzoom = function (transform) {
1583
+ var w = this.width();
1584
+ var low = this._gantt._minStart;
1585
+ var high = this._gantt._maxEnd;
1586
+ var range = high - low;
1587
+ var wpp = range / w;
1588
+ var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1589
+ var nextHigh = Math.ceil((range / transform.k) + nextLow);
1590
+ this._topAxis
1591
+ .low(this.parseAxisValue(nextLow))
1592
+ .high(this.parseAxisValue(nextHigh))
1593
+ .render();
1594
+ this._bottomAxis
1595
+ .low(this.parseAxisValue(nextLow))
1596
+ .high(this.parseAxisValue(nextHigh))
1597
+ .render();
1598
+ };
1599
+ return ReactTimelineSeries;
1600
+ }(ReactAxisGanttSeries));
1601
+ ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
1602
+ ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1603
+ ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1599
1604
 
1600
- exports.BUILD_VERSION = BUILD_VERSION;
1601
- exports.MiniGantt = MiniGantt;
1602
- exports.PKG_NAME = PKG_NAME;
1603
- exports.PKG_VERSION = PKG_VERSION;
1604
- exports.ReactAxisGantt = ReactAxisGantt;
1605
- exports.ReactAxisGanttSeries = ReactAxisGanttSeries;
1606
- exports.ReactGantt = ReactGantt;
1607
- exports.ReactTimeline = ReactTimeline;
1608
- exports.ReactTimelineSeries = ReactTimelineSeries;
1605
+ exports.BUILD_VERSION = BUILD_VERSION;
1606
+ exports.MiniGantt = MiniGantt;
1607
+ exports.PKG_NAME = PKG_NAME;
1608
+ exports.PKG_VERSION = PKG_VERSION;
1609
+ exports.ReactAxisGantt = ReactAxisGantt;
1610
+ exports.ReactAxisGanttSeries = ReactAxisGanttSeries;
1611
+ exports.ReactGantt = ReactGantt;
1612
+ exports.ReactTimeline = ReactTimeline;
1613
+ exports.ReactTimelineSeries = ReactTimelineSeries;
1609
1614
 
1610
- Object.defineProperty(exports, '__esModule', { value: true });
1615
+ Object.defineProperty(exports, '__esModule', { value: true });
1611
1616
 
1612
1617
  }));
1613
1618
  //# sourceMappingURL=index.js.map