@hpcc-js/timeline 2.54.0 → 3.0.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 (39) hide show
  1. package/dist/index.js +31 -1633
  2. package/dist/index.js.map +7 -1
  3. package/package.json +34 -37
  4. package/src/MiniGantt.ts +10 -9
  5. package/src/ReactAxisGantt.ts +8 -1
  6. package/src/ReactAxisGanttSeries.ts +2 -2
  7. package/src/ReactGantt.ts +4 -0
  8. package/src/ReactTimeline.ts +10 -10
  9. package/src/ReactTimelineSeries.ts +8 -8
  10. package/src/__package__.ts +2 -2
  11. package/src/index.ts +7 -7
  12. package/types/MiniGantt.d.ts +4 -5
  13. package/types/ReactAxisGantt.d.ts +2 -2
  14. package/types/ReactAxisGanttSeries.d.ts +2 -3
  15. package/types/ReactGantt.d.ts +1 -1
  16. package/types/ReactTimeline.d.ts +2 -3
  17. package/types/ReactTimelineSeries.d.ts +1 -2
  18. package/types/__package__.d.ts +2 -3
  19. package/types/index.d.ts +7 -8
  20. package/dist/index.es6.js +0 -1625
  21. package/dist/index.es6.js.map +0 -1
  22. package/dist/index.min.js +0 -2
  23. package/dist/index.min.js.map +0 -1
  24. package/types/MiniGantt.d.ts.map +0 -1
  25. package/types/ReactAxisGantt.d.ts.map +0 -1
  26. package/types/ReactAxisGanttSeries.d.ts.map +0 -1
  27. package/types/ReactGantt.d.ts.map +0 -1
  28. package/types/ReactTimeline.d.ts.map +0 -1
  29. package/types/ReactTimelineSeries.d.ts.map +0 -1
  30. package/types/__package__.d.ts.map +0 -1
  31. package/types/index.d.ts.map +0 -1
  32. package/types-3.4/MiniGantt.d.ts +0 -106
  33. package/types-3.4/ReactAxisGantt.d.ts +0 -83
  34. package/types-3.4/ReactAxisGanttSeries.d.ts +0 -82
  35. package/types-3.4/ReactGantt.d.ts +0 -135
  36. package/types-3.4/ReactTimeline.d.ts +0 -18
  37. package/types-3.4/ReactTimelineSeries.d.ts +0 -18
  38. package/types-3.4/__package__.d.ts +0 -4
  39. package/types-3.4/index.d.ts +0 -8
package/dist/index.js CHANGED
@@ -1,1634 +1,32 @@
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"]));
5
- })(this, (function (exports, api, chart, common, html, react, layout) { 'use strict';
6
-
7
- var PKG_NAME = "@hpcc-js/timeline";
8
- var PKG_VERSION = "2.54.0";
9
- var BUILD_VERSION = "2.107.0";
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, SuppressedError, Symbol, Iterator */
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
- }
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 (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);
81
- } else {
82
- head.appendChild(style);
83
- }
84
- } else {
85
- head.appendChild(style);
86
- }
87
-
88
- if (style.styleSheet) {
89
- style.styleSheet.cssText = css;
90
- } else {
91
- style.appendChild(document.createTextNode(css));
92
- }
93
- }
94
-
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);
97
-
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");
571
-
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.selection = function (_) {
610
- if (!arguments.length)
611
- return this._selection.get();
612
- this._selection.set(_);
613
- return this;
614
- };
615
- ReactGantt.prototype.rangeRenderer = function (_) {
616
- if (!arguments.length)
617
- return this._rangeRenderer;
618
- this._rangeRenderer = _;
619
- return this._rangeRenderer;
620
- };
621
- ReactGantt.prototype.enter = function (domNode, element) {
622
- _super.prototype.enter.call(this, domNode, element);
623
- var context = this;
624
- element
625
- .on("click", function (d) {
626
- context._selection.clear();
627
- });
628
- this._tooltip.target(domNode);
629
- };
630
- ReactGantt.prototype.update = function (domNode, element) {
631
- var _this = this;
632
- _super.prototype.update.call(this, domNode, element);
633
- this.zoomExtent([0.05, this.maxZoom()]);
634
- this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
635
- this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
636
- this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
637
- this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
638
- this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
639
- this._series_idx = this.seriesColumn() !== null ? this.columns().indexOf(this.seriesColumn()) : this._series_idx;
640
- this._bucket_idx = this.bucketColumn() !== null ? this.columns().indexOf(this.bucketColumn()) : -1;
641
- var context = this;
642
- var w = this.width();
643
- var x0 = 0;
644
- var x1 = w;
645
- this._interpolateX = common.scaleLinear()
646
- .domain([this._minStart, this._maxEnd])
647
- .range([x0, x1]);
648
- this.data().sort(function (a, b) { return a[1] - b[1]; });
649
- if (this._series_idx > -1) {
650
- this._origIdxMap = {};
651
- this._dataBySeries = {};
652
- this._bucketsBySeries = {};
653
- this.data().forEach(function (dataRow, origIdx) {
654
- var seriesKey = dataRow[_this._series_idx];
655
- if (!_this._dataBySeries[seriesKey]) {
656
- _this._origIdxMap[seriesKey] = {};
657
- _this._dataBySeries[seriesKey] = [];
658
- }
659
- _this._dataBySeries[seriesKey].push({
660
- dataRow: dataRow,
661
- origIdx: origIdx
662
- });
663
- });
664
- var gutter_1 = this.gutter();
665
- var bucketOffset_1 = 0;
666
- var seriesKeys = Object.keys(this._dataBySeries);
667
- seriesKeys.forEach(function (seriesKey) {
668
- _this._dataBySeries[seriesKey].sort(function (a, b) { return a.dataRow[1] - b.dataRow[1]; });
669
- _this._bucketsBySeries[seriesKey] = _this.calcBuckets(_this._dataBySeries[seriesKey].map(function (n) { return n.dataRow; }), 1, 2);
670
- _this._bucketsBySeries[seriesKey].bucketHeight = _this.bucketHeight();
671
- _this._bucketsBySeries[seriesKey].bucketOffset = bucketOffset_1;
672
- bucketOffset_1 += (_this._bucketsBySeries[seriesKey].bucketHeight + _this.strokeWidth() + _this.gutter()) * (_this._bucketsBySeries[seriesKey].maxBucket + 1);
673
- _this._dataBySeries[seriesKey].forEach(function (n, i) {
674
- _this._origIdxMap[seriesKey][n.origIdx] = i;
675
- });
676
- });
677
- this._seriesBackgrounds = this._renderElement.selectAll(".series-background")
678
- .data(seriesKeys.map(function (key) {
679
- return _this._bucketsBySeries[key];
680
- }));
681
- this._seriesBackgrounds
682
- .join(function (enter) { return enter.append("rect")
683
- .attr("class", "series-background"); }, function (update) { return update; }, function (exit) { return exit
684
- .each(function (d) {
685
- delete d.element;
686
- })
687
- .remove(); })
688
- .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
689
- .each(function (d, i) {
690
- common.select(this)
691
- .attr("x", 0)
692
- .attr("y", d.bucketOffset - (gutter_1 / 2))
693
- .attr("width", w)
694
- .attr("height", ((d.bucketHeight + gutter_1) * (d.maxBucket + 1)) + gutter_1)
695
- .attr("fill", i % 2 ? context.oddSeriesBackground() : context.evenSeriesBackground());
696
- });
697
- }
698
- else {
699
- if (this._bucket_idx !== -1) {
700
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx, this._bucket_idx);
701
- }
702
- else {
703
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx);
704
- }
705
- }
706
- var interpedStart = this._interpolateX(this._minStart);
707
- this.zoomTo([interpedStart, 0], 1);
708
- var bucketHeight = this.bucketHeight();
709
- this.setRangeOptions();
710
- this._maxFontScale = (bucketHeight - (this.rangePadding() * 2));
711
- this.measureDataText();
712
- var itemSelection = this._renderElement.selectAll(".item")
713
- .data(this.data());
714
- var borderOffset1 = this.strokeWidth();
715
- var borderOffset2 = borderOffset1 * 2;
716
- itemSelection
717
- .join(function (enter) { return enter.append("g")
718
- .attr("class", "item")
719
- .on("click.selectionBag", function (d, i) {
720
- var _id = d.id === undefined ? i : d.id;
721
- if (context._selection.isSelected({ _id: _id, element: d.element })) {
722
- context._selection.clear();
723
- }
724
- else {
725
- context._selection.click({
726
- _id: _id,
727
- element: function () { return d.element; }
728
- }, common.d3Event);
729
- }
730
- context.selectionChanged();
731
- common.d3Event().stopPropagation();
732
- })
733
- .on("click", function (d) {
734
- var selected = d.element.classed("selected");
735
- if (d[context.columns().length]) {
736
- d.__lparam = d[context.columns().length];
737
- }
738
- context.click(d, "", selected);
739
- })
740
- .on("dblclick", function (d) {
741
- var selected = d.element.classed("selected");
742
- if (d[context.columns().length]) {
743
- d.__lparam = d[context.columns().length];
744
- }
745
- context.click(d, "", selected);
746
- })
747
- .on("mousein", function (d) {
748
- context.highlightItem(common.select(this), d);
749
- var selected = d.element.classed("selected");
750
- context.mousein(d, "", selected);
751
- })
752
- .on("mouseover", function (d) {
753
- var d3evt = common.d3Event();
754
- context._tooltip._triggerElement = d.element;
755
- context._tooltip._cursorLoc = [
756
- d3evt.clientX,
757
- d3evt.clientY
758
- ];
759
- context._tooltip
760
- .data(d)
761
- .visible(true)
762
- .fitContent(true)
763
- .render();
764
- context.highlightItem(common.select(this), d);
765
- var selected = d.element.classed("selected");
766
- context.mouseover(d, "", selected);
767
- })
768
- .on("mouseout", function (d) {
769
- context._tooltip
770
- .visible(false)
771
- .render();
772
- context.highlightItem(null, null);
773
- var selected = d.element.classed("selected");
774
- context.mouseout(d, "", selected);
775
- })
776
- .each(function (d, i) {
777
- d.that = this;
778
- d.element = common.select(this);
779
- d.x = context._interpolateX(d[1]);
780
- var endX = context._interpolateX(d[2]);
781
- if (context._series_idx > -1) {
782
- var seriesKey = d[context._series_idx];
783
- var bucket = context._bucketsBySeries[seriesKey].bucketMap[context._origIdxMap[seriesKey][i]];
784
- d.y = context._bucketsBySeries[seriesKey].interpolateY(bucket) + context._bucketsBySeries[seriesKey].bucketOffset;
785
- }
786
- else {
787
- var _i = context._bucket_idx === -1 ? i : d[context._bucket_idx];
788
- d.y = context._buckets.interpolateY(context._buckets.bucketMap[_i]);
789
- }
790
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
791
- d.props.width = endX - d.x;
792
- d.props.height = bucketHeight;
793
- d.x += borderOffset1;
794
- d.y += borderOffset1;
795
- d.props.width -= borderOffset2;
796
- d.props.height -= borderOffset2;
797
- d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
798
- }); }, function (update) { return update; }, function (exit) { return exit
799
- .each(function (d) {
800
- delete d.element;
801
- })
802
- .remove(); })
803
- .attr("opacity", function (d) { return d.props && d.props.hidden ? 0 : 1; })
804
- .each(function (d, i) {
805
- d.that = this;
806
- if (context._series_idx > -1) {
807
- var seriesKey = d[context._series_idx];
808
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions, seriesKey);
809
- }
810
- else {
811
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions);
812
- }
813
- })
814
- .on("dblclick.zoom", function (d) {
815
- var x1 = _this._interpolateX(d[1]);
816
- var x2 = _this._interpolateX(d[2]);
817
- var xRange = x2 - x1;
818
- var xScale = w / xRange;
819
- _this.zoomTo([
820
- -x1 * xScale,
821
- 0
822
- ], xScale);
823
- });
824
- element.on("dblclick.zoom", null);
825
- };
826
- ReactGantt.prototype.renderRangeElement = function (d, i, transformEach, options, seriesKey) {
827
- if (transformEach === void 0) { transformEach = false; }
828
- if (options === void 0) { options = {}; }
829
- var borderOffset1 = options.strokeWidth;
830
- var borderOffset2 = borderOffset1 * 2;
831
- var padding = options.rangePadding;
832
- var endX;
833
- var x = isNaN(this._transform.x) ? 0 : this._transform.x;
834
- var k = isNaN(this._transform.k) ? 1 : this._transform.k;
835
- var b;
836
- var bucketHeight = this.bucketHeight();
837
- d.that.setAttribute("data-series", seriesKey);
838
- if (this._color_idx > -1) {
839
- d.that.setAttribute("data-color", d[this._color_idx]);
840
- }
841
- if (seriesKey !== undefined) {
842
- b = this._bucketsBySeries[seriesKey].bucketMap[this._origIdxMap[seriesKey][i]];
843
- d.that.setAttribute("data-b", b);
844
- d.that.setAttribute("data-bucketOffset", this._bucketsBySeries[seriesKey].bucketOffset);
845
- d.y = this._bucketsBySeries[seriesKey].interpolateY(b) + this._bucketsBySeries[seriesKey].bucketOffset;
846
- d.that.setAttribute("data-dy", d.y);
847
- }
848
- else {
849
- b = this._buckets.bucketMap[i];
850
- d.y = this._buckets.interpolateY(b);
851
- }
852
- if (this._color_idx > -1) {
853
- options.fill = d[this._color_idx];
854
- }
855
- if (!transformEach) {
856
- d.x = this._interpolateX(d[1]);
857
- endX = this._interpolateX(d[2]);
858
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
859
- d.props.width = (endX - d.x) / k;
860
- }
861
- else {
862
- d.x = this._interpolateX(d[1]) * k;
863
- endX = this._interpolateX(d[2]) * k;
864
- d.props = __assign(__assign({}, d[3]), { text: d[0] });
865
- d.props.width = (endX - d.x) / k;
866
- d.x += x;
867
- d.props.width *= k;
868
- }
869
- d.props.height = bucketHeight;
870
- if (seriesKey === undefined && this._buckets.bucketScale < 1) {
871
- d.props.height = this._buckets.bucketScale * bucketHeight;
872
- }
873
- if (d.element === undefined && d.that) {
874
- d.element = common.select(d.that);
875
- }
876
- d.element.attr("transform", "translate(".concat(d.x + (d.props.width / 2), " ").concat(d.y + (d.props.height / 2), ")"));
877
- d.x += borderOffset1;
878
- d.y += borderOffset1;
879
- d.props.width -= borderOffset2;
880
- d.props.height -= borderOffset2;
881
- d.props.width = d.props.width < 1 ? 1 : d.props.width;
882
- d.props.height = d.props.height < 1 ? 1 : d.props.height;
883
- var text = this.truncateText(d.props.text, d.props.width - padding, this._maxFontScale);
884
- if (text !== d.props.text) {
885
- text = this.truncateText(d.props.text, d.props.width - padding);
886
- }
887
- else {
888
- d.props.fontSize = this._maxFontScale * options.fontSize;
889
- }
890
- if (seriesKey === undefined && this._buckets.bucketScale < 1) {
891
- d.props.fontSize = Math.min(this._maxFontScale, this._buckets.bucketScale) * options.fontSize;
892
- }
893
- if (!this._maxY || this._maxY < d.y + d.props.height) {
894
- this._maxY = d.y + d.props.height;
895
- }
896
- if (!this._maxX || this._maxX < d.x + d.props.width) {
897
- this._maxX = d.x + d.props.width;
898
- }
899
- react.render(this._rangeRenderer, __assign(__assign(__assign({}, options), d.props), { text: text }), d.that);
900
- };
901
- ReactGantt.prototype.setRangeOptions = function () {
902
- this._rangeOptions = {
903
- rangePadding: this.rangePadding(),
904
- fontFamily: this.fontFamily(),
905
- fontSize: this.fontSize(),
906
- strokeWidth: this.strokeWidth(),
907
- fill: this.fill(),
908
- stroke: this.stroke(),
909
- textFill: this.rangeFontColor(),
910
- cornerRadius: this.cornerRadius(),
911
- };
912
- };
913
- ReactGantt.prototype.zoomed = function (transform) {
914
- var _this = this;
915
- this._transform = transform;
916
- switch (this.renderMode()) {
917
- case "scale-all":
918
- this._zoomScale = transform.k;
919
- this._zoomTranslate = [transform.x, 0];
920
- this._zoomG.attr("transform", "translate(".concat(transform.x, " ").concat(0, ")scale(").concat(transform.k, " 1)"));
921
- break;
922
- default:
923
- var options_1 = this._rangeOptions;
924
- this.data().forEach(function (d, i) {
925
- if (_this._color_idx > -1) {
926
- options_1.fill = d[_this._color_idx];
927
- }
928
- if (_this._series_idx > -1) {
929
- var seriesKey = d[_this._series_idx];
930
- _this.renderRangeElement(d, i, true, options_1, seriesKey);
931
- }
932
- else {
933
- _this.renderRangeElement(d, i, true, options_1);
934
- }
935
- });
936
- }
937
- this.zoomedHook(transform);
938
- };
939
- ReactGantt.prototype.zoomedHook = function (transform) {
940
- };
941
- ReactGantt.prototype.calcBuckets = function (data, startKey, endKey, bucketKey) {
942
- var bucketMap = {};
943
- var bucketKeyMap = {};
944
- var tol = this.overlapTolerence();
945
- var buckets = [{ end: -Infinity }];
946
- var maxBucket = 0;
947
- if (bucketKey !== undefined) {
948
- data.forEach(function (d, i) {
949
- bucketMap[i] = d[bucketKey];
950
- bucketKeyMap[d[bucketKey]] = true;
951
- });
952
- maxBucket = Object.keys(bucketKeyMap).length;
953
- }
954
- else {
955
- data.forEach(function (d, i) {
956
- for (var i2 = 0; i2 < buckets.length; ++i2) {
957
- if (i === 0 || buckets[i2][endKey] + tol <= d[startKey]) {
958
- bucketMap[i] = i2;
959
- if (maxBucket < i2)
960
- maxBucket = i2;
961
- buckets[i2][endKey] = d[endKey];
962
- break;
963
- }
964
- }
965
- if (bucketMap[i] === undefined) {
966
- bucketMap[i] = buckets.length;
967
- var b = {};
968
- b[endKey] = d[endKey];
969
- buckets.push(b);
970
- }
971
- if (maxBucket < bucketMap[i])
972
- maxBucket = bucketMap[i];
973
- });
974
- }
975
- var height = (maxBucket + 1) * (this.bucketHeight() + this.gutter());
976
- return {
977
- bucketMap: bucketMap,
978
- maxBucket: maxBucket,
979
- bucketScale: this.height() / height,
980
- interpolateY: common.scaleLinear()
981
- .domain([0, maxBucket + 1])
982
- .range([0, Math.min(this.height(), height)])
983
- };
984
- };
985
- ReactGantt.prototype.data = function (_) {
986
- var _a, _b;
987
- var retVal = _super.prototype.data.apply(this, arguments);
988
- if (arguments.length > 0) {
989
- this._minStart = (_a = Math.min.apply(Math, this.data().map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
990
- this._maxEnd = (_b = Math.max.apply(Math, this.data().map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
991
- this.measureDataText(true);
992
- }
993
- return retVal;
994
- };
995
- ReactGantt.prototype.measureDataText = function (forceMeasure) {
996
- if (forceMeasure === void 0) { forceMeasure = false; }
997
- var textWidths = {};
998
- var characterWidths = {};
999
- var fontFamily = this.fontFamily();
1000
- var fontSize = this.fontSize();
1001
- var bucketHeight = this.bucketHeight();
1002
- if (bucketHeight) {
1003
- this._maxFontScale = (bucketHeight - (this.rangePadding() * 2)) / fontSize;
1004
- }
1005
- if (forceMeasure || this._prevFontFamily !== fontFamily || this._prevFontSize !== fontSize) {
1006
- characterWidths["."] = common.Utility.textSize(".", fontFamily, fontSize).width;
1007
- this.data().forEach(function (d) {
1008
- if (!textWidths[d[0]]) {
1009
- textWidths[d[0]] = common.Utility.textSize(d[0], fontFamily, fontSize).width;
1010
- }
1011
- d[0].split("").forEach(function (char) {
1012
- if (!characterWidths[char]) {
1013
- characterWidths[char] = common.Utility.textSize(char, fontFamily, fontSize).width;
1014
- }
1015
- });
1016
- });
1017
- this._textWidths = textWidths;
1018
- this._characterWidths = characterWidths;
1019
- }
1020
- this._prevFontFamily = fontFamily;
1021
- this._prevFontSize = fontSize;
1022
- };
1023
- ReactGantt.prototype.truncateText = function (text, width, scale) {
1024
- if (scale === void 0) { scale = 1; }
1025
- var textFits = this._textWidths[text] * scale < width;
1026
- if (textFits) {
1027
- return text;
1028
- }
1029
- var ret = "";
1030
- var sum = 0;
1031
- var _width = width - (this._characterWidths["."] * 3);
1032
- for (var _a = 0, text_1 = text; _a < text_1.length; _a++) {
1033
- var char = text_1[_a];
1034
- sum += this._characterWidths[char];
1035
- if (sum < _width) {
1036
- ret += char;
1037
- }
1038
- else {
1039
- break;
1040
- }
1041
- }
1042
- return _width < 0 ? "" : ret + "...";
1043
- };
1044
- ReactGantt.prototype.resize = function (_size) {
1045
- var retVal;
1046
- if (this.fitWidthToContent() || this.fitHeightToContent()) {
1047
- retVal = _super.prototype.resize.call(this, {
1048
- width: _size.width,
1049
- height: this._maxY
1050
- });
1051
- }
1052
- else {
1053
- retVal = _super.prototype.resize.apply(this, arguments);
1054
- }
1055
- return retVal;
1056
- };
1057
- ReactGantt.prototype.selectionChanged = function () {
1058
- };
1059
- ReactGantt.prototype.highlightItem = function (_element, d) {
1060
- };
1061
- ReactGantt.prototype.click = function (row, _col, sel) {
1062
- };
1063
- ReactGantt.prototype.dblclick = function (row, _col, sel) {
1064
- };
1065
- ReactGantt.prototype.mousein = function (row, _col, sel) {
1066
- };
1067
- ReactGantt.prototype.mouseover = function (row, _col, sel) {
1068
- };
1069
- ReactGantt.prototype.mouseout = function (row, _col, sel) {
1070
- };
1071
- return ReactGantt;
1072
- }(common.SVGZoomWidget));
1073
- ReactGantt.prototype._class += " timeline_ReactGantt";
1074
- ReactGantt.prototype.publish("fitWidthToContent", false, "boolean", "If true, resize will simply reapply the bounding box width");
1075
- ReactGantt.prototype.publish("fitHeightToContent", false, "boolean", "If true, resize will simply reapply the bounding box height");
1076
- ReactGantt.prototype.publish("titleColumn", null, "string", "Column name to for the title");
1077
- ReactGantt.prototype.publish("startDateColumn", null, "string", "Column name to for the start date");
1078
- ReactGantt.prototype.publish("endDateColumn", null, "string", "Column name to for the end date");
1079
- ReactGantt.prototype.publish("iconColumn", null, "string", "Column name to for the icon");
1080
- ReactGantt.prototype.publish("colorColumn", null, "string", "Column name to for the color");
1081
- ReactGantt.prototype.publish("seriesColumn", null, "string", "Column name to for the series identifier");
1082
- ReactGantt.prototype.publish("bucketColumn", null, "string", "Column name to for the bucket identifier");
1083
- ReactGantt.prototype.publish("renderMode", "default", "set", "Render modes vary in features and performance", ["default", "scale-all"]);
1084
- ReactGantt.prototype.publish("rangePadding", 3, "number", "Padding within each range rectangle (pixels)");
1085
- ReactGantt.prototype.publish("fill", "#1f77b4", "string", "Background color of range rectangle");
1086
- ReactGantt.prototype.publish("stroke", null, "string", "Color of range rectangle border");
1087
- ReactGantt.prototype.publish("strokeWidth", null, "number", "Width of range rectangle border (pixels)");
1088
- ReactGantt.prototype.publish("cornerRadius", 3, "number", "Space between range buckets (pixels)");
1089
- ReactGantt.prototype.publish("fontFamily", null, "string", "Font family within range rectangle", null, { optional: true });
1090
- ReactGantt.prototype.publish("fontSize", 10, "number", "Size of font within range rectangle (pixels)");
1091
- ReactGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
1092
- ReactGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1093
- ReactGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1094
- ReactGantt.prototype.publish("bucketHeight", 100, "number", "Max height of range element (pixels)");
1095
- ReactGantt.prototype.publish("gutter", 2, "number", "Space between range buckets (pixels)");
1096
- ReactGantt.prototype.publish("maxZoom", 16, "number", "Maximum zoom");
1097
- ReactGantt.prototype.publish("evenSeriesBackground", "#FFFFFF", "html-color", "Background color of even series rows");
1098
- ReactGantt.prototype.publish("oddSeriesBackground", "#DDDDDD", "html-color", "Background color of odd series rows");
1099
-
1100
- var ReactAxisGantt = /** @class */ (function (_super) {
1101
- __extends(ReactAxisGantt, _super);
1102
- function ReactAxisGantt() {
1103
- var _this = _super.call(this) || this;
1104
- _this._topAxis = new chart.Axis("center")
1105
- .orientation("top")
1106
- .type("linear")
1107
- .shrinkToFit("none")
1108
- .overlapMode("hide")
1109
- .extend(0)
1110
- .tickFormat("d");
1111
- _this._gantt = new ReactGantt("center")
1112
- .stroke("#000000");
1113
- _this._bottomAxis = new chart.Axis("center")
1114
- .orientation("bottom")
1115
- .type("linear")
1116
- .shrinkToFit("none")
1117
- .overlapMode("hide")
1118
- .extend(0)
1119
- .tickFormat("d");
1120
- _this._drawStartPos = "origin";
1121
- _this.rangeRenderer = function () {
1122
- var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1123
- if (!arguments.length)
1124
- return ret;
1125
- return this;
1126
- };
1127
- return _this;
1128
- }
1129
- ReactAxisGantt.prototype.selection = function (_) {
1130
- if (!arguments.length)
1131
- return this._gantt.selection();
1132
- this._gantt.selection(_);
1133
- return this;
1134
- };
1135
- ReactAxisGantt.prototype.resizeWrappers = function () {
1136
- var w = this.width();
1137
- var h = this.height();
1138
- var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1139
- var contentHeight = (h - (axisHeight * 2));
1140
- var borderOffset1 = this.strokeWidth();
1141
- this._topRect
1142
- .attr("height", axisHeight)
1143
- .attr("width", w)
1144
- .attr("fill", "transparent");
1145
- this._topAxisElement.attr("transform", "translate(0 0)");
1146
- this._topAxis.resize({ height: axisHeight, width: w });
1147
- this._contentRect
1148
- .attr("height", contentHeight)
1149
- .attr("width", w)
1150
- .attr("fill", "transparent");
1151
- this._contentElement.attr("transform", "translate(0 ".concat(axisHeight + borderOffset1, ")"));
1152
- this._gantt.resize({ height: contentHeight, width: w });
1153
- this._bottomRect
1154
- .attr("height", axisHeight)
1155
- .attr("width", w)
1156
- .attr("fill", "transparent");
1157
- this._bottomAxisElement.attr("transform", "translate(0 ".concat(axisHeight + contentHeight + borderOffset1, ")"));
1158
- this._bottomAxis.resize({ height: axisHeight, width: w });
1159
- };
1160
- ReactAxisGantt.prototype.enter = function (domNode, element) {
1161
- var _this = this;
1162
- _super.prototype.enter.call(this, domNode, element);
1163
- this._gantt.click = function (row, col, sel) {
1164
- _this.click(row, col, sel);
1165
- };
1166
- this._gantt.dblclick = function (row, col, sel) {
1167
- _this.dblclick(row, col, sel);
1168
- };
1169
- this._topAxisElement = element.append("g")
1170
- .attr("class", "top-axis-wrapper");
1171
- this._topRect = this._topAxisElement.append("rect")
1172
- .attr("class", "top-axis-rect");
1173
- this._contentElement = element.append("g")
1174
- .attr("class", "content-wrapper");
1175
- this._contentRect = this._contentElement.append("rect")
1176
- .attr("class", "content-rect");
1177
- this._bottomAxisElement = element.append("g")
1178
- .attr("class", "bottom-axis-wrapper");
1179
- this._bottomRect = this._bottomAxisElement.append("rect")
1180
- .attr("class", "top-axis-rect");
1181
- this._topAxis.target(this._topAxisElement.node());
1182
- this._gantt.target(this._contentElement.node()).bucketHeight(30);
1183
- this._bottomAxis.target(this._bottomAxisElement.node());
1184
- this.resizeWrappers();
1185
- this._gantt.zoomedHook = function (transform) {
1186
- _this.onzoom(transform);
1187
- };
1188
- };
1189
- ReactAxisGantt.prototype.onzoom = function (transform) {
1190
- var w = this.width();
1191
- var low = this._gantt._minStart;
1192
- var high = this._gantt._maxEnd;
1193
- var range = high - low;
1194
- var wpp = range / w;
1195
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1196
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1197
- this._topAxis
1198
- .fontFamily(this.axisFontFamily())
1199
- .fontSize(this.axisFontSize())
1200
- .tickLength(this.axisTickLength())
1201
- .low(nextLow)
1202
- .high(nextHigh)
1203
- .render();
1204
- this._bottomAxis
1205
- .fontFamily(this.axisFontFamily())
1206
- .fontSize(this.axisFontSize())
1207
- .tickLength(this.axisTickLength())
1208
- .low(nextLow)
1209
- .high(nextHigh)
1210
- .render();
1211
- };
1212
- ReactAxisGantt.prototype.update = function (domNode, element) {
1213
- _super.prototype.update.call(this, domNode, element);
1214
- this._topAxis.tickFormat(this.tickFormat()).render();
1215
- this._bottomAxis.tickFormat(this.tickFormat()).render();
1216
- this._gantt.render();
1217
- };
1218
- ReactAxisGantt.prototype.columns = function (_) {
1219
- var retVal = _super.prototype.columns.apply(this, arguments);
1220
- if (arguments.length > 0) {
1221
- this._gantt.columns(_);
1222
- }
1223
- return retVal;
1224
- };
1225
- ReactAxisGantt.prototype.data = function (_) {
1226
- var _a, _b;
1227
- var retVal = _super.prototype.data.apply(this, arguments);
1228
- if (arguments.length > 0) {
1229
- var ganttData = this.data().map(function (n) {
1230
- var ret = __spreadArray([], n, true);
1231
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1232
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1233
- return ret;
1234
- });
1235
- this._gantt._minStart = (_a = Math.min.apply(Math, ganttData.map(function (n) { return n[1]; }))) !== null && _a !== void 0 ? _a : 0;
1236
- this._gantt._maxEnd = (_b = Math.max.apply(Math, ganttData.map(function (n) { return n[2]; }))) !== null && _b !== void 0 ? _b : 1;
1237
- this._gantt.data(ganttData);
1238
- }
1239
- return retVal;
1240
- };
1241
- ReactAxisGantt.prototype.resize = function (_size) {
1242
- var retVal = _super.prototype.resize.apply(this, arguments);
1243
- if (this._topAxisElement) {
1244
- this.resizeWrappers();
1245
- }
1246
- return retVal;
1247
- };
1248
- ReactAxisGantt.prototype.click = function (row, col, sel) {
1249
- };
1250
- ReactAxisGantt.prototype.dblclick = function (row, col, sel) {
1251
- };
1252
- ReactAxisGantt.prototype.tooltip = function () {
1253
- return this._gantt._tooltip;
1254
- };
1255
- return ReactAxisGantt;
1256
- }(common.SVGWidget));
1257
- ReactAxisGantt.prototype._class += " timeline_ReactAxisGantt";
1258
- ReactAxisGantt.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1259
- ReactAxisGantt.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1260
- ReactAxisGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1261
- ReactAxisGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1262
- ReactAxisGantt.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1263
- ReactAxisGantt.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1264
- ReactAxisGantt.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1265
- ReactAxisGantt.prototype.publishProxy("gutter", "_gantt");
1266
- ReactAxisGantt.prototype.publishProxy("renderMode", "_gantt");
1267
- ReactAxisGantt.prototype.publishProxy("strokeWidth", "_gantt");
1268
- ReactAxisGantt.prototype.publishProxy("fontSize", "_gantt");
1269
- ReactAxisGantt.prototype.publishProxy("fontFamily", "_gantt");
1270
- ReactAxisGantt.prototype.publishProxy("stroke", "_gantt");
1271
- ReactAxisGantt.prototype.publishProxy("cornerRadius", "_gantt");
1272
- ReactAxisGantt.prototype.publishProxy("titleColumn", "_gantt");
1273
- ReactAxisGantt.prototype.publishProxy("startDateColumn", "_gantt");
1274
- ReactAxisGantt.prototype.publishProxy("endDateColumn", "_gantt");
1275
- ReactAxisGantt.prototype.publishProxy("iconColumn", "_gantt");
1276
- ReactAxisGantt.prototype.publishProxy("colorColumn", "_gantt");
1277
- ReactAxisGantt.prototype.publishProxy("bucketColumn", "_gantt");
1278
- ReactAxisGantt.prototype.publishProxy("maxZoom", "_gantt");
1279
- ReactAxisGantt.prototype.publishProxy("bucketHeight", "_gantt");
1280
-
1281
- var ReactAxisGanttSeries = /** @class */ (function (_super) {
1282
- __extends(ReactAxisGanttSeries, _super);
1283
- function ReactAxisGanttSeries() {
1284
- var _this = _super.call(this) || this;
1285
- _this._topAxis = new chart.Axis("origin")
1286
- .orientation("top")
1287
- .type("linear")
1288
- .shrinkToFit("none")
1289
- .overlapMode("hide")
1290
- .extend(0)
1291
- .tickFormat("d");
1292
- _this._gantt = new ReactGantt("origin")
1293
- .stroke("#000000")
1294
- .fitHeightToContent(true);
1295
- _this._bottomAxis = new chart.Axis("origin")
1296
- .orientation("bottom")
1297
- .type("linear")
1298
- .shrinkToFit("none")
1299
- .overlapMode("hide")
1300
- .extend(0)
1301
- .tickFormat("d");
1302
- _this.centerOverflowX_default("hidden");
1303
- _this.centerOverflowY_default("auto");
1304
- return _this;
1305
- }
1306
- ReactAxisGanttSeries.prototype.selection = function (_) {
1307
- if (!arguments.length)
1308
- return this._gantt.selection();
1309
- this._gantt.selection(_);
1310
- return this;
1311
- };
1312
- ReactAxisGanttSeries.prototype.rangeRenderer = function (_) {
1313
- var ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1314
- if (!arguments.length)
1315
- return ret;
1316
- return this;
1317
- };
1318
- ReactAxisGanttSeries.prototype.resizeWrappers = function () {
1319
- var w = this.width();
1320
- var h = this.height();
1321
- var axisHeight = this.axisHeight(); //TODO: Dynamic scaling to allow for small resolutions?
1322
- var contentHeight = (h - (axisHeight * 2));
1323
- this.bottomHeight(axisHeight);
1324
- this._topWA.resize({
1325
- width: w,
1326
- height: axisHeight
1327
- });
1328
- this._centerWA.resize({
1329
- width: w,
1330
- height: contentHeight
1331
- });
1332
- this._bottomWA.resize({
1333
- width: w,
1334
- height: axisHeight
1335
- });
1336
- this.top().render();
1337
- this.bottom().render();
1338
- this.center().render();
1339
- };
1340
- ReactAxisGanttSeries.prototype.enter = function (domNode, element) {
1341
- var _this = this;
1342
- _super.prototype.enter.call(this, domNode, element);
1343
- this._gantt.click = function (row, col, sel) {
1344
- _this.click(row, col, sel);
1345
- };
1346
- this._gantt.dblclick = function (row, col, sel) {
1347
- _this.dblclick(row, col, sel);
1348
- };
1349
- this.top(this._topAxis);
1350
- this.center(this._gantt);
1351
- this.bottom(this._bottomAxis);
1352
- this.resizeWrappers();
1353
- this._gantt.zoomedHook = function (transform) {
1354
- _this.onzoom(transform);
1355
- };
1356
- };
1357
- ReactAxisGanttSeries.prototype.onzoom = function (transform) {
1358
- var w = this.width();
1359
- var low = this._gantt._minStart;
1360
- var high = this._gantt._maxEnd;
1361
- var range = high - low;
1362
- var wpp = range / w;
1363
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1364
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1365
- this._topAxis
1366
- .fontFamily(this.axisFontFamily())
1367
- .fontSize(this.axisFontSize())
1368
- .tickLength(this.axisTickLength())
1369
- .low(nextLow)
1370
- .high(nextHigh)
1371
- .lazyRender();
1372
- this._bottomAxis
1373
- .fontFamily(this.axisFontFamily())
1374
- .fontSize(this.axisFontSize())
1375
- .tickLength(this.axisTickLength())
1376
- .low(nextLow)
1377
- .high(nextHigh)
1378
- .lazyRender();
1379
- };
1380
- ReactAxisGanttSeries.prototype.update = function (domNode, element) {
1381
- _super.prototype.update.call(this, domNode, element);
1382
- this._topAxis.tickFormat(this.tickFormat()).render();
1383
- this._bottomAxis.tickFormat(this.tickFormat()).render();
1384
- this._gantt.render();
1385
- };
1386
- ReactAxisGanttSeries.prototype.columns = function (_) {
1387
- var retVal = _super.prototype.columns.apply(this, arguments);
1388
- if (arguments.length > 0) {
1389
- this._gantt.columns(_);
1390
- }
1391
- return retVal;
1392
- };
1393
- ReactAxisGanttSeries.prototype.data = function (_) {
1394
- var retVal = _super.prototype.data.apply(this, arguments);
1395
- if (arguments.length > 0) {
1396
- var ganttData = this.data().map(function (n) {
1397
- var ret = __spreadArray([], n, true);
1398
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1399
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1400
- return ret;
1401
- });
1402
- this._gantt._minStart = common.min(ganttData, function (n) { return n[1]; });
1403
- this._gantt._maxEnd = common.max(ganttData, function (n) { return n[2]; });
1404
- this._gantt.data(ganttData);
1405
- }
1406
- return retVal;
1407
- };
1408
- ReactAxisGanttSeries.prototype.resize = function (_size) {
1409
- var retVal = _super.prototype.resize.apply(this, arguments);
1410
- if (this._topAxisElement) {
1411
- this.resizeWrappers();
1412
- }
1413
- return retVal;
1414
- };
1415
- ReactAxisGanttSeries.prototype.click = function (row, col, sel) {
1416
- };
1417
- ReactAxisGanttSeries.prototype.dblclick = function (row, col, sel) {
1418
- };
1419
- ReactAxisGanttSeries.prototype.tooltip = function () {
1420
- return this._gantt._tooltip;
1421
- };
1422
- return ReactAxisGanttSeries;
1423
- }(layout.Border2));
1424
- ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
1425
- ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", undefined, { optional: true });
1426
- ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1427
- ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1428
- ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1429
- ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1430
- ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1431
- ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1432
- ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
1433
- ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
1434
- ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
1435
- ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
1436
- ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
1437
- ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
1438
- ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
1439
- ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
1440
- ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
1441
- ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
1442
- ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
1443
- ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
1444
- ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
1445
- ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
1446
- ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
1447
- ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
1448
- ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
1449
- ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");
1450
-
1451
- var ReactTimeline = /** @class */ (function (_super) {
1452
- __extends(ReactTimeline, _super);
1453
- function ReactTimeline() {
1454
- var _this = _super.call(this) || this;
1455
- _this._drawStartPos = "origin";
1456
- _this._topAxis.type("time");
1457
- _this._bottomAxis.type("time");
1458
- _this.tooltipHTML(function (d) {
1459
- var parser = common.timeParse("%Q");
1460
- var startTime = parser(d[1]);
1461
- var endTime = parser(d[2]);
1462
- var formatter = common.timeFormat(_this.tooltipTimeFormat());
1463
- return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1464
- });
1465
- return _this;
1466
- }
1467
- ReactTimeline.prototype.update = function (domNode, element) {
1468
- _super.prototype.update.call(this, domNode, element);
1469
- if (this.timePattern_exists()) {
1470
- var minTimestamp_1 = Infinity;
1471
- var maxTimestamp_1 = -Infinity;
1472
- var lowDateStr_1 = "";
1473
- var highDateStr_1 = "";
1474
- this.data().map(function (n) {
1475
- var start = new Date(n[1]).getTime();
1476
- var end = new Date(n[2]).getTime();
1477
- if (minTimestamp_1 > start) {
1478
- minTimestamp_1 = start;
1479
- lowDateStr_1 = "" + n[1];
1480
- }
1481
- if (maxTimestamp_1 < end) {
1482
- maxTimestamp_1 = end;
1483
- highDateStr_1 = "" + n[2];
1484
- }
1485
- });
1486
- this._topAxis
1487
- .type("time")
1488
- .timePattern(this.timePattern())
1489
- .overlapMode("none")
1490
- .tickFormat(this._axisLabelFormatter)
1491
- .low(lowDateStr_1)
1492
- .high(highDateStr_1);
1493
- this._bottomAxis
1494
- .type("time")
1495
- .timePattern(this.timePattern())
1496
- .overlapMode("none")
1497
- .tickFormat(this._axisLabelFormatter)
1498
- .low(lowDateStr_1)
1499
- .high(highDateStr_1);
1500
- this._gantt._minStart = minTimestamp_1;
1501
- this._gantt._maxEnd = maxTimestamp_1;
1502
- }
1503
- };
1504
- ReactTimeline.prototype.tooltipHTML = function (callback) {
1505
- this._tooltipHTML = callback;
1506
- this.tooltip().tooltipHTML(this._tooltipHTML);
1507
- return this;
1508
- };
1509
- ReactTimeline.prototype.parseAxisValue = function (v) {
1510
- var parseTime = common.timeParse("%Q");
1511
- var parsedTime = parseTime(v);
1512
- var formatTime = common.timeFormat(this.timePattern());
1513
- return formatTime(parsedTime);
1514
- };
1515
- ReactTimeline.prototype.onzoom = function (transform) {
1516
- var w = this.width();
1517
- var low = this._gantt._minStart;
1518
- var high = this._gantt._maxEnd;
1519
- var range = high - low;
1520
- var wpp = range / w;
1521
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1522
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1523
- this._topAxis
1524
- .low(this.parseAxisValue(nextLow))
1525
- .high(this.parseAxisValue(nextHigh))
1526
- .render();
1527
- this._bottomAxis
1528
- .low(this.parseAxisValue(nextLow))
1529
- .high(this.parseAxisValue(nextHigh))
1530
- .render();
1531
- };
1532
- return ReactTimeline;
1533
- }(ReactAxisGantt));
1534
- ReactTimeline.prototype._class += " timeline_ReactTimeline";
1535
- ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1536
- ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1537
-
1538
- var parseTime = common.timeParse("%Q");
1539
- var ReactTimelineSeries = /** @class */ (function (_super) {
1540
- __extends(ReactTimelineSeries, _super);
1541
- function ReactTimelineSeries() {
1542
- var _this = _super.call(this) || this;
1543
- _this._topAxis.type("time");
1544
- _this._bottomAxis.type("time");
1545
- _this.tooltipHTML(function (d) {
1546
- var startTime = parseTime(d[1]);
1547
- var endTime = parseTime(d[2]);
1548
- var formatter = common.timeFormat(_this.tooltipTimeFormat());
1549
- return "<div style=\"text-align:center;\">".concat(d[0], "<br/><br/>").concat(formatter(startTime), " -&gt; ").concat(formatter(endTime), "</div>");
1550
- });
1551
- return _this;
1552
- }
1553
- ReactTimelineSeries.prototype.update = function (domNode, element) {
1554
- _super.prototype.update.call(this, domNode, element);
1555
- if (this.timePattern_exists()) {
1556
- var minTimestamp_1 = Infinity;
1557
- var maxTimestamp_1 = -Infinity;
1558
- var lowDateStr_1 = "";
1559
- var highDateStr_1 = "";
1560
- this.data().forEach(function (n) {
1561
- var start = new Date(n[1]).getTime();
1562
- var end = new Date(n[2]).getTime();
1563
- if (minTimestamp_1 > start) {
1564
- minTimestamp_1 = start;
1565
- lowDateStr_1 = "" + n[1];
1566
- }
1567
- if (maxTimestamp_1 < end) {
1568
- maxTimestamp_1 = end;
1569
- highDateStr_1 = "" + n[2];
1570
- }
1571
- });
1572
- this._topAxis
1573
- .type("time")
1574
- .timePattern(this.timePattern())
1575
- .overlapMode("none")
1576
- .tickFormat(this._axisLabelFormatter)
1577
- .low(lowDateStr_1)
1578
- .high(highDateStr_1);
1579
- this._bottomAxis
1580
- .type("time")
1581
- .timePattern(this.timePattern())
1582
- .overlapMode("none")
1583
- .tickFormat(this._axisLabelFormatter)
1584
- .low(lowDateStr_1)
1585
- .high(highDateStr_1);
1586
- this._gantt._minStart = minTimestamp_1;
1587
- this._gantt._maxEnd = maxTimestamp_1;
1588
- }
1589
- };
1590
- ReactTimelineSeries.prototype.tooltipHTML = function (callback) {
1591
- this._tooltipHTML = callback;
1592
- this.tooltip().tooltipHTML(this._tooltipHTML);
1593
- return this;
1594
- };
1595
- ReactTimelineSeries.prototype.parseAxisValue = function (v) {
1596
- var parsedTime = parseTime(v);
1597
- var formatTime = common.timeFormat(this.timePattern());
1598
- return formatTime(parsedTime);
1599
- };
1600
- ReactTimelineSeries.prototype.onzoom = function (transform) {
1601
- var w = this.width();
1602
- var low = this._gantt._minStart;
1603
- var high = this._gantt._maxEnd;
1604
- var range = high - low;
1605
- var wpp = range / w;
1606
- var nextLow = Math.floor(low - (wpp * (transform.x / transform.k)));
1607
- var nextHigh = Math.ceil((range / transform.k) + nextLow);
1608
- this._topAxis
1609
- .low(this.parseAxisValue(nextLow))
1610
- .high(this.parseAxisValue(nextHigh))
1611
- .render();
1612
- this._bottomAxis
1613
- .low(this.parseAxisValue(nextLow))
1614
- .high(this.parseAxisValue(nextHigh))
1615
- .render();
1616
- };
1617
- return ReactTimelineSeries;
1618
- }(ReactAxisGanttSeries));
1619
- ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
1620
- ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1621
- ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1622
-
1623
- exports.BUILD_VERSION = BUILD_VERSION;
1624
- exports.MiniGantt = MiniGantt;
1625
- exports.PKG_NAME = PKG_NAME;
1626
- exports.PKG_VERSION = PKG_VERSION;
1627
- exports.ReactAxisGantt = ReactAxisGantt;
1628
- exports.ReactAxisGanttSeries = ReactAxisGanttSeries;
1629
- exports.ReactGantt = ReactGantt;
1630
- exports.ReactTimeline = ReactTimeline;
1631
- exports.ReactTimelineSeries = ReactTimelineSeries;
1632
-
1633
- }));
1
+ var N=Object.defineProperty;var F=(S,t)=>N(S,"name",{value:t,configurable:!0});var mt="@hpcc-js/timeline",ut="3.0.0",dt="3.2.0";import{ITooltip as I}from"@hpcc-js/api";import{Axis as M}from"@hpcc-js/chart";import{d3Event as E,EntityPin as U,EntityRect as j,local as W,select as O,SVGWidget as Q,Utility as L}from"@hpcc-js/common";import{extent as q}from"@hpcc-js/common";import{scaleBand as J}from"@hpcc-js/common";import{timeFormat as B,timeParse as K}from"@hpcc-js/common";import{zoom as tt,zoomIdentity as et}from"@hpcc-js/common";(function(){if(!document.getElementById("815a87be")){var S=document.createElement("style");S.id="815a87be",S.textContent=`.timeline_MiniGantt .line {
2
+ fill: none;
3
+ stroke: lightgrey;
4
+ opacity: 0.7;
5
+ }
6
+
7
+ .timeline_MiniGantt .common_TextBox .rect {
8
+ fill: lightskyblue;
9
+ stroke: blue;
10
+ opacity: 0.5;
11
+ }
12
+
13
+ .timeline_MiniGantt .buckets .entity_shape rect {
14
+ stroke: #333;
15
+ }
16
+
17
+ .timeline_MiniGantt .buckets.selected .common_EntityRect .common_Shape > rect {
18
+ stroke: red;
19
+ }
20
+
21
+ .timeline_MiniGantt .common_TextBox .rect text {
22
+ fill: black;
23
+ stroke: none;
24
+ }
25
+ .timeline_MiniGantt .over {
26
+ stroke: transparent;
27
+ opacity: 0.8;
28
+ }
29
+ .timeline_MiniGantt rect {
30
+ shape-rendering: crispEdges;
31
+ }`,document.head.appendChild(S)}})();var b=class extends Q{static{F(this,"MiniGantt")}tlAxis;brAxis;verticalBands;_zoom;gUpperContent;gUpperAxis;gMiddleContent;gLowerAxis;gLowerContent;localRect=W();localEntityPin=W();tooltipFormatter;_dateCache;rootExtent;_title_idx=0;_startDate_idx=1;_endDate_idx=2;_icon_idx=-1;_color_idx=-1;_yoffset_idx=-1;constructor(){super(),I.call(this),L.SimpleSelectionMixin.call(this),this._drawStartPos="origin",this.tooltipHTML(t=>`<center>${t[this._title_idx]}</center><br>${this.tooltipFormatter(this.brAxis.parse(t[this._startDate_idx]))} -> ${this.tooltipFormatter(this.brAxis.parse(t[this._endDate_idx]))}`),this.tlAxis=new M().type("time"),this.brAxis=new M().type("time"),this.verticalBands=J().paddingOuter(.2).paddingInner(.2)}isHorizontal(){return this.orientation()==="horizontal"}fullExtent(){let t=[...this.data().map(i=>i[this._startDate_idx]),...this.data().filter(i=>!!i[this._endDate_idx]).map(i=>i[this._endDate_idx])];return q(t)}extent(){let t=this.rootExtent?[this.rootExtent[1],this.rootExtent[2]]:this.fullExtent();if(t[0]!==void 0&&t[1]!==void 0&&(t[0]===t[1]||this.centerOnMostRecent())){let i=K(this.timePattern()),e=B(this.timePattern()),n=i(t[0]),s=i(t[1]);if(t[0]===t[1])t[0]=e(new Date(n.setFullYear(n.getFullYear()-1))),t[1]=e(new Date(n.setFullYear(n.getFullYear()+2)));else{let p=n.getTime(),h=s.getTime()-p;t[0]=e(n),t[1]=e(new Date(p+h*2))}}return t}dataStartPos(t){if(typeof this._dateCache[t[this._startDate_idx]]<"u")return this._dateCache[t[this._startDate_idx]];let i=this.brAxis.scalePos(t[this._startDate_idx]);return this._dateCache[t[this._startDate_idx]]=i,i}dataEndPos(t){if(typeof this._dateCache[t[this._endDate_idx]]<"u")return this._dateCache[t[this._endDate_idx]];let i=this.brAxis.scalePos(t[this._endDate_idx]);return this._dateCache[t[this._endDate_idx]]=i,i}dataWidth(t){return this.dataEndPos(t)-this.dataStartPos(t)}transform;resetZoom(){this._zoom.transform(this.element(),et.translate(0,this.isHorizontal()?0:this.height()))}zoomed(){this.transform=E().transform,this.render()}background;enter(t,i){super.enter(t,i),this._zoom=tt().scaleExtent([0,this.maxZoom()]).on("zoom",()=>{this.zoomed()}),this.background=i.append("rect").attr("fill","white").attr("opacity",0).on("dblclick",()=>{E().stopPropagation(),delete this.rootExtent,this.resetZoom()}),this.gUpperContent=i.append("g").attr("class","gUpperContent"),this.gUpperAxis=i.append("g").attr("class","gUpperAxis"),this.gMiddleContent=i.append("g").attr("class","gMiddleContent"),this.gLowerAxis=i.append("g").attr("class","gLowerAxis"),this.gLowerContent=i.append("g").attr("class","gLowerContent"),this.tlAxis.target(this.gUpperAxis.node()).tickFormat(this.tickFormat()).guideTarget(this.gUpperAxis.append("g").node()).shrinkToFit("none").overlapMode(this.tickFormat_exists()?"stagger":"none").extend(.1),this.brAxis.target(this.gLowerAxis.node()).tickFormat(this.tickFormat()).guideTarget(this.gLowerAxis.append("g").node()).shrinkToFit("none").overlapMode(this.tickFormat_exists()?"stagger":"none").extend(.1),i.call(this._zoom),this._selection.widgetElement(this.gMiddleContent)}_prevIsHorizontal;update(t,i){if(super.update(t,i),this._dateCache={},this._title_idx=this.titleColumn()!==null?this.columns().indexOf(this.titleColumn()):this._title_idx,this._startDate_idx=this.startDateColumn()!==null?this.columns().indexOf(this.startDateColumn()):this._startDate_idx,this._endDate_idx=this.endDateColumn()!==null?this.columns().indexOf(this.endDateColumn()):this._endDate_idx,this._icon_idx=this.iconColumn()!==null?this.columns().indexOf(this.iconColumn()):this._icon_idx,this._color_idx=this.colorColumn()!==null?this.columns().indexOf(this.colorColumn()):this._color_idx,this._yoffset_idx=this.yOffsetColumn()!==null?this.columns().indexOf(this.yOffsetColumn()):this._yoffset_idx,this._prevIsHorizontal!==this.isHorizontal()){this._prevIsHorizontal=this.isHorizontal(),this.resetZoom();return}this.tooltipFormatter=B(this.tooltipTimeFormat());let e=this.width(),n=this.height();this.background.attr("x",0).attr("y",0).attr("width",e).attr("height",n);let s=this.extent();if(this.tlAxis.x(e/2).orientation(this.isHorizontal()?"top":"left").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(e-1).low(s[0]).high(s[1]).updateScale(),this.brAxis.x(e/2).y(n/2).orientation(this.isHorizontal()?"bottom":"right").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(e-1).height(n).low(s[0]).high(s[1]).updateScale(),this.transform){let u,k;this.isHorizontal()?(u=this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(0))),k=this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(e-1)))):(u=this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(0))),k=this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(n-1)))),this.tlAxis.low(u).high(k).updateScale(),this.brAxis.low(u).high(k).updateScale()}let p=this.data().sort(this.isHorizontal()?(u,k)=>{let w=this.brAxis.scalePos(u[1])-this.brAxis.scalePos(k[1]);return w===0?(""+u[0]).localeCompare(""+k[0]):w}:(u,k)=>this.brAxis.scalePos(k[1])-this.brAxis.scalePos(u[1])),h=p.filter(u=>!u[this._endDate_idx]),r=p.filter(u=>!!u[this._endDate_idx]);this.tlAxis.render(),this.brAxis.render();let _=this.brAxis.getBBox(),y=this.updateEntityPins(h),c=_.height,l=n-y,o=this._yoffset_idx!==-1?Math.min.apply(void 0,this.data().filter(u=>!isNaN(u[this._yoffset_idx])).map(u=>u[this._yoffset_idx])):0;if(h.length>0&&r.length===0){this.tlAxis.visible(!1);let u=y/4;u>n/2-c&&(u=n/2-c);let k=n/2+u,w=(n/2-c-u)*-1,H=o!==0?o/2:0;this.gUpperContent.attr("transform",`translate(0, ${k-H})`),this.gLowerAxis.attr("transform",`translate(0, ${w-H})`)}else h.length===0&&r.length>0?(this.tlAxis.visible(!0),this.gUpperContent.attr("transform",`translate(0, ${y})`),this.gUpperAxis.attr("transform",`translate(0, ${y})`)):(y-=o,l+=o,this.tlAxis.visible(!0),this.gUpperContent.attr("transform",`translate(0, ${y})`),this.gUpperAxis.attr("transform",`translate(0, ${y})`),this.gMiddleContent.attr("transform",`translate(0, ${y})`));this.tlAxis.render();let m=this.tlAxis.getBBox(),a=[],d={};for(let u of r){for(let k=0;k<a.length;++k){let w=a[k];if(w.endPos+this.overlapTolerence()<=this.dataStartPos(u)){d[u]=k,w.endPos=this.dataEndPos(u);break}}d[u]===void 0&&(d[u]=a.length,a.push({endPos:this.dataEndPos(u)}))}let C=this.isHorizontal()?0+m.height:0+m.width,v=this.isHorizontal()?l-_.height:e-_.width;this.verticalBands.range([C,v]).domain(a.map((u,k)=>k)),r.length>0&&this.updateEventRanges(h,r,d,l,m,_,e)}updateEntityPins(t){let i=0,e=this,n=this.gUpperContent.selectAll(".entity_pin").data(t,o=>o[0]+":"+o[1]),s=this.eventFontColorColumn()?this.columns().indexOf(this.eventFontColorColumn()):-1,p=this.eventBorderColorColumn()?this.columns().indexOf(this.eventBorderColorColumn()):-1,h=this.eventBackgroundColorColumn()?this.columns().indexOf(this.eventBackgroundColorColumn()):-1,r={};for(let o of t){let m=typeof o[e._title_idx]<"u"?o[e._title_idx]:o[0];r[m]=r[m]?r[m]+1:1}let _=Object.keys(r),y=e.eventGroupOffset(),c=n.enter().append("g").attr("class","entity_pin");c.append("line").attr("class","entity_line"),c.on("mouseover",function(o){O(this).raise()}).each(function(o,m){let a=new U().target(this).icon("\uF024").iconOnlyShowOnHover(e.hideIconWhenCollapsed()).titleOnlyShowOnHover(e.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(e.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(e.hideAnnotationsWhenCollapsed()).iconDiameter(18).iconPaddingPercent(1).titleFontSize(14).descriptionColor("#333").descriptionFontSize(15).iconColor(s===-1?"#333":o[s]).titleColor(s===-1?"#333":o[s]).descriptionColor(s===-1?"#333":o[s]).backgroundShape("pin").backgroundColorFill(s===-1?"#f8f8f8":o[h]).backgroundColorStroke(s===-1?"#ccc":o[p]).cornerRadius(5).arrowHeight(10).arrowWidth(16);e.localEntityPin.set(this,a)}).merge(n).each(function(o,m){let a=e.localEntityPin.get(this),d=typeof o[e._title_idx]<"u"?o[e._title_idx]:a.title(),C=e.dataStartPos(o)-0,v=_.indexOf(d)%e.eventGroupMod()*y-5;if(typeof o[e._yoffset_idx]<"u"&&(v+=o[e._yoffset_idx]?o[e._yoffset_idx]:0),o[e._title_idx]!==a.title()&&o[e._startDate_idx]!==a.description()){let k=e.brAxis.parse(o[e._startDate_idx]),w=e.tooltipFormatter(k);a.x(C).y(v).iconOnlyShowOnHover(e.hideIconWhenCollapsed()).titleOnlyShowOnHover(e.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(e.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(e.hideAnnotationsWhenCollapsed()).icon(typeof o[e._icon_idx]<"u"?o[e._icon_idx]:a.icon()).title(d).description(w).animationFrameRender()}else a.move({x:C,y:v});let u=a.calcHeight();i<u&&(i=u),O(this).selectAll(".entity_line").attr("x1",C).attr("x2",C).attr("y1",0).attr("y2",v).style("stroke",s===-1?"#ccc":o[p]).style("stroke-width",1)}),n.exit().each(function(o,m){e.localEntityPin.get(this).target(null)}).remove();let l=Math.abs(Math.min(t.length,e.eventGroupMod())*e.eventGroupOffset());return i+l}updateEventRanges(t,i,e,n,s,p,h){let r=this,_=this.gMiddleContent.selectAll(".line").data(t,c=>c[r._title_idx]);_.enter().append("line").attr("class","line").merge(_).attr(this.isHorizontal()?"x1":"y1",c=>this.dataStartPos(c)-0).attr(this.isHorizontal()?"x2":"y2",c=>this.dataStartPos(c)-0).attr(this.isHorizontal()?"y1":"x1",this.isHorizontal()?s.height:s.width).attr(this.isHorizontal()?"y2":"x2",this.isHorizontal()?n-p.height:h-p.width),_.exit().remove();let y=this.gMiddleContent.selectAll(".buckets").data(i,c=>c[r._title_idx]);y.enter().append("g").attr("class","buckets").call(this._selection.enter.bind(this._selection)).each(function(c){let l=new j().target(this).iconDiameter(28).iconPaddingPercent(0).titleFontSize(28).titleColor(r.rangeFontColor()).descriptionColor(r.rangeFontColor()).iconColor(r.rangeFontColor()).backgroundShape("rect").backgroundColorFill(c[r._color_idx]);r.localRect.set(this,l),r.enterEntityRect(l,c)}).on("click",function(c){r.click(r.rowToObj(c),"range",r._selection.selected(this))},!1).on("dblclick",function(c){r.rootExtent=c,r.resetZoom(),r.dblclick(r.rowToObj(c),"range",r._selection.selected(this))},!0).on("mouseout.tooltip",this.tooltip.hide).on("mousemove.tooltip",this.tooltip.show).merge(y).attr("transform",c=>r.isHorizontal()?`translate(${this.dataStartPos(c)}, ${this.verticalBands(e[c])}) `:`translate(${this.verticalBands(e[c])}, ${this.dataStartPos(c)}) `).each(function(c){let l=r.localRect.get(this),o=r.dataWidth(c)/2,m=r.verticalBands.bandwidth()/2,a=Math.max(r.dataWidth(c),2),d=Math.max(r.verticalBands.bandwidth(),2),C=.618,u=(1-C)/2*d,k=d*C,w=k;l.pos(r.isHorizontal()?{x:o,y:m}:{x:m,y:o}).fixedHeight(r.isHorizontal()?d:a).fixedWidth(r.isHorizontal()?a:d).icon(typeof c[r._icon_idx]<"u"?c[r._icon_idx]:"").title(typeof c[r._title_idx]<"u"?c[r._title_idx]:"").padding(u).iconDiameter(w).titleFontSize(k),w*1.5>a&&l.icon(null),r.updateEntityRect(l,c[r._icon_idx]),l.render()}),y.exit().remove()}exit(t,i){this.brAxis.target(null),this.tlAxis.target(null),super.exit(t,i)}click(t,i,e){}dblclick(t,i,e){}enterEntityRect(t,i){}updateEntityRect(t,i){}};b.prototype._class+=" timeline_MiniGantt";b.prototype.implements(I.prototype);b.prototype.mixin(L.SimpleSelectionMixin);b.prototype.publish("timePattern","%Y-%m-%d","string","timePattern");b.prototype.publish("tickFormat",null,"string","tickFormat",void 0,{optional:!0});b.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","tooltipTimeFormat");b.prototype.publish("overlapTolerence",2,"number","overlapTolerence");b.prototype.publish("orientation","horizontal","set","orientation",["horizontal","vertical"]);b.prototype.publish("rangeFontColor","#ecf0f1","html-color","rangeFontColor");b.prototype.publish("titleColumn",null,"string","titleColumn");b.prototype.publish("startDateColumn",null,"string","startDateColumn");b.prototype.publish("endDateColumn",null,"string","endDateColumn");b.prototype.publish("iconColumn",null,"string","iconColumn");b.prototype.publish("colorColumn",null,"string","colorColumn");b.prototype.publish("yOffsetColumn",null,"string","yOffsetColumn");b.prototype.publish("maxZoom",16,"number","maxZoom");b.prototype.publish("eventGroupOffset",-50,"number","eventGroupOffset");b.prototype.publish("eventGroupMod",5,"number","eventGroupMod");b.prototype.publish("eventFontColorColumn",null,"string","eventFontColorColumn");b.prototype.publish("eventBorderColorColumn",null,"string","eventBorderColorColumn");b.prototype.publish("eventBackgroundColorColumn",null,"string","eventBackgroundColorColumn");b.prototype.publish("hideIconWhenCollapsed",!1,"boolean","hideIconWhenCollapsed");b.prototype.publish("hideTitleWhenCollapsed",!1,"boolean","hideTitleWhenCollapsed");b.prototype.publish("hideDescriptionWhenCollapsed",!1,"boolean","hideDescriptionWhenCollapsed");b.prototype.publish("hideAnnotationsWhenCollapsed",!0,"boolean","hideAnnotationsWhenCollapsed");b.prototype.publish("centerOnMostRecent",!1,"boolean","If true, the timeline will be centered on the most recent data point");import{d3Event as D,select as A,SVGZoomWidget as it,Utility as P}from"@hpcc-js/common";import{HTMLTooltip as ot}from"@hpcc-js/html";import{scaleLinear as G}from"@hpcc-js/common";import{render as nt,LabelledRect as st}from"@hpcc-js/react";var g=class extends it{static{F(this,"ReactGantt")}_selection=new P.Selection(this);_buckets;_interpolateX;_interpolateY;_bucketsBySeries;_dataBySeries;_origIdxMap;_seriesBackgrounds;_maxFontSize;_tooltip;_minStart;_maxEnd;_title_idx=0;_startDate_idx=1;_endDate_idx=2;_icon_idx=-1;_color_idx=-1;_series_idx=-1;_bucket_idx=-1;_yoffset_idx=-1;_maxX;_maxY;_rangeOptions={rangePadding:2,fontFamily:"Verdana",fontSize:12,fill:"white",stroke:"black",textFill:"black",cornerRadius:3,strokeWidth:0};constructor(t="origin"){super(),this._drawStartPos=t,this.showToolbar_default(!1),this._tooltip=new ot,this._tooltip.tooltipHTML(i=>`<div style="text-align:center;">${i[0]}<br/><br/>${i[1]} -&gt; ${i[2]}</div>`),this._tooltip.followCursor(!0)}selection(t){return arguments.length?(this._selection.set(t),this):this._selection.get()}_rangeRenderer=st;rangeRenderer(t){return arguments.length?(this._rangeRenderer=t,this._rangeRenderer):this._rangeRenderer}enter(t,i){super.enter(t,i);let e=this;i.on("click",function(n){e._selection.clear()}),this._tooltip.target(t)}update(t,i){super.update(t,i),this.zoomExtent([.05,this.maxZoom()]),this._title_idx=this.titleColumn()!==null?this.columns().indexOf(this.titleColumn()):this._title_idx,this._startDate_idx=this.startDateColumn()!==null?this.columns().indexOf(this.startDateColumn()):this._startDate_idx,this._endDate_idx=this.endDateColumn()!==null?this.columns().indexOf(this.endDateColumn()):this._endDate_idx,this._icon_idx=this.iconColumn()!==null?this.columns().indexOf(this.iconColumn()):this._icon_idx,this._color_idx=this.colorColumn()!==null?this.columns().indexOf(this.colorColumn()):this._color_idx,this._series_idx=this.seriesColumn()!==null?this.columns().indexOf(this.seriesColumn()):this._series_idx,this._bucket_idx=this.bucketColumn()!==null?this.columns().indexOf(this.bucketColumn()):-1;let e=this,n=this.width(),s=0,p=n;if(this._interpolateX=G().domain([this._minStart,this._maxEnd]).range([s,p]),this.data().sort((l,o)=>l[1]-o[1]),this._series_idx>-1){this._origIdxMap={},this._dataBySeries={},this._bucketsBySeries={},this.data().forEach((a,d)=>{let C=a[this._series_idx];this._dataBySeries[C]||(this._origIdxMap[C]={},this._dataBySeries[C]=[]),this._dataBySeries[C].push({dataRow:a,origIdx:d})});let l=this.gutter(),o=0,m=Object.keys(this._dataBySeries);m.forEach(a=>{this._dataBySeries[a].sort((d,C)=>d.dataRow[1]-C.dataRow[1]),this._bucketsBySeries[a]=this.calcBuckets(this._dataBySeries[a].map(d=>d.dataRow),1,2),this._bucketsBySeries[a].bucketHeight=this.bucketHeight(),this._bucketsBySeries[a].bucketOffset=o,o+=(this._bucketsBySeries[a].bucketHeight+this.strokeWidth()+this.gutter())*(this._bucketsBySeries[a].maxBucket+1),this._dataBySeries[a].forEach((d,C)=>{this._origIdxMap[a][d.origIdx]=C})}),this._seriesBackgrounds=this._renderElement.selectAll(".series-background").data(m.map(a=>this._bucketsBySeries[a])),this._seriesBackgrounds.join(a=>a.append("rect").attr("class","series-background"),a=>a,a=>a.each(function(d){delete d.element}).remove()).attr("opacity",a=>a.props&&a.props.hidden?0:1).each(function(a,d){A(this).attr("x",0).attr("y",a.bucketOffset-l/2).attr("width",n).attr("height",(a.bucketHeight+l)*(a.maxBucket+1)+l).attr("fill",d%2?e.oddSeriesBackground():e.evenSeriesBackground())})}else this._bucket_idx!==-1?this._buckets=this.calcBuckets(this.data(),this._startDate_idx,this._endDate_idx,this._bucket_idx):this._buckets=this.calcBuckets(this.data(),this._startDate_idx,this._endDate_idx);let h=this._interpolateX(this._minStart);this.zoomTo([h,0],1);let r=this.bucketHeight();this.setRangeOptions(),this._maxFontScale=r-this.rangePadding()*2,this.measureDataText();let _=this._renderElement.selectAll(".item").data(this.data()),y=this.strokeWidth(),c=y*2;_.join(l=>l.append("g").attr("class","item").on("click.selectionBag",function(o,m){let a=o.id===void 0?m:o.id;e._selection.isSelected({_id:a,element:o.element})?e._selection.clear():e._selection.click({_id:a,element:F(()=>o.element,"element")},D),e.selectionChanged(),D().stopPropagation()}).on("click",function(o){let m=o.element.classed("selected");o[e.columns().length]&&(o.__lparam=o[e.columns().length]),e.click(o,"",m)}).on("dblclick",function(o){let m=o.element.classed("selected");o[e.columns().length]&&(o.__lparam=o[e.columns().length]),e.click(o,"",m)}).on("mousein",function(o){e.highlightItem(A(this),o);let m=o.element.classed("selected");e.mousein(o,"",m)}).on("mouseover",function(o){let m=D();e._tooltip._triggerElement=o.element,e._tooltip._cursorLoc=[m.clientX,m.clientY],e._tooltip.data(o).visible(!0).fitContent(!0).render(),e.highlightItem(A(this),o);let a=o.element.classed("selected");e.mouseover(o,"",a)}).on("mouseout",function(o){e._tooltip.visible(!1).render(),e.highlightItem(null,null);let m=o.element.classed("selected");e.mouseout(o,"",m)}).each(function(o,m){o.that=this,o.element=A(this),o.x=e._interpolateX(o[1]);let a=e._interpolateX(o[2]);if(e._series_idx>-1){let d=o[e._series_idx],C=e._bucketsBySeries[d].bucketMap[e._origIdxMap[d][m]];o.y=e._bucketsBySeries[d].interpolateY(C)+e._bucketsBySeries[d].bucketOffset}else{let d=e._bucket_idx===-1?m:o[e._bucket_idx];o.y=e._buckets.interpolateY(e._buckets.bucketMap[d])}o.props={...o[3],text:o[0]},o.props.width=a-o.x,o.props.height=r,o.x+=y,o.y+=y,o.props.width-=c,o.props.height-=c,o.element.attr("transform",`translate(${o.x+o.props.width/2} ${o.y+o.props.height/2})`)}),l=>l,l=>l.each(function(o){delete o.element}).remove()).attr("opacity",l=>l.props&&l.props.hidden?0:1).each(function(l,o){if(l.that=this,e._series_idx>-1){let m=l[e._series_idx];l.x=e.renderRangeElement(l,o,!1,e._rangeOptions,m)}else l.x=e.renderRangeElement(l,o,!1,e._rangeOptions)}).on("dblclick.zoom",l=>{let o=this._interpolateX(l[1]),a=this._interpolateX(l[2])-o,d=n/a;this.zoomTo([-o*d,0],d)}),i.on("dblclick.zoom",null)}exit(t,i){this._tooltip.target(null),super.exit(t,i)}renderRangeElement(t,i,e=!1,n={},s){let p=n.strokeWidth,h=p*2,r=n.rangePadding,_,y=isNaN(this._transform.x)?0:this._transform.x,c=isNaN(this._transform.k)?1:this._transform.k,l,o=this.bucketHeight();t.that.setAttribute("data-series",s),this._color_idx>-1&&t.that.setAttribute("data-color",t[this._color_idx]),s!==void 0?(l=this._bucketsBySeries[s].bucketMap[this._origIdxMap[s][i]],t.that.setAttribute("data-b",l),t.that.setAttribute("data-bucketOffset",this._bucketsBySeries[s].bucketOffset),t.y=this._bucketsBySeries[s].interpolateY(l)+this._bucketsBySeries[s].bucketOffset,t.that.setAttribute("data-dy",t.y)):(l=this._buckets.bucketMap[i],t.y=this._buckets.interpolateY(l)),this._color_idx>-1&&(n.fill=t[this._color_idx]),e?(t.x=this._interpolateX(t[1])*c,_=this._interpolateX(t[2])*c,t.props={...t[3],text:t[0]},t.props.width=(_-t.x)/c,t.x+=y,t.props.width*=c):(t.x=this._interpolateX(t[1]),_=this._interpolateX(t[2]),t.props={...t[3],text:t[0]},t.props.width=(_-t.x)/c),t.props.height=o,s===void 0&&this._buckets.bucketScale<1&&(t.props.height=this._buckets.bucketScale*o),t.element===void 0&&t.that&&(t.element=A(t.that)),t.element.attr("transform",`translate(${t.x+t.props.width/2} ${t.y+t.props.height/2})`),t.x+=p,t.y+=p,t.props.width-=h,t.props.height-=h,t.props.width=t.props.width<1?1:t.props.width,t.props.height=t.props.height<1?1:t.props.height;let m=this.truncateText(t.props.text,t.props.width-r,this._maxFontScale);m!==t.props.text?m=this.truncateText(t.props.text,t.props.width-r):t.props.fontSize=this._maxFontScale*n.fontSize,s===void 0&&this._buckets.bucketScale<1&&(t.props.fontSize=Math.min(this._maxFontScale,this._buckets.bucketScale)*n.fontSize),(!this._maxY||this._maxY<t.y+t.props.height)&&(this._maxY=t.y+t.props.height),(!this._maxX||this._maxX<t.x+t.props.width)&&(this._maxX=t.x+t.props.width),nt(this._rangeRenderer,{...n,...t.props,text:m},t.that)}setRangeOptions(){this._rangeOptions={rangePadding:this.rangePadding(),fontFamily:this.fontFamily(),fontSize:this.fontSize(),strokeWidth:this.strokeWidth(),fill:this.fill(),stroke:this.stroke(),textFill:this.rangeFontColor(),cornerRadius:this.cornerRadius()}}_transform={k:1,x:0,y:0};zoomed(t){switch(this._transform=t,this.renderMode()){case"scale-all":this._zoomScale=t.k,this._zoomTranslate=[t.x,0],this._zoomG.attr("transform",`translate(${t.x} 0)scale(${t.k} 1)`);break;default:let i=this._rangeOptions;this.data().forEach((e,n)=>{if(this._color_idx>-1&&(i.fill=e[this._color_idx]),this._series_idx>-1){let s=e[this._series_idx];this.renderRangeElement(e,n,!0,i,s)}else this.renderRangeElement(e,n,!0,i)})}this.zoomedHook(t)}zoomedHook(t){}calcBuckets(t,i,e,n){let s={},p={},h=this.overlapTolerence(),r=[{end:-1/0}],_=0;n!==void 0?(t.forEach((c,l)=>{s[l]=c[n],p[c[n]]=!0}),_=Object.keys(p).length):t.forEach((c,l)=>{for(let o=0;o<r.length;++o)if(l===0||r[o][e]+h<=c[i]){s[l]=o,_<o&&(_=o),r[o][e]=c[e];break}if(s[l]===void 0){s[l]=r.length;let o={};o[e]=c[e],r.push(o)}_<s[l]&&(_=s[l])});let y=(_+1)*(this.bucketHeight()+this.gutter());return{bucketMap:s,maxBucket:_,bucketScale:this.height()/y,interpolateY:G().domain([0,_+1]).range([0,Math.min(this.height(),y)])}}data(t){let i=super.data.apply(this,arguments);return arguments.length>0&&(this._minStart=Math.min(...this.data().map(e=>e[1]))??0,this._maxEnd=Math.max(...this.data().map(e=>e[2]))??1,this.measureDataText(!0)),i}_textWidths;_maxFontScale;_characterWidths;_prevFontFamily;_prevFontSize;measureDataText(t=!1){let i={},e={},n=this.fontFamily(),s=this.fontSize(),p=this.bucketHeight();p&&(this._maxFontScale=(p-this.rangePadding()*2)/s),(t||this._prevFontFamily!==n||this._prevFontSize!==s)&&(e["."]=P.textSize(".",n,s).width,this.data().forEach(h=>{i[h[0]]||(i[h[0]]=P.textSize(h[0],n,s).width),h[0].split("").forEach(r=>{e[r]||(e[r]=P.textSize(r,n,s).width)})}),this._textWidths=i,this._characterWidths=e),this._prevFontFamily=n,this._prevFontSize=s}truncateText(t,i,e=1){if(this._textWidths[t]*e<i)return t;let s="",p=0,h=i-this._characterWidths["."]*3;for(let r of t)if(p+=this._characterWidths[r],p<h)s+=r;else break;return h<0?"":s+"..."}resize(t){let i;return this.fitWidthToContent()||this.fitHeightToContent()?i=super.resize.call(this,{width:t.width,height:this._maxY}):i=super.resize.apply(this,arguments),i}selectionChanged(){}highlightItem(t,i){}click(t,i,e){}dblclick(t,i,e){}mousein(t,i,e){}mouseover(t,i,e){}mouseout(t,i,e){}};g.prototype._class+=" timeline_ReactGantt";g.prototype.publish("fitWidthToContent",!1,"boolean","If true, resize will simply reapply the bounding box width");g.prototype.publish("fitHeightToContent",!1,"boolean","If true, resize will simply reapply the bounding box height");g.prototype.publish("titleColumn",null,"string","Column name to for the title");g.prototype.publish("startDateColumn",null,"string","Column name to for the start date");g.prototype.publish("endDateColumn",null,"string","Column name to for the end date");g.prototype.publish("iconColumn",null,"string","Column name to for the icon");g.prototype.publish("colorColumn",null,"string","Column name to for the color");g.prototype.publish("seriesColumn",null,"string","Column name to for the series identifier");g.prototype.publish("bucketColumn",null,"string","Column name to for the bucket identifier");g.prototype.publish("renderMode","default","set","Render modes vary in features and performance",["default","scale-all"]);g.prototype.publish("rangePadding",3,"number","Padding within each range rectangle (pixels)");g.prototype.publish("fill","#1f77b4","string","Background color of range rectangle");g.prototype.publish("stroke",null,"string","Color of range rectangle border");g.prototype.publish("strokeWidth",null,"number","Width of range rectangle border (pixels)");g.prototype.publish("cornerRadius",3,"number","Space between range buckets (pixels)");g.prototype.publish("fontFamily",null,"string","Font family within range rectangle",null,{optional:!0});g.prototype.publish("fontSize",10,"number","Size of font within range rectangle (pixels)");g.prototype.publish("rangeFontColor","#ecf0f1","html-color","rangeFontColor");g.prototype.publish("overlapTolerence",2,"number","overlapTolerence");g.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)");g.prototype.publish("bucketHeight",100,"number","Max height of range element (pixels)");g.prototype.publish("gutter",2,"number","Space between range buckets (pixels)");g.prototype.publish("maxZoom",16,"number","Maximum zoom");g.prototype.publish("evenSeriesBackground","#FFFFFF","html-color","Background color of even series rows");g.prototype.publish("oddSeriesBackground","#DDDDDD","html-color","Background color of odd series rows");import{Axis as $}from"@hpcc-js/chart";import{SVGWidget as rt}from"@hpcc-js/common";var f=class extends rt{static{F(this,"ReactAxisGantt")}_topAxis=new $("center").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_gantt=new g("center").stroke("#000000");_bottomAxis=new $("center").orientation("bottom").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_topAxisElement;_contentElement;_bottomAxisElement;_topRect;_contentRect;_bottomRect;rangeRenderer;constructor(){super(),this._drawStartPos="origin",this.rangeRenderer=function(){let t=this._gantt.rangeRenderer.apply(this._gantt,arguments);return arguments.length?this:t}}selection(t){return arguments.length?(this._gantt.selection(t),this):this._gantt.selection()}resizeWrappers(){let t=this.width(),i=this.height(),e=this.axisHeight(),n=i-e*2,s=this.strokeWidth();this._topRect.attr("height",e).attr("width",t).attr("fill","transparent"),this._topAxisElement.attr("transform","translate(0 0)"),this._topAxis.resize({height:e,width:t}),this._contentRect.attr("height",n).attr("width",t).attr("fill","transparent"),this._contentElement.attr("transform",`translate(0 ${e+s})`),this._gantt.resize({height:n,width:t}),this._bottomRect.attr("height",e).attr("width",t).attr("fill","transparent"),this._bottomAxisElement.attr("transform",`translate(0 ${e+n+s})`),this._bottomAxis.resize({height:e,width:t})}enter(t,i){super.enter(t,i),this._gantt.click=(e,n,s)=>{this.click(e,n,s)},this._gantt.dblclick=(e,n,s)=>{this.dblclick(e,n,s)},this._topAxisElement=i.append("g").attr("class","top-axis-wrapper"),this._topRect=this._topAxisElement.append("rect").attr("class","top-axis-rect"),this._contentElement=i.append("g").attr("class","content-wrapper"),this._contentRect=this._contentElement.append("rect").attr("class","content-rect"),this._bottomAxisElement=i.append("g").attr("class","bottom-axis-wrapper"),this._bottomRect=this._bottomAxisElement.append("rect").attr("class","top-axis-rect"),this._topAxis.target(this._topAxisElement.node()),this._gantt.target(this._contentElement.node()).bucketHeight(30),this._bottomAxis.target(this._bottomAxisElement.node()),this.resizeWrappers(),this._gantt.zoomedHook=e=>{this.onzoom(e)}}onzoom(t){let i=this.width(),e=this._gantt._minStart,s=this._gantt._maxEnd-e,p=s/i,h=Math.floor(e-p*(t.x/t.k)),r=Math.ceil(s/t.k+h);this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(h).high(r).render(),this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(h).high(r).render()}update(t,i){super.update(t,i),this._topAxis.tickFormat(this.tickFormat()).render(),this._bottomAxis.tickFormat(this.tickFormat()).render(),this._gantt.render()}exit(t,i){this._bottomAxis.target(null),this._gantt.target(null),this._topAxis.target(null),super.exit(t,i)}columns(t){let i=super.columns.apply(this,arguments);return arguments.length>0&&this._gantt.columns(t),i}data(t){let i=super.data.apply(this,arguments);if(arguments.length>0){let e=this.data().map(n=>{let s=[...n];return s[1]=isNaN(n[1])?new Date(n[1]).getTime():Number(n[1]),s[2]=isNaN(n[2])?new Date(n[2]).getTime():Number(n[2]),s});this._gantt._minStart=Math.min(...e.map(n=>n[1]))??0,this._gantt._maxEnd=Math.max(...e.map(n=>n[2]))??1,this._gantt.data(e)}return i}resize(t){let i=super.resize.apply(this,arguments);return this._topAxisElement&&this.resizeWrappers(),i}click(t,i,e){}dblclick(t,i,e){}tooltip(){return this._gantt._tooltip}};f.prototype._class+=" timeline_ReactAxisGantt";f.prototype.publish("tickFormat",null,"string","Format rule applied to axis tick labels",void 0,{optional:!0});f.prototype.publish("axisHeight",22,"number","Height of axes (pixels)");f.prototype.publish("overlapTolerence",2,"number","overlapTolerence");f.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)");f.prototype.publish("axisFontSize",null,"number","Font size of axis tick labels");f.prototype.publish("axisFontFamily",null,"string","Font family of axis tick labels");f.prototype.publish("axisTickLength",null,"number","Length of axis ticks");f.prototype.publishProxy("gutter","_gantt");f.prototype.publishProxy("renderMode","_gantt");f.prototype.publishProxy("strokeWidth","_gantt");f.prototype.publishProxy("fontSize","_gantt");f.prototype.publishProxy("fontFamily","_gantt");f.prototype.publishProxy("stroke","_gantt");f.prototype.publishProxy("cornerRadius","_gantt");f.prototype.publishProxy("titleColumn","_gantt");f.prototype.publishProxy("startDateColumn","_gantt");f.prototype.publishProxy("endDateColumn","_gantt");f.prototype.publishProxy("iconColumn","_gantt");f.prototype.publishProxy("colorColumn","_gantt");f.prototype.publishProxy("bucketColumn","_gantt");f.prototype.publishProxy("maxZoom","_gantt");f.prototype.publishProxy("bucketHeight","_gantt");import{min as at,max as lt}from"@hpcc-js/common";import{Axis as V}from"@hpcc-js/chart";import{Border2 as ht}from"@hpcc-js/layout";var x=class extends ht{static{F(this,"ReactAxisGanttSeries")}_topAxis=new V("origin").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_gantt=new g("origin").stroke("#000000").fitHeightToContent(!0);_bottomAxis=new V("origin").orientation("bottom").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_topAxisElement;_contentElement;_bottomAxisElement;_topRect;_contentRect;_bottomRect;constructor(){super(),this.centerOverflowX_default("hidden"),this.centerOverflowY_default("auto")}selection(t){return arguments.length?(this._gantt.selection(t),this):this._gantt.selection()}rangeRenderer(t){let i=this._gantt.rangeRenderer.apply(this._gantt,arguments);return arguments.length?this:i}resizeWrappers(){let t=this.width(),i=this.height(),e=this.axisHeight(),n=i-e*2;this.bottomHeight(e),this._topWA.resize({width:t,height:e}),this._centerWA.resize({width:t,height:n}),this._bottomWA.resize({width:t,height:e}),this.top().render(),this.bottom().render(),this.center().render()}enter(t,i){super.enter(t,i),this._gantt.click=(e,n,s)=>{this.click(e,n,s)},this._gantt.dblclick=(e,n,s)=>{this.dblclick(e,n,s)},this.top(this._topAxis),this.center(this._gantt),this.bottom(this._bottomAxis),this.resizeWrappers(),this._gantt.zoomedHook=e=>{this.onzoom(e)}}onzoom(t){let i=this.width(),e=this._gantt._minStart,s=this._gantt._maxEnd-e,p=s/i,h=Math.floor(e-p*(t.x/t.k)),r=Math.ceil(s/t.k+h);this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(h).high(r).lazyRender(),this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(h).high(r).lazyRender()}update(t,i){super.update(t,i),this._topAxis.tickFormat(this.tickFormat()).render(),this._bottomAxis.tickFormat(this.tickFormat()).render(),this._gantt.render()}columns(t){let i=super.columns.apply(this,arguments);return arguments.length>0&&this._gantt.columns(t),i}data(t){let i=super.data.apply(this,arguments);if(arguments.length>0){let e=this.data().map(n=>{let s=[...n];return s[1]=isNaN(n[1])?new Date(n[1]).getTime():Number(n[1]),s[2]=isNaN(n[2])?new Date(n[2]).getTime():Number(n[2]),s});this._gantt._minStart=at(e,n=>n[1]),this._gantt._maxEnd=lt(e,n=>n[2]),this._gantt.data(e)}return i}resize(t){let i=super.resize.apply(this,arguments);return this._topAxisElement&&this.resizeWrappers(),i}click(t,i,e){}dblclick(t,i,e){}tooltip(){return this._gantt._tooltip}};x.prototype._class+=" timeline_ReactAxisGanttSeries";x.prototype.publish("tickFormat",null,"string","Format rule applied to axis tick labels",void 0,{optional:!0});x.prototype.publish("axisHeight",22,"number","Height of axes (pixels)");x.prototype.publish("overlapTolerence",2,"number","overlapTolerence");x.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)");x.prototype.publish("axisFontSize",null,"number","Font size of axis tick labels");x.prototype.publish("axisFontFamily",null,"string","Font family of axis tick labels");x.prototype.publish("axisTickLength",null,"number","Length of axis ticks");x.prototype.publishProxy("gutter","_gantt");x.prototype.publishProxy("renderMode","_gantt");x.prototype.publishProxy("strokeWidth","_gantt");x.prototype.publishProxy("fontSize","_gantt");x.prototype.publishProxy("fontFamily","_gantt");x.prototype.publishProxy("stroke","_gantt");x.prototype.publishProxy("cornerRadius","_gantt");x.prototype.publishProxy("titleColumn","_gantt");x.prototype.publishProxy("startDateColumn","_gantt");x.prototype.publishProxy("endDateColumn","_gantt");x.prototype.publishProxy("iconColumn","_gantt");x.prototype.publishProxy("colorColumn","_gantt");x.prototype.publishProxy("seriesColumn","_gantt");x.prototype.publishProxy("bucketColumn","_gantt");x.prototype.publishProxy("maxZoom","_gantt");x.prototype.publishProxy("evenSeriesBackground","_gantt");x.prototype.publishProxy("oddSeriesBackground","_gantt");x.prototype.publishProxy("bucketHeight","_gantt");import{timeFormat as Y,timeParse as Z}from"@hpcc-js/common";var T=class extends f{static{F(this,"ReactTimeline")}_axisLabelFormatter;constructor(){super(),this._drawStartPos="origin",this._topAxis.type("time"),this._bottomAxis.type("time"),this.tooltipHTML(t=>{let i=Z("%Q"),e=i(t[1]),n=i(t[2]),s=Y(this.tooltipTimeFormat());return`<div style="text-align:center;">${t[0]}<br/><br/>${s(e)} -&gt; ${s(n)}</div>`})}update(t,i){if(super.update(t,i),this.timePattern_exists()){let e=1/0,n=-1/0,s="",p="";this.data().map(h=>{let r=new Date(h[1]).getTime(),_=new Date(h[2]).getTime();e>r&&(e=r,s=""+h[1]),n<_&&(n=_,p=""+h[2])}),this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").tickFormat(this._axisLabelFormatter).low(s).high(p),this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").tickFormat(this._axisLabelFormatter).low(s).high(p),this._gantt._minStart=e,this._gantt._maxEnd=n}}tooltipHTML(t){return this._tooltipHTML=t,this.tooltip().tooltipHTML(this._tooltipHTML),this}parseAxisValue(t){let e=Z("%Q")(t);return Y(this.timePattern())(e)}onzoom(t){let i=this.width(),e=this._gantt._minStart,s=this._gantt._maxEnd-e,p=s/i,h=Math.floor(e-p*(t.x/t.k)),r=Math.ceil(s/t.k+h);this._topAxis.low(this.parseAxisValue(h)).high(this.parseAxisValue(r)).render(),this._bottomAxis.low(this.parseAxisValue(h)).high(this.parseAxisValue(r)).render()}};T.prototype._class+=" timeline_ReactTimeline";T.prototype.publish("timePattern","%Y-%m-%d","string","Time pattern used for parsing datetime strings on each data row",null,{optional:!0});T.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","Time format used in the default html tooltip");import{timeFormat as X,timeParse as ct}from"@hpcc-js/common";var R=ct("%Q"),z=class extends x{static{F(this,"ReactTimelineSeries")}_axisLabelFormatter;constructor(){super(),this._topAxis.type("time"),this._bottomAxis.type("time"),this.tooltipHTML(t=>{let i=R(t[1]),e=R(t[2]),n=X(this.tooltipTimeFormat());return`<div style="text-align:center;">${t[0]}<br/><br/>${n(i)} -&gt; ${n(e)}</div>`})}update(t,i){if(super.update(t,i),this.timePattern_exists()){let e=1/0,n=-1/0,s="",p="";this.data().forEach(h=>{let r=new Date(h[1]).getTime(),_=new Date(h[2]).getTime();e>r&&(e=r,s=""+h[1]),n<_&&(n=_,p=""+h[2])}),this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").tickFormat(this._axisLabelFormatter).low(s).high(p),this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").tickFormat(this._axisLabelFormatter).low(s).high(p),this._gantt._minStart=e,this._gantt._maxEnd=n}}tooltipHTML(t){return this._tooltipHTML=t,this.tooltip().tooltipHTML(this._tooltipHTML),this}parseAxisValue(t){let i=R(t);return X(this.timePattern())(i)}onzoom(t){let i=this.width(),e=this._gantt._minStart,s=this._gantt._maxEnd-e,p=s/i,h=Math.floor(e-p*(t.x/t.k)),r=Math.ceil(s/t.k+h);this._topAxis.low(this.parseAxisValue(h)).high(this.parseAxisValue(r)).render(),this._bottomAxis.low(this.parseAxisValue(h)).high(this.parseAxisValue(r)).render()}_tooltipHTML};z.prototype._class+=" timeline_ReactTimelineSeries";z.prototype.publish("timePattern","%Y-%m-%d","string","Time pattern used for parsing datetime strings on each data row",null,{optional:!0});z.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","Time format used in the default html tooltip");export{dt as BUILD_VERSION,b as MiniGantt,mt as PKG_NAME,ut as PKG_VERSION,f as ReactAxisGantt,x as ReactAxisGanttSeries,g as ReactGantt,T as ReactTimeline,z as ReactTimelineSeries};
1634
32
  //# sourceMappingURL=index.js.map