@hpcc-js/timeline 2.56.0 → 2.57.0

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