@hpcc-js/timeline 3.2.1 → 3.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,1323 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { ITooltip } from "@hpcc-js/api";
4
- import { Axis } from "@hpcc-js/chart";
5
- import { Utility, SVGWidget, local, scaleBand, extent, timeParse, timeFormat, zoomIdentity, d3Event, zoom, select, EntityPin, EntityRect, SVGZoomWidget, scaleLinear, min, max } from "@hpcc-js/common";
6
- import { HTMLTooltip } from "@hpcc-js/html";
7
- import { LabelledRect, render } from "@hpcc-js/react";
8
- import { Border2 } from "@hpcc-js/layout";
9
- const PKG_NAME = "@hpcc-js/timeline";
10
- const PKG_VERSION = "3.2.1";
11
- const BUILD_VERSION = "3.15.1";
12
- const _MiniGantt = class _MiniGantt extends SVGWidget {
13
- tlAxis;
14
- brAxis;
15
- verticalBands;
16
- _zoom;
17
- gUpperContent;
18
- gUpperAxis;
19
- gMiddleContent;
20
- gLowerAxis;
21
- gLowerContent;
22
- localRect = local();
23
- localEntityPin = local();
24
- tooltipFormatter;
25
- _dateCache;
26
- rootExtent;
27
- _title_idx = 0;
28
- _startDate_idx = 1;
29
- _endDate_idx = 2;
30
- _icon_idx = -1;
31
- _color_idx = -1;
32
- _yoffset_idx = -1;
33
- constructor() {
34
- super();
35
- ITooltip.call(this);
36
- Utility.SimpleSelectionMixin.call(this);
37
- this._drawStartPos = "origin";
38
- this.tooltipHTML((d) => `<center>${d[this._title_idx]}</center><br>${this.tooltipFormatter(this.brAxis.parse(d[this._startDate_idx]))} -> ${this.tooltipFormatter(this.brAxis.parse(d[this._endDate_idx]))}`);
39
- this.tlAxis = new Axis().type("time");
40
- this.brAxis = new Axis().type("time");
41
- this.verticalBands = scaleBand().paddingOuter(0.2).paddingInner(0.2);
42
- }
43
- isHorizontal() {
44
- return this.orientation() === "horizontal";
45
- }
46
- fullExtent() {
47
- const data = [...this.data().map((d) => d[this._startDate_idx]), ...this.data().filter((d) => !!d[this._endDate_idx]).map((d) => d[this._endDate_idx])];
48
- return extent(data);
49
- }
50
- extent() {
51
- const extent2 = this.rootExtent ? [this.rootExtent[1], this.rootExtent[2]] : this.fullExtent();
52
- if (extent2[0] !== void 0 && extent2[1] !== void 0) {
53
- if (extent2[0] === extent2[1] || this.centerOnMostRecent()) {
54
- const parser = timeParse(this.timePattern());
55
- const formatter = timeFormat(this.timePattern());
56
- const date1 = parser(extent2[0]);
57
- const date2 = parser(extent2[1]);
58
- if (extent2[0] === extent2[1]) {
59
- extent2[0] = formatter(new Date(date1.setFullYear(date1.getFullYear() - 1)));
60
- extent2[1] = formatter(new Date(date1.setFullYear(date1.getFullYear() + 2)));
61
- } else {
62
- const time1 = date1.getTime();
63
- const timeDiff = date2.getTime() - time1;
64
- extent2[0] = formatter(date1);
65
- extent2[1] = formatter(new Date(time1 + timeDiff * 2));
66
- }
67
- }
68
- }
69
- return extent2;
70
- }
71
- dataStartPos(d) {
72
- if (typeof this._dateCache[d[this._startDate_idx]] !== "undefined") {
73
- return this._dateCache[d[this._startDate_idx]];
74
- }
75
- const pos = this.brAxis.scalePos(d[this._startDate_idx]);
76
- this._dateCache[d[this._startDate_idx]] = pos;
77
- return pos;
78
- }
79
- dataEndPos(d) {
80
- if (typeof this._dateCache[d[this._endDate_idx]] !== "undefined") {
81
- return this._dateCache[d[this._endDate_idx]];
82
- }
83
- const pos = this.brAxis.scalePos(d[this._endDate_idx]);
84
- this._dateCache[d[this._endDate_idx]] = pos;
85
- return pos;
86
- }
87
- dataWidth(d) {
88
- return this.dataEndPos(d) - this.dataStartPos(d);
89
- }
90
- transform;
91
- resetZoom() {
92
- this._zoom.transform(this.element(), zoomIdentity.translate(0, this.isHorizontal() ? 0 : this.height()));
93
- }
94
- zoomed() {
95
- this.transform = d3Event().transform;
96
- this.render();
97
- }
98
- background;
99
- enter(domNode, element) {
100
- super.enter(domNode, element);
101
- this._zoom = zoom().scaleExtent([0, this.maxZoom()]).on("zoom", () => {
102
- this.zoomed();
103
- });
104
- this.background = element.append("rect").attr("fill", "white").attr("opacity", 0).on("dblclick", () => {
105
- d3Event().stopPropagation();
106
- delete this.rootExtent;
107
- this.resetZoom();
108
- });
109
- this.gUpperContent = element.append("g").attr("class", "gUpperContent");
110
- this.gUpperAxis = element.append("g").attr("class", "gUpperAxis");
111
- this.gMiddleContent = element.append("g").attr("class", "gMiddleContent");
112
- this.gLowerAxis = element.append("g").attr("class", "gLowerAxis");
113
- this.gLowerContent = element.append("g").attr("class", "gLowerContent");
114
- this.tlAxis.target(this.gUpperAxis.node()).tickFormat(this.tickFormat()).guideTarget(this.gUpperAxis.append("g").node()).shrinkToFit("none").overlapMode(this.tickFormat_exists() ? "stagger" : "none").extend(0.1);
115
- this.brAxis.target(this.gLowerAxis.node()).tickFormat(this.tickFormat()).guideTarget(this.gLowerAxis.append("g").node()).shrinkToFit("none").overlapMode(this.tickFormat_exists() ? "stagger" : "none").extend(0.1);
116
- element.call(this._zoom);
117
- this._selection.widgetElement(this.gMiddleContent);
118
- }
119
- _prevIsHorizontal;
120
- update(domNode, element) {
121
- super.update(domNode, element);
122
- this._dateCache = {};
123
- this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
124
- this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
125
- this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
126
- this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
127
- this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
128
- this._yoffset_idx = this.yOffsetColumn() !== null ? this.columns().indexOf(this.yOffsetColumn()) : this._yoffset_idx;
129
- if (this._prevIsHorizontal !== this.isHorizontal()) {
130
- this._prevIsHorizontal = this.isHorizontal();
131
- this.resetZoom();
132
- return;
133
- }
134
- this.tooltipFormatter = timeFormat(this.tooltipTimeFormat());
135
- const width = this.width();
136
- const height = this.height();
137
- this.background.attr("x", 0).attr("y", 0).attr("width", width).attr("height", height);
138
- const extent2 = this.extent();
139
- this.tlAxis.x(width / 2).orientation(this.isHorizontal() ? "top" : "left").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(width - 1).low(extent2[0]).high(extent2[1]).updateScale();
140
- this.brAxis.x(width / 2).y(height / 2).orientation(this.isHorizontal() ? "bottom" : "right").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(width - 1).height(height).low(extent2[0]).high(extent2[1]).updateScale();
141
- if (this.transform) {
142
- let low;
143
- let hi;
144
- if (this.isHorizontal()) {
145
- low = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(0)));
146
- hi = this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(width - 1)));
147
- } else {
148
- low = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(0)));
149
- hi = this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(height - 1)));
150
- }
151
- this.tlAxis.low(low).high(hi).updateScale();
152
- this.brAxis.low(low).high(hi).updateScale();
153
- }
154
- const data = this.data().sort(this.isHorizontal() ? (l, r) => {
155
- const retVal = this.brAxis.scalePos(l[1]) - this.brAxis.scalePos(r[1]);
156
- if (retVal === 0) {
157
- return ("" + l[0]).localeCompare("" + r[0]);
158
- }
159
- return retVal;
160
- } : (l, r) => {
161
- return this.brAxis.scalePos(r[1]) - this.brAxis.scalePos(l[1]);
162
- });
163
- const events = data.filter((d) => !d[this._endDate_idx]);
164
- const ranges = data.filter((d) => !!d[this._endDate_idx]);
165
- this.tlAxis.render();
166
- this.brAxis.render();
167
- const brAxisBBox = this.brAxis.getBBox();
168
- let upperContentHeight = this.updateEntityPins(events);
169
- const lowerAxisHeight = brAxisBBox.height;
170
- let lowerHeight = height - upperContentHeight;
171
- const minYOffset = this._yoffset_idx !== -1 ? Math.min.apply(void 0, this.data().filter((row) => !isNaN(row[this._yoffset_idx])).map((row) => row[this._yoffset_idx])) : 0;
172
- if (events.length > 0 && ranges.length === 0) {
173
- this.tlAxis.visible(false);
174
- let y_offset = upperContentHeight / 4;
175
- if (y_offset > height / 2 - lowerAxisHeight) {
176
- y_offset = height / 2 - lowerAxisHeight;
177
- }
178
- const upperContentYOffset = height / 2 + y_offset;
179
- const lowerAxisYOffset = (height / 2 - lowerAxisHeight - y_offset) * -1;
180
- const halfMinYOffset = minYOffset !== 0 ? minYOffset / 2 : 0;
181
- this.gUpperContent.attr("transform", `translate(0, ${upperContentYOffset - halfMinYOffset})`);
182
- this.gLowerAxis.attr("transform", `translate(0, ${lowerAxisYOffset - halfMinYOffset})`);
183
- } else if (events.length === 0 && ranges.length > 0) {
184
- this.tlAxis.visible(true);
185
- this.gUpperContent.attr("transform", `translate(0, ${upperContentHeight})`);
186
- this.gUpperAxis.attr("transform", `translate(0, ${upperContentHeight})`);
187
- } else {
188
- upperContentHeight -= minYOffset;
189
- lowerHeight += minYOffset;
190
- this.tlAxis.visible(true);
191
- this.gUpperContent.attr("transform", `translate(0, ${upperContentHeight})`);
192
- this.gUpperAxis.attr("transform", `translate(0, ${upperContentHeight})`);
193
- this.gMiddleContent.attr("transform", `translate(0, ${upperContentHeight})`);
194
- }
195
- this.tlAxis.render();
196
- const tlAxisBBox = this.tlAxis.getBBox();
197
- const bucketData = [];
198
- const bucketIndex = {};
199
- for (const range of ranges) {
200
- for (let i = 0; i < bucketData.length; ++i) {
201
- const bucket = bucketData[i];
202
- if (bucket.endPos + this.overlapTolerence() <= this.dataStartPos(range)) {
203
- bucketIndex[range] = i;
204
- bucket.endPos = this.dataEndPos(range);
205
- break;
206
- }
207
- }
208
- if (bucketIndex[range] === void 0) {
209
- bucketIndex[range] = bucketData.length;
210
- bucketData.push({
211
- endPos: this.dataEndPos(range)
212
- });
213
- }
214
- }
215
- const vbLower = this.isHorizontal() ? 0 + tlAxisBBox.height : 0 + tlAxisBBox.width;
216
- const vbHigher = this.isHorizontal() ? lowerHeight - brAxisBBox.height : width - brAxisBBox.width;
217
- this.verticalBands.range([vbLower, vbHigher]).domain(bucketData.map((_d, i) => i));
218
- if (ranges.length > 0) {
219
- this.updateEventRanges(events, ranges, bucketIndex, lowerHeight, tlAxisBBox, brAxisBBox, width);
220
- }
221
- }
222
- updateEntityPins(events) {
223
- let event_height = 0;
224
- const context = this;
225
- const entityPins = this.gUpperContent.selectAll(".entity_pin").data(events, (d) => d[0] + ":" + d[1]);
226
- const eventFontColor_idx = this.eventFontColorColumn() ? this.columns().indexOf(this.eventFontColorColumn()) : -1;
227
- const eventBorderColor_idx = this.eventBorderColorColumn() ? this.columns().indexOf(this.eventBorderColorColumn()) : -1;
228
- const eventBackgroundColor_idx = this.eventBackgroundColorColumn() ? this.columns().indexOf(this.eventBackgroundColorColumn()) : -1;
229
- const title_counts = {};
230
- for (const d of events) {
231
- const type = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : d[0];
232
- title_counts[type] = title_counts[type] ? title_counts[type] + 1 : 1;
233
- }
234
- const title_types = Object.keys(title_counts);
235
- const title_group_offset = context.eventGroupOffset();
236
- const entityPinsEnter = entityPins.enter().append("g").attr("class", "entity_pin");
237
- entityPinsEnter.append("line").attr("class", "entity_line");
238
- entityPinsEnter.on("mouseover", function(d) {
239
- select(this).raise();
240
- }).each(function(d, i) {
241
- const entityPin = new EntityPin().target(this).icon("").iconOnlyShowOnHover(context.hideIconWhenCollapsed()).titleOnlyShowOnHover(context.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed()).iconDiameter(18).iconPaddingPercent(1).titleFontSize(14).descriptionColor("#333").descriptionFontSize(15).iconColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx]).titleColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx]).descriptionColor(eventFontColor_idx === -1 ? "#333" : d[eventFontColor_idx]).backgroundShape("pin").backgroundColorFill(eventFontColor_idx === -1 ? "#f8f8f8" : d[eventBackgroundColor_idx]).backgroundColorStroke(eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx]).cornerRadius(5).arrowHeight(10).arrowWidth(16);
242
- context.localEntityPin.set(this, entityPin);
243
- }).merge(entityPins).each(function(d, i) {
244
- const entityPin = context.localEntityPin.get(this);
245
- const _title = typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : entityPin.title();
246
- const x_offset = context.dataStartPos(d) - 0;
247
- let y_offset = title_types.indexOf(_title) % context.eventGroupMod() * title_group_offset - 5;
248
- if (typeof d[context._yoffset_idx] !== "undefined") y_offset += d[context._yoffset_idx] ? d[context._yoffset_idx] : 0;
249
- if (d[context._title_idx] !== entityPin.title() && d[context._startDate_idx] !== entityPin.description()) {
250
- const parsed_start_time = context.brAxis.parse(d[context._startDate_idx]);
251
- const formatted_start_time = context.tooltipFormatter(parsed_start_time);
252
- entityPin.x(x_offset).y(y_offset).iconOnlyShowOnHover(context.hideIconWhenCollapsed()).titleOnlyShowOnHover(context.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(context.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(context.hideAnnotationsWhenCollapsed()).icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : entityPin.icon()).title(_title).description(formatted_start_time).animationFrameRender();
253
- } else {
254
- entityPin.move({ x: x_offset, y: y_offset });
255
- }
256
- const calc_height = entityPin.calcHeight();
257
- if (event_height < calc_height) event_height = calc_height;
258
- select(this).selectAll(".entity_line").attr("x1", x_offset).attr("x2", x_offset).attr("y1", 0).attr("y2", y_offset).style("stroke", eventFontColor_idx === -1 ? "#ccc" : d[eventBorderColor_idx]).style("stroke-width", 1);
259
- });
260
- entityPins.exit().each(function(d, i) {
261
- const entityPin = context.localEntityPin.get(this);
262
- entityPin.target(null);
263
- }).remove();
264
- const event_offset = Math.abs(Math.min(events.length, context.eventGroupMod()) * context.eventGroupOffset());
265
- return event_height + event_offset;
266
- }
267
- updateEventRanges(events, ranges, bucketIndex, eventRangeHeight, tlAxisBBox, brAxisBBox, width) {
268
- const context = this;
269
- const lines = this.gMiddleContent.selectAll(".line").data(events, (d) => {
270
- return d[context._title_idx];
271
- });
272
- lines.enter().append("line").attr("class", "line").merge(lines).attr(this.isHorizontal() ? "x1" : "y1", (d) => this.dataStartPos(d) - 0).attr(this.isHorizontal() ? "x2" : "y2", (d) => this.dataStartPos(d) - 0).attr(this.isHorizontal() ? "y1" : "x1", this.isHorizontal() ? tlAxisBBox.height : tlAxisBBox.width).attr(this.isHorizontal() ? "y2" : "x2", this.isHorizontal() ? eventRangeHeight - brAxisBBox.height : width - brAxisBBox.width);
273
- lines.exit().remove();
274
- const buckets = this.gMiddleContent.selectAll(".buckets").data(ranges, (d) => d[context._title_idx]);
275
- buckets.enter().append("g").attr("class", "buckets").call(this._selection.enter.bind(this._selection)).each(function(d) {
276
- const entityRect = new EntityRect().target(this).iconDiameter(28).iconPaddingPercent(0).titleFontSize(28).titleColor(context.rangeFontColor()).descriptionColor(context.rangeFontColor()).iconColor(context.rangeFontColor()).backgroundShape("rect").backgroundColorFill(d[context._color_idx]);
277
- context.localRect.set(this, entityRect);
278
- context.enterEntityRect(entityRect, d);
279
- }).on("click", function(d) {
280
- context.click(context.rowToObj(d), "range", context._selection.selected(this));
281
- }, false).on("dblclick", function(d) {
282
- context.rootExtent = d;
283
- context.resetZoom();
284
- context.dblclick(context.rowToObj(d), "range", context._selection.selected(this));
285
- }, true).on("mouseout.tooltip", this.tooltip.hide).on("mousemove.tooltip", this.tooltip.show).merge(buckets).attr("transform", (d) => context.isHorizontal() ? `translate(${this.dataStartPos(d)}, ${this.verticalBands(bucketIndex[d])}) ` : `translate(${this.verticalBands(bucketIndex[d])}, ${this.dataStartPos(d)}) `).each(function(d) {
286
- const textBox = context.localRect.get(this);
287
- const x = context.dataWidth(d) / 2;
288
- const y = context.verticalBands.bandwidth() / 2;
289
- const rectWidth = Math.max(context.dataWidth(d), 2);
290
- const rectHeight = Math.max(context.verticalBands.bandwidth(), 2);
291
- const fontHeightRatio = 0.618;
292
- const paddingRatio = (1 - fontHeightRatio) / 2;
293
- const paddingSize = paddingRatio * rectHeight;
294
- const fontSize = rectHeight * fontHeightRatio;
295
- const iconSize = fontSize;
296
- textBox.pos(context.isHorizontal() ? { x, y } : { x: y, y: x }).fixedHeight(context.isHorizontal() ? rectHeight : rectWidth).fixedWidth(context.isHorizontal() ? rectWidth : rectHeight).icon(typeof d[context._icon_idx] !== "undefined" ? d[context._icon_idx] : "").title(typeof d[context._title_idx] !== "undefined" ? d[context._title_idx] : "").padding(paddingSize).iconDiameter(iconSize).titleFontSize(fontSize);
297
- if (iconSize * 1.5 > rectWidth) {
298
- textBox.icon(null);
299
- }
300
- context.updateEntityRect(textBox, d[context._icon_idx]);
301
- textBox.render();
302
- });
303
- buckets.exit().remove();
304
- }
305
- exit(domNode, element) {
306
- this.brAxis.target(null);
307
- this.tlAxis.target(null);
308
- super.exit(domNode, element);
309
- }
310
- // Events ---
311
- click(row, col, sel) {
312
- }
313
- dblclick(row, col, sel) {
314
- }
315
- enterEntityRect(textbox, d) {
316
- }
317
- updateEntityRect(textbox, d) {
318
- }
319
- };
320
- __name(_MiniGantt, "MiniGantt");
321
- let MiniGantt = _MiniGantt;
322
- MiniGantt.prototype._class += " timeline_MiniGantt";
323
- MiniGantt.prototype.implements(ITooltip.prototype);
324
- MiniGantt.prototype.mixin(Utility.SimpleSelectionMixin);
325
- MiniGantt.prototype.publish("timePattern", "%Y-%m-%d", "string", "timePattern");
326
- MiniGantt.prototype.publish("tickFormat", null, "string", "tickFormat", void 0, { optional: true });
327
- MiniGantt.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "tooltipTimeFormat");
328
- MiniGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
329
- MiniGantt.prototype.publish("orientation", "horizontal", "set", "orientation", ["horizontal", "vertical"]);
330
- MiniGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
331
- MiniGantt.prototype.publish("titleColumn", null, "string", "titleColumn");
332
- MiniGantt.prototype.publish("startDateColumn", null, "string", "startDateColumn");
333
- MiniGantt.prototype.publish("endDateColumn", null, "string", "endDateColumn");
334
- MiniGantt.prototype.publish("iconColumn", null, "string", "iconColumn");
335
- MiniGantt.prototype.publish("colorColumn", null, "string", "colorColumn");
336
- MiniGantt.prototype.publish("yOffsetColumn", null, "string", "yOffsetColumn");
337
- MiniGantt.prototype.publish("maxZoom", 16, "number", "maxZoom");
338
- MiniGantt.prototype.publish("eventGroupOffset", -50, "number", "eventGroupOffset");
339
- MiniGantt.prototype.publish("eventGroupMod", 5, "number", "eventGroupMod");
340
- MiniGantt.prototype.publish("eventFontColorColumn", null, "string", "eventFontColorColumn");
341
- MiniGantt.prototype.publish("eventBorderColorColumn", null, "string", "eventBorderColorColumn");
342
- MiniGantt.prototype.publish("eventBackgroundColorColumn", null, "string", "eventBackgroundColorColumn");
343
- MiniGantt.prototype.publish("hideIconWhenCollapsed", false, "boolean", "hideIconWhenCollapsed");
344
- MiniGantt.prototype.publish("hideTitleWhenCollapsed", false, "boolean", "hideTitleWhenCollapsed");
345
- MiniGantt.prototype.publish("hideDescriptionWhenCollapsed", false, "boolean", "hideDescriptionWhenCollapsed");
346
- MiniGantt.prototype.publish("hideAnnotationsWhenCollapsed", true, "boolean", "hideAnnotationsWhenCollapsed");
347
- MiniGantt.prototype.publish("centerOnMostRecent", false, "boolean", "If true, the timeline will be centered on the most recent data point");
348
- const _ReactGantt = class _ReactGantt extends SVGZoomWidget {
349
- _selection = new Utility.Selection(this);
350
- _buckets;
351
- _interpolateX;
352
- _interpolateY;
353
- _bucketsBySeries;
354
- _dataBySeries;
355
- _origIdxMap;
356
- _seriesBackgrounds;
357
- _maxFontSize;
358
- _tooltip;
359
- _minStart;
360
- _maxEnd;
361
- _title_idx = 0;
362
- _startDate_idx = 1;
363
- _endDate_idx = 2;
364
- _icon_idx = -1;
365
- _color_idx = -1;
366
- _series_idx = -1;
367
- _bucket_idx = -1;
368
- _yoffset_idx = -1;
369
- _maxX;
370
- _maxY;
371
- _rangeOptions = {
372
- rangePadding: 2,
373
- fontFamily: "Verdana",
374
- fontSize: 12,
375
- fill: "white",
376
- stroke: "black",
377
- textFill: "black",
378
- cornerRadius: 3,
379
- strokeWidth: 0
380
- };
381
- constructor(drawStartPosition = "origin") {
382
- super();
383
- this._drawStartPos = drawStartPosition;
384
- this.showToolbar_default(false);
385
- this._tooltip = new HTMLTooltip();
386
- this._tooltip.tooltipHTML((d) => {
387
- return `<div style="text-align:center;">${d[0]}<br/><br/>${d[1]} -&gt; ${d[2]}</div>`;
388
- });
389
- this._tooltip.followCursor(true);
390
- }
391
- selection(_) {
392
- if (!arguments.length) return this._selection.get();
393
- this._selection.set(_);
394
- return this;
395
- }
396
- _rangeRenderer = LabelledRect;
397
- rangeRenderer(_) {
398
- if (!arguments.length) return this._rangeRenderer;
399
- this._rangeRenderer = _;
400
- return this._rangeRenderer;
401
- }
402
- enter(domNode, element) {
403
- super.enter(domNode, element);
404
- const context = this;
405
- element.on("click", function(d) {
406
- context._selection.clear();
407
- });
408
- this._tooltip.target(domNode);
409
- }
410
- update(domNode, element) {
411
- super.update(domNode, element);
412
- this.zoomExtent([0.05, this.maxZoom()]);
413
- this._title_idx = this.titleColumn() !== null ? this.columns().indexOf(this.titleColumn()) : this._title_idx;
414
- this._startDate_idx = this.startDateColumn() !== null ? this.columns().indexOf(this.startDateColumn()) : this._startDate_idx;
415
- this._endDate_idx = this.endDateColumn() !== null ? this.columns().indexOf(this.endDateColumn()) : this._endDate_idx;
416
- this._icon_idx = this.iconColumn() !== null ? this.columns().indexOf(this.iconColumn()) : this._icon_idx;
417
- this._color_idx = this.colorColumn() !== null ? this.columns().indexOf(this.colorColumn()) : this._color_idx;
418
- this._series_idx = this.seriesColumn() !== null ? this.columns().indexOf(this.seriesColumn()) : this._series_idx;
419
- this._bucket_idx = this.bucketColumn() !== null ? this.columns().indexOf(this.bucketColumn()) : -1;
420
- const context = this;
421
- const w = this.width();
422
- const x0 = 0;
423
- const x1 = w;
424
- this._interpolateX = scaleLinear().domain([this._minStart, this._maxEnd]).range([x0, x1]);
425
- this.data().sort((a, b) => a[1] - b[1]);
426
- if (this._series_idx > -1) {
427
- this._origIdxMap = {};
428
- this._dataBySeries = {};
429
- this._bucketsBySeries = {};
430
- this.data().forEach((dataRow, origIdx) => {
431
- const seriesKey = dataRow[this._series_idx];
432
- if (!this._dataBySeries[seriesKey]) {
433
- this._origIdxMap[seriesKey] = {};
434
- this._dataBySeries[seriesKey] = [];
435
- }
436
- this._dataBySeries[seriesKey].push({
437
- dataRow,
438
- origIdx
439
- });
440
- });
441
- const gutter = this.gutter();
442
- let bucketOffset = 0;
443
- const seriesKeys = Object.keys(this._dataBySeries);
444
- seriesKeys.forEach((seriesKey) => {
445
- this._dataBySeries[seriesKey].sort((a, b) => a.dataRow[1] - b.dataRow[1]);
446
- this._bucketsBySeries[seriesKey] = this.calcBuckets(this._dataBySeries[seriesKey].map((n) => n.dataRow), 1, 2);
447
- this._bucketsBySeries[seriesKey].bucketHeight = this.bucketHeight();
448
- this._bucketsBySeries[seriesKey].bucketOffset = bucketOffset;
449
- bucketOffset += (this._bucketsBySeries[seriesKey].bucketHeight + this.strokeWidth() + this.gutter()) * (this._bucketsBySeries[seriesKey].maxBucket + 1);
450
- this._dataBySeries[seriesKey].forEach((n, i) => {
451
- this._origIdxMap[seriesKey][n.origIdx] = i;
452
- });
453
- });
454
- this._seriesBackgrounds = this._renderElement.selectAll(".series-background").data(seriesKeys.map((key) => {
455
- return this._bucketsBySeries[key];
456
- }));
457
- this._seriesBackgrounds.join(
458
- (enter) => enter.append("rect").attr("class", "series-background"),
459
- (update) => update,
460
- (exit) => exit.each(function(d) {
461
- delete d.element;
462
- }).remove()
463
- ).attr("opacity", (d) => d.props && d.props.hidden ? 0 : 1).each(function(d, i) {
464
- select(this).attr("x", 0).attr("y", d.bucketOffset - gutter / 2).attr("width", w).attr("height", (d.bucketHeight + gutter) * (d.maxBucket + 1) + gutter).attr("fill", i % 2 ? context.oddSeriesBackground() : context.evenSeriesBackground());
465
- });
466
- } else {
467
- if (this._bucket_idx !== -1) {
468
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx, this._bucket_idx);
469
- } else {
470
- this._buckets = this.calcBuckets(this.data(), this._startDate_idx, this._endDate_idx);
471
- }
472
- }
473
- const interpedStart = this._interpolateX(this._minStart);
474
- this.zoomTo(
475
- [interpedStart, 0],
476
- 1
477
- );
478
- const bucketHeight = this.bucketHeight();
479
- this.setRangeOptions();
480
- this._maxFontScale = bucketHeight - this.rangePadding() * 2;
481
- this.measureDataText();
482
- const itemSelection = this._renderElement.selectAll(".item").data(this.data());
483
- const borderOffset1 = this.strokeWidth();
484
- const borderOffset2 = borderOffset1 * 2;
485
- itemSelection.join(
486
- (enter) => enter.append("g").attr("class", "item").on("click.selectionBag", function(d, i) {
487
- const _id = d.id === void 0 ? i : d.id;
488
- if (context._selection.isSelected({ _id, element: d.element })) {
489
- context._selection.clear();
490
- } else {
491
- context._selection.click(
492
- {
493
- _id,
494
- element: /* @__PURE__ */ __name(() => d.element, "element")
495
- },
496
- d3Event
497
- );
498
- }
499
- context.selectionChanged();
500
- d3Event().stopPropagation();
501
- }).on("click", function(d) {
502
- const selected = d.element.classed("selected");
503
- if (d[context.columns().length]) {
504
- d.__lparam = d[context.columns().length];
505
- }
506
- context.click(d, "", selected);
507
- }).on("dblclick", function(d) {
508
- const selected = d.element.classed("selected");
509
- if (d[context.columns().length]) {
510
- d.__lparam = d[context.columns().length];
511
- }
512
- context.click(d, "", selected);
513
- }).on("mousein", function(d) {
514
- context.highlightItem(select(this), d);
515
- const selected = d.element.classed("selected");
516
- context.mousein(d, "", selected);
517
- }).on("mouseover", function(d) {
518
- const d3evt = d3Event();
519
- context._tooltip._triggerElement = d.element;
520
- context._tooltip._cursorLoc = [
521
- d3evt.clientX,
522
- d3evt.clientY
523
- ];
524
- context._tooltip.data(d).visible(true).fitContent(true).render();
525
- context.highlightItem(select(this), d);
526
- const selected = d.element.classed("selected");
527
- context.mouseover(d, "", selected);
528
- }).on("mouseout", function(d) {
529
- context._tooltip.visible(false).render();
530
- context.highlightItem(null, null);
531
- const selected = d.element.classed("selected");
532
- context.mouseout(d, "", selected);
533
- }).each(function(d, i) {
534
- d.that = this;
535
- d.element = select(this);
536
- d.x = context._interpolateX(d[1]);
537
- const endX = context._interpolateX(d[2]);
538
- if (context._series_idx > -1) {
539
- const seriesKey = d[context._series_idx];
540
- const bucket = context._bucketsBySeries[seriesKey].bucketMap[context._origIdxMap[seriesKey][i]];
541
- d.y = context._bucketsBySeries[seriesKey].interpolateY(bucket) + context._bucketsBySeries[seriesKey].bucketOffset;
542
- } else {
543
- const _i = context._bucket_idx === -1 ? i : d[context._bucket_idx];
544
- d.y = context._buckets.interpolateY(context._buckets.bucketMap[_i]);
545
- }
546
- d.props = {
547
- ...d[3],
548
- text: d[0]
549
- };
550
- d.props.width = endX - d.x;
551
- d.props.height = bucketHeight;
552
- d.x += borderOffset1;
553
- d.y += borderOffset1;
554
- d.props.width -= borderOffset2;
555
- d.props.height -= borderOffset2;
556
- d.element.attr("transform", `translate(${d.x + d.props.width / 2} ${d.y + d.props.height / 2})`);
557
- }),
558
- (update) => update,
559
- (exit) => exit.each(function(d) {
560
- delete d.element;
561
- }).remove()
562
- ).attr("opacity", (d) => d.props && d.props.hidden ? 0 : 1).each(function(d, i) {
563
- d.that = this;
564
- if (context._series_idx > -1) {
565
- const seriesKey = d[context._series_idx];
566
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions, seriesKey);
567
- } else {
568
- d.x = context.renderRangeElement(d, i, false, context._rangeOptions);
569
- }
570
- }).on("dblclick.zoom", (d) => {
571
- const x12 = this._interpolateX(d[1]);
572
- const x2 = this._interpolateX(d[2]);
573
- const xRange = x2 - x12;
574
- const xScale = w / xRange;
575
- this.zoomTo(
576
- [
577
- -x12 * xScale,
578
- 0
579
- ],
580
- xScale
581
- );
582
- });
583
- element.on("dblclick.zoom", null);
584
- }
585
- exit(domNode, element) {
586
- this._tooltip.target(null);
587
- super.exit(domNode, element);
588
- }
589
- renderRangeElement(d, i, transformEach = false, options = {}, seriesKey) {
590
- const borderOffset1 = options.strokeWidth;
591
- const borderOffset2 = borderOffset1 * 2;
592
- const padding = options.rangePadding;
593
- let endX;
594
- const x = isNaN(this._transform.x) ? 0 : this._transform.x;
595
- const k = isNaN(this._transform.k) ? 1 : this._transform.k;
596
- let b;
597
- const bucketHeight = this.bucketHeight();
598
- d.that.setAttribute("data-series", seriesKey);
599
- if (this._color_idx > -1) {
600
- d.that.setAttribute("data-color", d[this._color_idx]);
601
- }
602
- if (seriesKey !== void 0) {
603
- b = this._bucketsBySeries[seriesKey].bucketMap[this._origIdxMap[seriesKey][i]];
604
- d.that.setAttribute("data-b", b);
605
- d.that.setAttribute("data-bucketOffset", this._bucketsBySeries[seriesKey].bucketOffset);
606
- d.y = this._bucketsBySeries[seriesKey].interpolateY(b) + this._bucketsBySeries[seriesKey].bucketOffset;
607
- d.that.setAttribute("data-dy", d.y);
608
- } else {
609
- b = this._buckets.bucketMap[i];
610
- d.y = this._buckets.interpolateY(b);
611
- }
612
- if (this._color_idx > -1) {
613
- options.fill = d[this._color_idx];
614
- }
615
- if (!transformEach) {
616
- d.x = this._interpolateX(d[1]);
617
- endX = this._interpolateX(d[2]);
618
- d.props = {
619
- ...d[3],
620
- text: d[0]
621
- };
622
- d.props.width = (endX - d.x) / k;
623
- } else {
624
- d.x = this._interpolateX(d[1]) * k;
625
- endX = this._interpolateX(d[2]) * k;
626
- d.props = {
627
- ...d[3],
628
- text: d[0]
629
- };
630
- d.props.width = (endX - d.x) / k;
631
- d.x += x;
632
- d.props.width *= k;
633
- }
634
- d.props.height = bucketHeight;
635
- if (seriesKey === void 0 && this._buckets.bucketScale < 1) {
636
- d.props.height = this._buckets.bucketScale * bucketHeight;
637
- }
638
- if (d.element === void 0 && d.that) {
639
- d.element = select(d.that);
640
- }
641
- d.element.attr("transform", `translate(${d.x + d.props.width / 2} ${d.y + d.props.height / 2})`);
642
- d.x += borderOffset1;
643
- d.y += borderOffset1;
644
- d.props.width -= borderOffset2;
645
- d.props.height -= borderOffset2;
646
- d.props.width = d.props.width < 1 ? 1 : d.props.width;
647
- d.props.height = d.props.height < 1 ? 1 : d.props.height;
648
- let text = this.truncateText(d.props.text, d.props.width - padding, this._maxFontScale);
649
- if (text !== d.props.text) {
650
- text = this.truncateText(d.props.text, d.props.width - padding);
651
- } else {
652
- d.props.fontSize = this._maxFontScale * options.fontSize;
653
- }
654
- if (seriesKey === void 0 && this._buckets.bucketScale < 1) {
655
- d.props.fontSize = Math.min(this._maxFontScale, this._buckets.bucketScale) * options.fontSize;
656
- }
657
- if (!this._maxY || this._maxY < d.y + d.props.height) {
658
- this._maxY = d.y + d.props.height;
659
- }
660
- if (!this._maxX || this._maxX < d.x + d.props.width) {
661
- this._maxX = d.x + d.props.width;
662
- }
663
- render(
664
- this._rangeRenderer,
665
- {
666
- ...options,
667
- ...d.props,
668
- text
669
- },
670
- d.that
671
- );
672
- }
673
- setRangeOptions() {
674
- this._rangeOptions = {
675
- rangePadding: this.rangePadding(),
676
- fontFamily: this.fontFamily(),
677
- fontSize: this.fontSize(),
678
- strokeWidth: this.strokeWidth(),
679
- fill: this.fill(),
680
- stroke: this.stroke(),
681
- textFill: this.rangeFontColor(),
682
- cornerRadius: this.cornerRadius()
683
- };
684
- }
685
- _transform = { k: 1, x: 0, y: 0 };
686
- zoomed(transform) {
687
- this._transform = transform;
688
- switch (this.renderMode()) {
689
- case "scale-all":
690
- this._zoomScale = transform.k;
691
- this._zoomTranslate = [transform.x, 0];
692
- this._zoomG.attr("transform", `translate(${transform.x} ${0})scale(${transform.k} 1)`);
693
- break;
694
- default:
695
- const options = this._rangeOptions;
696
- this.data().forEach((d, i) => {
697
- if (this._color_idx > -1) {
698
- options.fill = d[this._color_idx];
699
- }
700
- if (this._series_idx > -1) {
701
- const seriesKey = d[this._series_idx];
702
- this.renderRangeElement(d, i, true, options, seriesKey);
703
- } else {
704
- this.renderRangeElement(d, i, true, options);
705
- }
706
- });
707
- }
708
- this.zoomedHook(transform);
709
- }
710
- zoomedHook(transform) {
711
- }
712
- calcBuckets(data, startKey, endKey, bucketKey) {
713
- const bucketMap = {};
714
- const bucketKeyMap = {};
715
- const tol = this.overlapTolerence();
716
- const buckets = [{ end: -Infinity }];
717
- let maxBucket = 0;
718
- if (bucketKey !== void 0) {
719
- data.forEach((d, i) => {
720
- bucketMap[i] = d[bucketKey];
721
- bucketKeyMap[d[bucketKey]] = true;
722
- });
723
- maxBucket = Object.keys(bucketKeyMap).length;
724
- } else {
725
- data.forEach((d, i) => {
726
- for (let i2 = 0; i2 < buckets.length; ++i2) {
727
- if (i === 0 || buckets[i2][endKey] + tol <= d[startKey]) {
728
- bucketMap[i] = i2;
729
- if (maxBucket < i2) maxBucket = i2;
730
- buckets[i2][endKey] = d[endKey];
731
- break;
732
- }
733
- }
734
- if (bucketMap[i] === void 0) {
735
- bucketMap[i] = buckets.length;
736
- const b = {};
737
- b[endKey] = d[endKey];
738
- buckets.push(b);
739
- }
740
- if (maxBucket < bucketMap[i]) maxBucket = bucketMap[i];
741
- });
742
- }
743
- const height = (maxBucket + 1) * (this.bucketHeight() + this.gutter());
744
- return {
745
- bucketMap,
746
- maxBucket,
747
- bucketScale: this.height() / height,
748
- interpolateY: scaleLinear().domain([0, maxBucket + 1]).range([0, Math.min(this.height(), height)])
749
- };
750
- }
751
- data(_) {
752
- const retVal = super.data.apply(this, arguments);
753
- if (arguments.length > 0) {
754
- this._minStart = Math.min(...this.data().map((n) => n[1])) ?? 0;
755
- this._maxEnd = Math.max(...this.data().map((n) => n[2])) ?? 1;
756
- this.measureDataText(true);
757
- }
758
- return retVal;
759
- }
760
- _textWidths;
761
- _maxFontScale;
762
- _characterWidths;
763
- _prevFontFamily;
764
- _prevFontSize;
765
- measureDataText(forceMeasure = false) {
766
- const textWidths = {};
767
- const characterWidths = {};
768
- const fontFamily = this.fontFamily();
769
- const fontSize = this.fontSize();
770
- const bucketHeight = this.bucketHeight();
771
- if (bucketHeight) {
772
- this._maxFontScale = (bucketHeight - this.rangePadding() * 2) / fontSize;
773
- }
774
- if (forceMeasure || this._prevFontFamily !== fontFamily || this._prevFontSize !== fontSize) {
775
- characterWidths["."] = Utility.textSize(".", fontFamily, fontSize).width;
776
- this.data().forEach((d) => {
777
- if (!textWidths[d[0]]) {
778
- textWidths[d[0]] = Utility.textSize(d[0], fontFamily, fontSize).width;
779
- }
780
- d[0].split("").forEach((char) => {
781
- if (!characterWidths[char]) {
782
- characterWidths[char] = Utility.textSize(char, fontFamily, fontSize).width;
783
- }
784
- });
785
- });
786
- this._textWidths = textWidths;
787
- this._characterWidths = characterWidths;
788
- }
789
- this._prevFontFamily = fontFamily;
790
- this._prevFontSize = fontSize;
791
- }
792
- truncateText(text, width, scale = 1) {
793
- const textFits = this._textWidths[text] * scale < width;
794
- if (textFits) {
795
- return text;
796
- }
797
- let ret = "";
798
- let sum = 0;
799
- const _width = width - this._characterWidths["."] * 3;
800
- for (const char of text) {
801
- sum += this._characterWidths[char];
802
- if (sum < _width) {
803
- ret += char;
804
- } else {
805
- break;
806
- }
807
- }
808
- return _width < 0 ? "" : ret + "...";
809
- }
810
- resize(_size) {
811
- let retVal;
812
- if (this.fitWidthToContent() || this.fitHeightToContent()) {
813
- retVal = super.resize.call(this, {
814
- width: _size.width,
815
- height: this._maxY
816
- });
817
- } else {
818
- retVal = super.resize.apply(this, arguments);
819
- }
820
- return retVal;
821
- }
822
- selectionChanged() {
823
- }
824
- highlightItem(_element, d) {
825
- }
826
- click(row, _col, sel) {
827
- }
828
- dblclick(row, _col, sel) {
829
- }
830
- mousein(row, _col, sel) {
831
- }
832
- mouseover(row, _col, sel) {
833
- }
834
- mouseout(row, _col, sel) {
835
- }
836
- };
837
- __name(_ReactGantt, "ReactGantt");
838
- let ReactGantt = _ReactGantt;
839
- ReactGantt.prototype._class += " timeline_ReactGantt";
840
- ReactGantt.prototype.publish("fitWidthToContent", false, "boolean", "If true, resize will simply reapply the bounding box width");
841
- ReactGantt.prototype.publish("fitHeightToContent", false, "boolean", "If true, resize will simply reapply the bounding box height");
842
- ReactGantt.prototype.publish("titleColumn", null, "string", "Column name to for the title");
843
- ReactGantt.prototype.publish("startDateColumn", null, "string", "Column name to for the start date");
844
- ReactGantt.prototype.publish("endDateColumn", null, "string", "Column name to for the end date");
845
- ReactGantt.prototype.publish("iconColumn", null, "string", "Column name to for the icon");
846
- ReactGantt.prototype.publish("colorColumn", null, "string", "Column name to for the color");
847
- ReactGantt.prototype.publish("seriesColumn", null, "string", "Column name to for the series identifier");
848
- ReactGantt.prototype.publish("bucketColumn", null, "string", "Column name to for the bucket identifier");
849
- ReactGantt.prototype.publish("renderMode", "default", "set", "Render modes vary in features and performance", ["default", "scale-all"]);
850
- ReactGantt.prototype.publish("rangePadding", 3, "number", "Padding within each range rectangle (pixels)");
851
- ReactGantt.prototype.publish("fill", "#1f77b4", "string", "Background color of range rectangle");
852
- ReactGantt.prototype.publish("stroke", null, "string", "Color of range rectangle border");
853
- ReactGantt.prototype.publish("strokeWidth", null, "number", "Width of range rectangle border (pixels)");
854
- ReactGantt.prototype.publish("cornerRadius", 3, "number", "Space between range buckets (pixels)");
855
- ReactGantt.prototype.publish("fontFamily", null, "string", "Font family within range rectangle", null, { optional: true });
856
- ReactGantt.prototype.publish("fontSize", 10, "number", "Size of font within range rectangle (pixels)");
857
- ReactGantt.prototype.publish("rangeFontColor", "#ecf0f1", "html-color", "rangeFontColor");
858
- ReactGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
859
- ReactGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
860
- ReactGantt.prototype.publish("bucketHeight", 100, "number", "Max height of range element (pixels)");
861
- ReactGantt.prototype.publish("gutter", 2, "number", "Space between range buckets (pixels)");
862
- ReactGantt.prototype.publish("maxZoom", 16, "number", "Maximum zoom");
863
- ReactGantt.prototype.publish("evenSeriesBackground", "#FFFFFF", "html-color", "Background color of even series rows");
864
- ReactGantt.prototype.publish("oddSeriesBackground", "#DDDDDD", "html-color", "Background color of odd series rows");
865
- const _ReactAxisGantt = class _ReactAxisGantt extends SVGWidget {
866
- _topAxis = new Axis("center").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");
867
- _gantt = new ReactGantt("center").stroke("#000000");
868
- _bottomAxis = new Axis("center").orientation("bottom").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");
869
- _topAxisElement;
870
- _contentElement;
871
- _bottomAxisElement;
872
- _topRect;
873
- _contentRect;
874
- _bottomRect;
875
- rangeRenderer;
876
- constructor() {
877
- super();
878
- this._drawStartPos = "origin";
879
- this.rangeRenderer = function() {
880
- const ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
881
- if (!arguments.length) return ret;
882
- return this;
883
- };
884
- }
885
- selection(_) {
886
- if (!arguments.length) return this._gantt.selection();
887
- this._gantt.selection(_);
888
- return this;
889
- }
890
- resizeWrappers() {
891
- const w = this.width();
892
- const h = this.height();
893
- const axisHeight = this.axisHeight();
894
- const contentHeight = h - axisHeight * 2;
895
- const borderOffset1 = this.strokeWidth();
896
- this._topRect.attr("height", axisHeight).attr("width", w).attr("fill", "transparent");
897
- this._topAxisElement.attr("transform", "translate(0 0)");
898
- this._topAxis.resize({ height: axisHeight, width: w });
899
- this._contentRect.attr("height", contentHeight).attr("width", w).attr("fill", "transparent");
900
- this._contentElement.attr("transform", `translate(0 ${axisHeight + borderOffset1})`);
901
- this._gantt.resize({ height: contentHeight, width: w });
902
- this._bottomRect.attr("height", axisHeight).attr("width", w).attr("fill", "transparent");
903
- this._bottomAxisElement.attr("transform", `translate(0 ${axisHeight + contentHeight + borderOffset1})`);
904
- this._bottomAxis.resize({ height: axisHeight, width: w });
905
- }
906
- enter(domNode, element) {
907
- super.enter(domNode, element);
908
- this._gantt.click = (row, col, sel) => {
909
- this.click(row, col, sel);
910
- };
911
- this._gantt.dblclick = (row, col, sel) => {
912
- this.dblclick(row, col, sel);
913
- };
914
- this._topAxisElement = element.append("g").attr("class", "top-axis-wrapper");
915
- this._topRect = this._topAxisElement.append("rect").attr("class", "top-axis-rect");
916
- this._contentElement = element.append("g").attr("class", "content-wrapper");
917
- this._contentRect = this._contentElement.append("rect").attr("class", "content-rect");
918
- this._bottomAxisElement = element.append("g").attr("class", "bottom-axis-wrapper");
919
- this._bottomRect = this._bottomAxisElement.append("rect").attr("class", "top-axis-rect");
920
- this._topAxis.target(this._topAxisElement.node());
921
- this._gantt.target(this._contentElement.node()).bucketHeight(30);
922
- this._bottomAxis.target(this._bottomAxisElement.node());
923
- this.resizeWrappers();
924
- this._gantt.zoomedHook = (transform) => {
925
- this.onzoom(transform);
926
- };
927
- }
928
- onzoom(transform) {
929
- const w = this.width();
930
- const low = this._gantt._minStart;
931
- const high = this._gantt._maxEnd;
932
- const range = high - low;
933
- const wpp = range / w;
934
- const nextLow = Math.floor(low - wpp * (transform.x / transform.k));
935
- const nextHigh = Math.ceil(range / transform.k + nextLow);
936
- this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(nextLow).high(nextHigh).render();
937
- this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(nextLow).high(nextHigh).render();
938
- }
939
- update(domNode, element) {
940
- super.update(domNode, element);
941
- this._topAxis.tickFormat(this.tickFormat()).render();
942
- this._bottomAxis.tickFormat(this.tickFormat()).render();
943
- this._gantt.render();
944
- }
945
- exit(domNode, element) {
946
- this._bottomAxis.target(null);
947
- this._gantt.target(null);
948
- this._topAxis.target(null);
949
- super.exit(domNode, element);
950
- }
951
- columns(_) {
952
- const retVal = super.columns.apply(this, arguments);
953
- if (arguments.length > 0) {
954
- this._gantt.columns(_);
955
- }
956
- return retVal;
957
- }
958
- data(_) {
959
- const retVal = super.data.apply(this, arguments);
960
- if (arguments.length > 0) {
961
- const ganttData = this.data().map((n) => {
962
- const ret = [...n];
963
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
964
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
965
- return ret;
966
- });
967
- this._gantt._minStart = Math.min(...ganttData.map((n) => n[1])) ?? 0;
968
- this._gantt._maxEnd = Math.max(...ganttData.map((n) => n[2])) ?? 1;
969
- this._gantt.data(ganttData);
970
- }
971
- return retVal;
972
- }
973
- resize(_size) {
974
- const retVal = super.resize.apply(this, arguments);
975
- if (this._topAxisElement) {
976
- this.resizeWrappers();
977
- }
978
- return retVal;
979
- }
980
- click(row, col, sel) {
981
- }
982
- dblclick(row, col, sel) {
983
- }
984
- tooltip() {
985
- return this._gantt._tooltip;
986
- }
987
- };
988
- __name(_ReactAxisGantt, "ReactAxisGantt");
989
- let ReactAxisGantt = _ReactAxisGantt;
990
- ReactAxisGantt.prototype._class += " timeline_ReactAxisGantt";
991
- ReactAxisGantt.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", void 0, { optional: true });
992
- ReactAxisGantt.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
993
- ReactAxisGantt.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
994
- ReactAxisGantt.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
995
- ReactAxisGantt.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
996
- ReactAxisGantt.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
997
- ReactAxisGantt.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
998
- ReactAxisGantt.prototype.publishProxy("gutter", "_gantt");
999
- ReactAxisGantt.prototype.publishProxy("renderMode", "_gantt");
1000
- ReactAxisGantt.prototype.publishProxy("strokeWidth", "_gantt");
1001
- ReactAxisGantt.prototype.publishProxy("fontSize", "_gantt");
1002
- ReactAxisGantt.prototype.publishProxy("fontFamily", "_gantt");
1003
- ReactAxisGantt.prototype.publishProxy("stroke", "_gantt");
1004
- ReactAxisGantt.prototype.publishProxy("cornerRadius", "_gantt");
1005
- ReactAxisGantt.prototype.publishProxy("titleColumn", "_gantt");
1006
- ReactAxisGantt.prototype.publishProxy("startDateColumn", "_gantt");
1007
- ReactAxisGantt.prototype.publishProxy("endDateColumn", "_gantt");
1008
- ReactAxisGantt.prototype.publishProxy("iconColumn", "_gantt");
1009
- ReactAxisGantt.prototype.publishProxy("colorColumn", "_gantt");
1010
- ReactAxisGantt.prototype.publishProxy("bucketColumn", "_gantt");
1011
- ReactAxisGantt.prototype.publishProxy("maxZoom", "_gantt");
1012
- ReactAxisGantt.prototype.publishProxy("bucketHeight", "_gantt");
1013
- const _ReactAxisGanttSeries = class _ReactAxisGanttSeries extends Border2 {
1014
- _topAxis = new Axis("origin").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");
1015
- _gantt = new ReactGantt("origin").stroke("#000000").fitHeightToContent(true);
1016
- _bottomAxis = new Axis("origin").orientation("bottom").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");
1017
- _topAxisElement;
1018
- _contentElement;
1019
- _bottomAxisElement;
1020
- _topRect;
1021
- _contentRect;
1022
- _bottomRect;
1023
- constructor() {
1024
- super();
1025
- this.centerOverflowX_default("hidden");
1026
- this.centerOverflowY_default("auto");
1027
- }
1028
- selection(_) {
1029
- if (!arguments.length) return this._gantt.selection();
1030
- this._gantt.selection(_);
1031
- return this;
1032
- }
1033
- rangeRenderer(_) {
1034
- const ret = this._gantt.rangeRenderer.apply(this._gantt, arguments);
1035
- if (!arguments.length) return ret;
1036
- return this;
1037
- }
1038
- resizeWrappers() {
1039
- const w = this.width();
1040
- const h = this.height();
1041
- const axisHeight = this.axisHeight();
1042
- const contentHeight = h - axisHeight * 2;
1043
- this.bottomHeight(axisHeight);
1044
- this._topWA.resize({
1045
- width: w,
1046
- height: axisHeight
1047
- });
1048
- this._centerWA.resize({
1049
- width: w,
1050
- height: contentHeight
1051
- });
1052
- this._bottomWA.resize({
1053
- width: w,
1054
- height: axisHeight
1055
- });
1056
- this.top().render();
1057
- this.bottom().render();
1058
- this.center().render();
1059
- }
1060
- enter(domNode, element) {
1061
- super.enter(domNode, element);
1062
- this._gantt.click = (row, col, sel) => {
1063
- this.click(row, col, sel);
1064
- };
1065
- this._gantt.dblclick = (row, col, sel) => {
1066
- this.dblclick(row, col, sel);
1067
- };
1068
- this.top(this._topAxis);
1069
- this.center(this._gantt);
1070
- this.bottom(this._bottomAxis);
1071
- this.resizeWrappers();
1072
- this._gantt.zoomedHook = (transform) => {
1073
- this.onzoom(transform);
1074
- };
1075
- }
1076
- onzoom(transform) {
1077
- const w = this.width();
1078
- const low = this._gantt._minStart;
1079
- const high = this._gantt._maxEnd;
1080
- const range = high - low;
1081
- const wpp = range / w;
1082
- const nextLow = Math.floor(low - wpp * (transform.x / transform.k));
1083
- const nextHigh = Math.ceil(range / transform.k + nextLow);
1084
- this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(nextLow).high(nextHigh).lazyRender();
1085
- this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(nextLow).high(nextHigh).lazyRender();
1086
- }
1087
- update(domNode, element) {
1088
- super.update(domNode, element);
1089
- this._topAxis.tickFormat(this.tickFormat()).render();
1090
- this._bottomAxis.tickFormat(this.tickFormat()).render();
1091
- this._gantt.render();
1092
- }
1093
- columns(_) {
1094
- const retVal = super.columns.apply(this, arguments);
1095
- if (arguments.length > 0) {
1096
- this._gantt.columns(_);
1097
- }
1098
- return retVal;
1099
- }
1100
- data(_) {
1101
- const retVal = super.data.apply(this, arguments);
1102
- if (arguments.length > 0) {
1103
- const ganttData = this.data().map((n) => {
1104
- const ret = [...n];
1105
- ret[1] = isNaN(n[1]) ? new Date(n[1]).getTime() : Number(n[1]);
1106
- ret[2] = isNaN(n[2]) ? new Date(n[2]).getTime() : Number(n[2]);
1107
- return ret;
1108
- });
1109
- this._gantt._minStart = min(ganttData, (n) => n[1]);
1110
- this._gantt._maxEnd = max(ganttData, (n) => n[2]);
1111
- this._gantt.data(ganttData);
1112
- }
1113
- return retVal;
1114
- }
1115
- resize(_size) {
1116
- const retVal = super.resize.apply(this, arguments);
1117
- if (this._topAxisElement) {
1118
- this.resizeWrappers();
1119
- }
1120
- return retVal;
1121
- }
1122
- click(row, col, sel) {
1123
- }
1124
- dblclick(row, col, sel) {
1125
- }
1126
- tooltip() {
1127
- return this._gantt._tooltip;
1128
- }
1129
- };
1130
- __name(_ReactAxisGanttSeries, "ReactAxisGanttSeries");
1131
- let ReactAxisGanttSeries = _ReactAxisGanttSeries;
1132
- ReactAxisGanttSeries.prototype._class += " timeline_ReactAxisGanttSeries";
1133
- ReactAxisGanttSeries.prototype.publish("tickFormat", null, "string", "Format rule applied to axis tick labels", void 0, { optional: true });
1134
- ReactAxisGanttSeries.prototype.publish("axisHeight", 22, "number", "Height of axes (pixels)");
1135
- ReactAxisGanttSeries.prototype.publish("overlapTolerence", 2, "number", "overlapTolerence");
1136
- ReactAxisGanttSeries.prototype.publish("smallestRangeWidth", 10, "number", "Width of the shortest range (pixels)");
1137
- ReactAxisGanttSeries.prototype.publish("axisFontSize", null, "number", "Font size of axis tick labels");
1138
- ReactAxisGanttSeries.prototype.publish("axisFontFamily", null, "string", "Font family of axis tick labels");
1139
- ReactAxisGanttSeries.prototype.publish("axisTickLength", null, "number", "Length of axis ticks");
1140
- ReactAxisGanttSeries.prototype.publishProxy("gutter", "_gantt");
1141
- ReactAxisGanttSeries.prototype.publishProxy("renderMode", "_gantt");
1142
- ReactAxisGanttSeries.prototype.publishProxy("strokeWidth", "_gantt");
1143
- ReactAxisGanttSeries.prototype.publishProxy("fontSize", "_gantt");
1144
- ReactAxisGanttSeries.prototype.publishProxy("fontFamily", "_gantt");
1145
- ReactAxisGanttSeries.prototype.publishProxy("stroke", "_gantt");
1146
- ReactAxisGanttSeries.prototype.publishProxy("cornerRadius", "_gantt");
1147
- ReactAxisGanttSeries.prototype.publishProxy("titleColumn", "_gantt");
1148
- ReactAxisGanttSeries.prototype.publishProxy("startDateColumn", "_gantt");
1149
- ReactAxisGanttSeries.prototype.publishProxy("endDateColumn", "_gantt");
1150
- ReactAxisGanttSeries.prototype.publishProxy("iconColumn", "_gantt");
1151
- ReactAxisGanttSeries.prototype.publishProxy("colorColumn", "_gantt");
1152
- ReactAxisGanttSeries.prototype.publishProxy("seriesColumn", "_gantt");
1153
- ReactAxisGanttSeries.prototype.publishProxy("bucketColumn", "_gantt");
1154
- ReactAxisGanttSeries.prototype.publishProxy("maxZoom", "_gantt");
1155
- ReactAxisGanttSeries.prototype.publishProxy("evenSeriesBackground", "_gantt");
1156
- ReactAxisGanttSeries.prototype.publishProxy("oddSeriesBackground", "_gantt");
1157
- ReactAxisGanttSeries.prototype.publishProxy("bucketHeight", "_gantt");
1158
- const _ReactTimeline = class _ReactTimeline extends ReactAxisGantt {
1159
- _axisLabelFormatter;
1160
- //TODO: add a type to this? d3 time formatting function type?
1161
- constructor() {
1162
- super();
1163
- this._drawStartPos = "origin";
1164
- this._topAxis.type("time");
1165
- this._bottomAxis.type("time");
1166
- this.tooltipHTML((d) => {
1167
- const parser = timeParse("%Q");
1168
- const startTime = parser(d[1]);
1169
- const endTime = parser(d[2]);
1170
- const formatter = timeFormat(this.tooltipTimeFormat());
1171
- return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
1172
- });
1173
- }
1174
- update(domNode, element) {
1175
- super.update(domNode, element);
1176
- if (this.timePattern_exists()) {
1177
- let minTimestamp = Infinity;
1178
- let maxTimestamp = -Infinity;
1179
- let lowDateStr = "";
1180
- let highDateStr = "";
1181
- this.data().map((n) => {
1182
- const start = new Date(n[1]).getTime();
1183
- const end = new Date(n[2]).getTime();
1184
- if (minTimestamp > start) {
1185
- minTimestamp = start;
1186
- lowDateStr = "" + n[1];
1187
- }
1188
- if (maxTimestamp < end) {
1189
- maxTimestamp = end;
1190
- highDateStr = "" + n[2];
1191
- }
1192
- });
1193
- const axisTickFormat = this._axisLabelFormatter ? this._axisLabelFormatter : this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : void 0;
1194
- this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(lowDateStr).high(highDateStr);
1195
- this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(lowDateStr).high(highDateStr);
1196
- if (axisTickFormat) {
1197
- this._topAxis.tickFormat(axisTickFormat);
1198
- this._bottomAxis.tickFormat(axisTickFormat);
1199
- } else {
1200
- this._topAxis.tickFormat_reset();
1201
- this._bottomAxis.tickFormat_reset();
1202
- }
1203
- this._gantt._minStart = minTimestamp;
1204
- this._gantt._maxEnd = maxTimestamp;
1205
- }
1206
- }
1207
- tooltipHTML(callback) {
1208
- this._tooltipHTML = callback;
1209
- this.tooltip().tooltipHTML(this._tooltipHTML);
1210
- return this;
1211
- }
1212
- parseAxisValue(v) {
1213
- const parseTime2 = timeParse("%Q");
1214
- const parsedTime = parseTime2(v);
1215
- const formatTime = timeFormat(this.timePattern());
1216
- return formatTime(parsedTime);
1217
- }
1218
- onzoom(transform) {
1219
- const w = this.width();
1220
- const low = this._gantt._minStart;
1221
- const high = this._gantt._maxEnd;
1222
- const range = high - low;
1223
- const wpp = range / w;
1224
- const nextLow = Math.floor(low - wpp * (transform.x / transform.k));
1225
- const nextHigh = Math.ceil(range / transform.k + nextLow);
1226
- this._topAxis.low(this.parseAxisValue(nextLow)).high(this.parseAxisValue(nextHigh)).render();
1227
- this._bottomAxis.low(this.parseAxisValue(nextLow)).high(this.parseAxisValue(nextHigh)).render();
1228
- }
1229
- };
1230
- __name(_ReactTimeline, "ReactTimeline");
1231
- let ReactTimeline = _ReactTimeline;
1232
- ReactTimeline.prototype._class += " timeline_ReactTimeline";
1233
- ReactTimeline.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1234
- ReactTimeline.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1235
- const parseTime = timeParse("%Q");
1236
- const _ReactTimelineSeries = class _ReactTimelineSeries extends ReactAxisGanttSeries {
1237
- _axisLabelFormatter;
1238
- //TODO: add a type to this? d3 time formatting function type?
1239
- constructor() {
1240
- super();
1241
- this._topAxis.type("time");
1242
- this._bottomAxis.type("time");
1243
- this.tooltipHTML((d) => {
1244
- const startTime = parseTime(d[1]);
1245
- const endTime = parseTime(d[2]);
1246
- const formatter = timeFormat(this.tooltipTimeFormat());
1247
- return `<div style="text-align:center;">${d[0]}<br/><br/>${formatter(startTime)} -&gt; ${formatter(endTime)}</div>`;
1248
- });
1249
- }
1250
- update(domNode, element) {
1251
- super.update(domNode, element);
1252
- if (this.timePattern_exists()) {
1253
- let minTimestamp = Infinity;
1254
- let maxTimestamp = -Infinity;
1255
- let lowDateStr = "";
1256
- let highDateStr = "";
1257
- this.data().forEach((n) => {
1258
- const start = new Date(n[1]).getTime();
1259
- const end = new Date(n[2]).getTime();
1260
- if (minTimestamp > start) {
1261
- minTimestamp = start;
1262
- lowDateStr = "" + n[1];
1263
- }
1264
- if (maxTimestamp < end) {
1265
- maxTimestamp = end;
1266
- highDateStr = "" + n[2];
1267
- }
1268
- });
1269
- const axisTickFormat = this._axisLabelFormatter ? this._axisLabelFormatter : this.tickFormat_exists && this.tickFormat_exists() ? this.tickFormat() : void 0;
1270
- this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(lowDateStr).high(highDateStr);
1271
- this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(lowDateStr).high(highDateStr);
1272
- if (axisTickFormat) {
1273
- this._topAxis.tickFormat(axisTickFormat);
1274
- this._bottomAxis.tickFormat(axisTickFormat);
1275
- } else {
1276
- this._topAxis.tickFormat_reset();
1277
- this._bottomAxis.tickFormat_reset();
1278
- }
1279
- this._gantt._minStart = minTimestamp;
1280
- this._gantt._maxEnd = maxTimestamp;
1281
- }
1282
- }
1283
- tooltipHTML(callback) {
1284
- this._tooltipHTML = callback;
1285
- this.tooltip().tooltipHTML(this._tooltipHTML);
1286
- return this;
1287
- }
1288
- parseAxisValue(v) {
1289
- const parsedTime = parseTime(v);
1290
- const formatTime = timeFormat(this.timePattern());
1291
- return formatTime(parsedTime);
1292
- }
1293
- onzoom(transform) {
1294
- const w = this.width();
1295
- const low = this._gantt._minStart;
1296
- const high = this._gantt._maxEnd;
1297
- const range = high - low;
1298
- const wpp = range / w;
1299
- const nextLow = Math.floor(low - wpp * (transform.x / transform.k));
1300
- const nextHigh = Math.ceil(range / transform.k + nextLow);
1301
- this._topAxis.low(this.parseAxisValue(nextLow)).high(this.parseAxisValue(nextHigh)).render();
1302
- this._bottomAxis.low(this.parseAxisValue(nextLow)).high(this.parseAxisValue(nextHigh)).render();
1303
- }
1304
- _tooltipHTML;
1305
- };
1306
- __name(_ReactTimelineSeries, "ReactTimelineSeries");
1307
- let ReactTimelineSeries = _ReactTimelineSeries;
1308
- ReactTimelineSeries.prototype._class += " timeline_ReactTimelineSeries";
1309
- ReactTimelineSeries.prototype.publish("timePattern", "%Y-%m-%d", "string", "Time pattern used for parsing datetime strings on each data row", null, { optional: true });
1310
- ReactTimelineSeries.prototype.publish("tooltipTimeFormat", "%Y-%m-%d", "string", "Time format used in the default html tooltip");
1311
- export {
1312
- BUILD_VERSION,
1313
- MiniGantt,
1314
- PKG_NAME,
1315
- PKG_VERSION,
1316
- ReactAxisGantt,
1317
- ReactAxisGanttSeries,
1318
- ReactGantt,
1319
- ReactTimeline,
1320
- ReactTimelineSeries
1321
- };
1
+ var t=Object.defineProperty,e=(e,i)=>t(e,"name",{value:i,configurable:!0});import{ITooltip as i}from"@hpcc-js/api";import{Axis as o}from"@hpcc-js/chart";import{Utility as s,SVGWidget as n,local as r,scaleBand as a,extent as l,timeParse as h,timeFormat as p,zoomIdentity as c,d3Event as d,zoom as m,select as u,EntityPin as _,EntityRect as x,SVGZoomWidget as g,scaleLinear as b,min as y,max as f}from"@hpcc-js/common";import{HTMLTooltip as k}from"@hpcc-js/html";import{LabelledRect as C,render as F}from"@hpcc-js/react";import{Border2 as w}from"@hpcc-js/layout";const A="@hpcc-js/timeline",v="3.2.3",S="3.16.1",z=class _MiniGantt extends n{tlAxis;brAxis;verticalBands;_zoom;gUpperContent;gUpperAxis;gMiddleContent;gLowerAxis;gLowerContent;localRect=r();localEntityPin=r();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),s.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 o).type("time"),this.brAxis=(new o).type("time"),this.verticalBands=a().paddingOuter(.2).paddingInner(.2)}isHorizontal(){return"horizontal"===this.orientation()}fullExtent(){const t=[...this.data().map(t=>t[this._startDate_idx]),...this.data().filter(t=>!!t[this._endDate_idx]).map(t=>t[this._endDate_idx])];return l(t)}extent(){const t=this.rootExtent?[this.rootExtent[1],this.rootExtent[2]]:this.fullExtent();if(void 0!==t[0]&&void 0!==t[1]&&(t[0]===t[1]||this.centerOnMostRecent())){const e=h(this.timePattern()),i=p(this.timePattern()),o=e(t[0]),s=e(t[1]);if(t[0]===t[1])t[0]=i(new Date(o.setFullYear(o.getFullYear()-1))),t[1]=i(new Date(o.setFullYear(o.getFullYear()+2)));else{const e=o.getTime(),n=s.getTime()-e;t[0]=i(o),t[1]=i(new Date(e+2*n))}}return t}dataStartPos(t){if(void 0!==this._dateCache[t[this._startDate_idx]])return this._dateCache[t[this._startDate_idx]];const e=this.brAxis.scalePos(t[this._startDate_idx]);return this._dateCache[t[this._startDate_idx]]=e,e}dataEndPos(t){if(void 0!==this._dateCache[t[this._endDate_idx]])return this._dateCache[t[this._endDate_idx]];const e=this.brAxis.scalePos(t[this._endDate_idx]);return this._dateCache[t[this._endDate_idx]]=e,e}dataWidth(t){return this.dataEndPos(t)-this.dataStartPos(t)}transform;resetZoom(){this._zoom.transform(this.element(),c.translate(0,this.isHorizontal()?0:this.height()))}zoomed(){this.transform=d().transform,this.render()}background;enter(t,e){super.enter(t,e),this._zoom=m().scaleExtent([0,this.maxZoom()]).on("zoom",()=>{this.zoomed()}),this.background=e.append("rect").attr("fill","white").attr("opacity",0).on("dblclick",()=>{d().stopPropagation(),delete this.rootExtent,this.resetZoom()}),this.gUpperContent=e.append("g").attr("class","gUpperContent"),this.gUpperAxis=e.append("g").attr("class","gUpperAxis"),this.gMiddleContent=e.append("g").attr("class","gMiddleContent"),this.gLowerAxis=e.append("g").attr("class","gLowerAxis"),this.gLowerContent=e.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),e.call(this._zoom),this._selection.widgetElement(this.gMiddleContent)}_prevIsHorizontal;update(t,e){if(super.update(t,e),this._dateCache={},this._title_idx=null!==this.titleColumn()?this.columns().indexOf(this.titleColumn()):this._title_idx,this._startDate_idx=null!==this.startDateColumn()?this.columns().indexOf(this.startDateColumn()):this._startDate_idx,this._endDate_idx=null!==this.endDateColumn()?this.columns().indexOf(this.endDateColumn()):this._endDate_idx,this._icon_idx=null!==this.iconColumn()?this.columns().indexOf(this.iconColumn()):this._icon_idx,this._color_idx=null!==this.colorColumn()?this.columns().indexOf(this.colorColumn()):this._color_idx,this._yoffset_idx=null!==this.yOffsetColumn()?this.columns().indexOf(this.yOffsetColumn()):this._yoffset_idx,this._prevIsHorizontal!==this.isHorizontal())return this._prevIsHorizontal=this.isHorizontal(),void this.resetZoom();this.tooltipFormatter=p(this.tooltipTimeFormat());const i=this.width(),o=this.height();this.background.attr("x",0).attr("y",0).attr("width",i).attr("height",o);const s=this.extent();if(this.tlAxis.x(i/2).orientation(this.isHorizontal()?"top":"left").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(i-1).low(s[0]).high(s[1]).updateScale(),this.brAxis.x(i/2).y(o/2).orientation(this.isHorizontal()?"bottom":"right").reverse(!this.isHorizontal()).timePattern(this.timePattern()).width(i-1).height(o).low(s[0]).high(s[1]).updateScale(),this.transform){let t,e;this.isHorizontal()?(t=this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(0))),e=this.tlAxis.parseInvert(this.tlAxis.invert(this.transform.invertX(i-1)))):(t=this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(0))),e=this.tlAxis.parseInvert(this.tlAxis.invert(-this.transform.invertY(o-1)))),this.tlAxis.low(t).high(e).updateScale(),this.brAxis.low(t).high(e).updateScale()}const n=this.data().sort(this.isHorizontal()?(t,e)=>{const i=this.brAxis.scalePos(t[1])-this.brAxis.scalePos(e[1]);return 0===i?(""+t[0]).localeCompare(""+e[0]):i}:(t,e)=>this.brAxis.scalePos(e[1])-this.brAxis.scalePos(t[1])),r=n.filter(t=>!t[this._endDate_idx]),a=n.filter(t=>!!t[this._endDate_idx]);this.tlAxis.render(),this.brAxis.render();const l=this.brAxis.getBBox();let h=this.updateEntityPins(r);const c=l.height;let d=o-h;const m=-1!==this._yoffset_idx?Math.min.apply(void 0,this.data().filter(t=>!isNaN(t[this._yoffset_idx])).map(t=>t[this._yoffset_idx])):0;if(r.length>0&&0===a.length){this.tlAxis.visible(!1);let t=h/4;t>o/2-c&&(t=o/2-c);const e=o/2+t,i=-1*(o/2-c-t),s=0!==m?m/2:0;this.gUpperContent.attr("transform",`translate(0, ${e-s})`),this.gLowerAxis.attr("transform",`translate(0, ${i-s})`)}else 0===r.length&&a.length>0?(this.tlAxis.visible(!0),this.gUpperContent.attr("transform",`translate(0, ${h})`),this.gUpperAxis.attr("transform",`translate(0, ${h})`)):(h-=m,d+=m,this.tlAxis.visible(!0),this.gUpperContent.attr("transform",`translate(0, ${h})`),this.gUpperAxis.attr("transform",`translate(0, ${h})`),this.gMiddleContent.attr("transform",`translate(0, ${h})`));this.tlAxis.render();const u=this.tlAxis.getBBox(),_=[],x={};for(const p of a){for(let t=0;t<_.length;++t){const e=_[t];if(e.endPos+this.overlapTolerence()<=this.dataStartPos(p)){x[p]=t,e.endPos=this.dataEndPos(p);break}}void 0===x[p]&&(x[p]=_.length,_.push({endPos:this.dataEndPos(p)}))}const g=this.isHorizontal()?0+u.height:0+u.width,b=this.isHorizontal()?d-l.height:i-l.width;this.verticalBands.range([g,b]).domain(_.map((t,e)=>e)),a.length>0&&this.updateEventRanges(r,a,x,d,u,l,i)}updateEntityPins(t){let e=0;const i=this,o=this.gUpperContent.selectAll(".entity_pin").data(t,t=>t[0]+":"+t[1]),s=this.eventFontColorColumn()?this.columns().indexOf(this.eventFontColorColumn()):-1,n=this.eventBorderColorColumn()?this.columns().indexOf(this.eventBorderColorColumn()):-1,r=this.eventBackgroundColorColumn()?this.columns().indexOf(this.eventBackgroundColorColumn()):-1,a={};for(const d of t){const t=void 0!==d[i._title_idx]?d[i._title_idx]:d[0];a[t]=a[t]?a[t]+1:1}const l=Object.keys(a),h=i.eventGroupOffset(),p=o.enter().append("g").attr("class","entity_pin");p.append("line").attr("class","entity_line"),p.on("mouseover",function(t){u(this).raise()}).each(function(t,e){const o=(new _).target(this).icon("").iconOnlyShowOnHover(i.hideIconWhenCollapsed()).titleOnlyShowOnHover(i.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(i.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(i.hideAnnotationsWhenCollapsed()).iconDiameter(18).iconPaddingPercent(1).titleFontSize(14).descriptionColor("#333").descriptionFontSize(15).iconColor(-1===s?"#333":t[s]).titleColor(-1===s?"#333":t[s]).descriptionColor(-1===s?"#333":t[s]).backgroundShape("pin").backgroundColorFill(-1===s?"#f8f8f8":t[r]).backgroundColorStroke(-1===s?"#ccc":t[n]).cornerRadius(5).arrowHeight(10).arrowWidth(16);i.localEntityPin.set(this,o)}).merge(o).each(function(t,o){const r=i.localEntityPin.get(this),a=void 0!==t[i._title_idx]?t[i._title_idx]:r.title(),p=i.dataStartPos(t)-0;let c=l.indexOf(a)%i.eventGroupMod()*h-5;if(void 0!==t[i._yoffset_idx]&&(c+=t[i._yoffset_idx]?t[i._yoffset_idx]:0),t[i._title_idx]!==r.title()&&t[i._startDate_idx]!==r.description()){const e=i.brAxis.parse(t[i._startDate_idx]),o=i.tooltipFormatter(e);r.x(p).y(c).iconOnlyShowOnHover(i.hideIconWhenCollapsed()).titleOnlyShowOnHover(i.hideTitleWhenCollapsed()).descriptionOnlyShowOnHover(i.hideDescriptionWhenCollapsed()).annotationOnlyShowOnHover(i.hideAnnotationsWhenCollapsed()).icon(void 0!==t[i._icon_idx]?t[i._icon_idx]:r.icon()).title(a).description(o).animationFrameRender()}else r.move({x:p,y:c});const d=r.calcHeight();e<d&&(e=d),u(this).selectAll(".entity_line").attr("x1",p).attr("x2",p).attr("y1",0).attr("y2",c).style("stroke",-1===s?"#ccc":t[n]).style("stroke-width",1)}),o.exit().each(function(t,e){i.localEntityPin.get(this).target(null)}).remove();const c=Math.abs(Math.min(t.length,i.eventGroupMod())*i.eventGroupOffset());return e+c}updateEventRanges(t,e,i,o,s,n,r){const a=this,l=this.gMiddleContent.selectAll(".line").data(t,t=>t[a._title_idx]);l.enter().append("line").attr("class","line").merge(l).attr(this.isHorizontal()?"x1":"y1",t=>this.dataStartPos(t)-0).attr(this.isHorizontal()?"x2":"y2",t=>this.dataStartPos(t)-0).attr(this.isHorizontal()?"y1":"x1",this.isHorizontal()?s.height:s.width).attr(this.isHorizontal()?"y2":"x2",this.isHorizontal()?o-n.height:r-n.width),l.exit().remove();const h=this.gMiddleContent.selectAll(".buckets").data(e,t=>t[a._title_idx]);h.enter().append("g").attr("class","buckets").call(this._selection.enter.bind(this._selection)).each(function(t){const e=(new x).target(this).iconDiameter(28).iconPaddingPercent(0).titleFontSize(28).titleColor(a.rangeFontColor()).descriptionColor(a.rangeFontColor()).iconColor(a.rangeFontColor()).backgroundShape("rect").backgroundColorFill(t[a._color_idx]);a.localRect.set(this,e),a.enterEntityRect(e,t)}).on("click",function(t){a.click(a.rowToObj(t),"range",a._selection.selected(this))},!1).on("dblclick",function(t){a.rootExtent=t,a.resetZoom(),a.dblclick(a.rowToObj(t),"range",a._selection.selected(this))},!0).on("mouseout.tooltip",this.tooltip.hide).on("mousemove.tooltip",this.tooltip.show).merge(h).attr("transform",t=>a.isHorizontal()?`translate(${this.dataStartPos(t)}, ${this.verticalBands(i[t])}) `:`translate(${this.verticalBands(i[t])}, ${this.dataStartPos(t)}) `).each(function(t){const e=a.localRect.get(this),i=a.dataWidth(t)/2,o=a.verticalBands.bandwidth()/2,s=Math.max(a.dataWidth(t),2),n=Math.max(a.verticalBands.bandwidth(),2),r=.191*n,l=.618*n,h=l;e.pos(a.isHorizontal()?{x:i,y:o}:{x:o,y:i}).fixedHeight(a.isHorizontal()?n:s).fixedWidth(a.isHorizontal()?s:n).icon(void 0!==t[a._icon_idx]?t[a._icon_idx]:"").title(void 0!==t[a._title_idx]?t[a._title_idx]:"").padding(r).iconDiameter(h).titleFontSize(l),1.5*h>s&&e.icon(null),a.updateEntityRect(e,t[a._icon_idx]),e.render()}),h.exit().remove()}exit(t,e){this.brAxis.target(null),this.tlAxis.target(null),super.exit(t,e)}click(t,e,i){}dblclick(t,e,i){}enterEntityRect(t,e){}updateEntityRect(t,e){}};e(z,"MiniGantt");let P=z;P.prototype._class+=" timeline_MiniGantt",P.prototype.implements(i.prototype),P.prototype.mixin(s.SimpleSelectionMixin),P.prototype.publish("timePattern","%Y-%m-%d","string","timePattern"),P.prototype.publish("tickFormat",null,"string","tickFormat",void 0,{optional:!0}),P.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","tooltipTimeFormat"),P.prototype.publish("overlapTolerence",2,"number","overlapTolerence"),P.prototype.publish("orientation","horizontal","set","orientation",["horizontal","vertical"]),P.prototype.publish("rangeFontColor","#ecf0f1","html-color","rangeFontColor"),P.prototype.publish("titleColumn",null,"string","titleColumn"),P.prototype.publish("startDateColumn",null,"string","startDateColumn"),P.prototype.publish("endDateColumn",null,"string","endDateColumn"),P.prototype.publish("iconColumn",null,"string","iconColumn"),P.prototype.publish("colorColumn",null,"string","colorColumn"),P.prototype.publish("yOffsetColumn",null,"string","yOffsetColumn"),P.prototype.publish("maxZoom",16,"number","maxZoom"),P.prototype.publish("eventGroupOffset",-50,"number","eventGroupOffset"),P.prototype.publish("eventGroupMod",5,"number","eventGroupMod"),P.prototype.publish("eventFontColorColumn",null,"string","eventFontColorColumn"),P.prototype.publish("eventBorderColorColumn",null,"string","eventBorderColorColumn"),P.prototype.publish("eventBackgroundColorColumn",null,"string","eventBackgroundColorColumn"),P.prototype.publish("hideIconWhenCollapsed",!1,"boolean","hideIconWhenCollapsed"),P.prototype.publish("hideTitleWhenCollapsed",!1,"boolean","hideTitleWhenCollapsed"),P.prototype.publish("hideDescriptionWhenCollapsed",!1,"boolean","hideDescriptionWhenCollapsed"),P.prototype.publish("hideAnnotationsWhenCollapsed",!0,"boolean","hideAnnotationsWhenCollapsed"),P.prototype.publish("centerOnMostRecent",!1,"boolean","If true, the timeline will be centered on the most recent data point");const T=class _ReactGantt extends g{_selection=new s.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 k,this._tooltip.tooltipHTML(t=>`<div style="text-align:center;">${t[0]}<br/><br/>${t[1]} -&gt; ${t[2]}</div>`),this._tooltip.followCursor(!0)}selection(t){return arguments.length?(this._selection.set(t),this):this._selection.get()}_rangeRenderer=C;rangeRenderer(t){return arguments.length?(this._rangeRenderer=t,this._rangeRenderer):this._rangeRenderer}enter(t,e){super.enter(t,e);const i=this;e.on("click",function(t){i._selection.clear()}),this._tooltip.target(t)}update(t,i){super.update(t,i),this.zoomExtent([.05,this.maxZoom()]),this._title_idx=null!==this.titleColumn()?this.columns().indexOf(this.titleColumn()):this._title_idx,this._startDate_idx=null!==this.startDateColumn()?this.columns().indexOf(this.startDateColumn()):this._startDate_idx,this._endDate_idx=null!==this.endDateColumn()?this.columns().indexOf(this.endDateColumn()):this._endDate_idx,this._icon_idx=null!==this.iconColumn()?this.columns().indexOf(this.iconColumn()):this._icon_idx,this._color_idx=null!==this.colorColumn()?this.columns().indexOf(this.colorColumn()):this._color_idx,this._series_idx=null!==this.seriesColumn()?this.columns().indexOf(this.seriesColumn()):this._series_idx,this._bucket_idx=null!==this.bucketColumn()?this.columns().indexOf(this.bucketColumn()):-1;const o=this,s=this.width(),n=s;if(this._interpolateX=b().domain([this._minStart,this._maxEnd]).range([0,n]),this.data().sort((t,e)=>t[1]-e[1]),this._series_idx>-1){this._origIdxMap={},this._dataBySeries={},this._bucketsBySeries={},this.data().forEach((t,e)=>{const i=t[this._series_idx];this._dataBySeries[i]||(this._origIdxMap[i]={},this._dataBySeries[i]=[]),this._dataBySeries[i].push({dataRow:t,origIdx:e})});const t=this.gutter();let e=0;const i=Object.keys(this._dataBySeries);i.forEach(t=>{this._dataBySeries[t].sort((t,e)=>t.dataRow[1]-e.dataRow[1]),this._bucketsBySeries[t]=this.calcBuckets(this._dataBySeries[t].map(t=>t.dataRow),1,2),this._bucketsBySeries[t].bucketHeight=this.bucketHeight(),this._bucketsBySeries[t].bucketOffset=e,e+=(this._bucketsBySeries[t].bucketHeight+this.strokeWidth()+this.gutter())*(this._bucketsBySeries[t].maxBucket+1),this._dataBySeries[t].forEach((e,i)=>{this._origIdxMap[t][e.origIdx]=i})}),this._seriesBackgrounds=this._renderElement.selectAll(".series-background").data(i.map(t=>this._bucketsBySeries[t])),this._seriesBackgrounds.join(t=>t.append("rect").attr("class","series-background"),t=>t,t=>t.each(function(t){delete t.element}).remove()).attr("opacity",t=>t.props&&t.props.hidden?0:1).each(function(e,i){u(this).attr("x",0).attr("y",e.bucketOffset-t/2).attr("width",s).attr("height",(e.bucketHeight+t)*(e.maxBucket+1)+t).attr("fill",i%2?o.oddSeriesBackground():o.evenSeriesBackground())})}else-1!==this._bucket_idx?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);const r=this._interpolateX(this._minStart);this.zoomTo([r,0],1);const a=this.bucketHeight();this.setRangeOptions(),this._maxFontScale=a-2*this.rangePadding(),this.measureDataText();const l=this._renderElement.selectAll(".item").data(this.data()),h=this.strokeWidth(),p=2*h;l.join(t=>t.append("g").attr("class","item").on("click.selectionBag",function(t,i){const s=void 0===t.id?i:t.id;o._selection.isSelected({_id:s,element:t.element})?o._selection.clear():o._selection.click({_id:s,element:/* @__PURE__ */e(()=>t.element,"element")},d),o.selectionChanged(),d().stopPropagation()}).on("click",function(t){const e=t.element.classed("selected");t[o.columns().length]&&(t.__lparam=t[o.columns().length]),o.click(t,"",e)}).on("dblclick",function(t){const e=t.element.classed("selected");t[o.columns().length]&&(t.__lparam=t[o.columns().length]),o.click(t,"",e)}).on("mousein",function(t){o.highlightItem(u(this),t);const e=t.element.classed("selected");o.mousein(t,"",e)}).on("mouseover",function(t){const e=d();o._tooltip._triggerElement=t.element,o._tooltip._cursorLoc=[e.clientX,e.clientY],o._tooltip.data(t).visible(!0).fitContent(!0).render(),o.highlightItem(u(this),t);const i=t.element.classed("selected");o.mouseover(t,"",i)}).on("mouseout",function(t){o._tooltip.visible(!1).render(),o.highlightItem(null,null);const e=t.element.classed("selected");o.mouseout(t,"",e)}).each(function(t,e){t.that=this,t.element=u(this),t.x=o._interpolateX(t[1]);const i=o._interpolateX(t[2]);if(o._series_idx>-1){const i=t[o._series_idx],s=o._bucketsBySeries[i].bucketMap[o._origIdxMap[i][e]];t.y=o._bucketsBySeries[i].interpolateY(s)+o._bucketsBySeries[i].bucketOffset}else{const i=-1===o._bucket_idx?e:t[o._bucket_idx];t.y=o._buckets.interpolateY(o._buckets.bucketMap[i])}t.props={...t[3],text:t[0]},t.props.width=i-t.x,t.props.height=a,t.x+=h,t.y+=h,t.props.width-=p,t.props.height-=p,t.element.attr("transform",`translate(${t.x+t.props.width/2} ${t.y+t.props.height/2})`)}),t=>t,t=>t.each(function(t){delete t.element}).remove()).attr("opacity",t=>t.props&&t.props.hidden?0:1).each(function(t,e){if(t.that=this,o._series_idx>-1){const i=t[o._series_idx];t.x=o.renderRangeElement(t,e,!1,o._rangeOptions,i)}else t.x=o.renderRangeElement(t,e,!1,o._rangeOptions)}).on("dblclick.zoom",t=>{const e=this._interpolateX(t[1]),i=this._interpolateX(t[2]),o=s/(i-e);this.zoomTo([-e*o,0],o)}),i.on("dblclick.zoom",null)}exit(t,e){this._tooltip.target(null),super.exit(t,e)}renderRangeElement(t,e,i=!1,o={},s){const n=o.strokeWidth,r=2*n,a=o.rangePadding;let l;const h=isNaN(this._transform.x)?0:this._transform.x,p=isNaN(this._transform.k)?1:this._transform.k;let c;const d=this.bucketHeight();t.that.setAttribute("data-series",s),this._color_idx>-1&&t.that.setAttribute("data-color",t[this._color_idx]),void 0!==s?(c=this._bucketsBySeries[s].bucketMap[this._origIdxMap[s][e]],t.that.setAttribute("data-b",c),t.that.setAttribute("data-bucketOffset",this._bucketsBySeries[s].bucketOffset),t.y=this._bucketsBySeries[s].interpolateY(c)+this._bucketsBySeries[s].bucketOffset,t.that.setAttribute("data-dy",t.y)):(c=this._buckets.bucketMap[e],t.y=this._buckets.interpolateY(c)),this._color_idx>-1&&(o.fill=t[this._color_idx]),i?(t.x=this._interpolateX(t[1])*p,l=this._interpolateX(t[2])*p,t.props={...t[3],text:t[0]},t.props.width=(l-t.x)/p,t.x+=h,t.props.width*=p):(t.x=this._interpolateX(t[1]),l=this._interpolateX(t[2]),t.props={...t[3],text:t[0]},t.props.width=(l-t.x)/p),t.props.height=d,void 0===s&&this._buckets.bucketScale<1&&(t.props.height=this._buckets.bucketScale*d),void 0===t.element&&t.that&&(t.element=u(t.that)),t.element.attr("transform",`translate(${t.x+t.props.width/2} ${t.y+t.props.height/2})`),t.x+=n,t.y+=n,t.props.width-=r,t.props.height-=r,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-a,this._maxFontScale);m!==t.props.text?m=this.truncateText(t.props.text,t.props.width-a):t.props.fontSize=this._maxFontScale*o.fontSize,void 0===s&&this._buckets.bucketScale<1&&(t.props.fontSize=Math.min(this._maxFontScale,this._buckets.bucketScale)*o.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),F(this._rangeRenderer,{...o,...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){if(this._transform=t,"scale-all"===this.renderMode())this._zoomScale=t.k,this._zoomTranslate=[t.x,0],this._zoomG.attr("transform",`translate(${t.x} 0)scale(${t.k} 1)`);else{const t=this._rangeOptions;this.data().forEach((e,i)=>{if(this._color_idx>-1&&(t.fill=e[this._color_idx]),this._series_idx>-1){const o=e[this._series_idx];this.renderRangeElement(e,i,!0,t,o)}else this.renderRangeElement(e,i,!0,t)})}this.zoomedHook(t)}zoomedHook(t){}calcBuckets(t,e,i,o){const s={},n={},r=this.overlapTolerence(),a=[{end:-1/0}];let l=0;void 0!==o?(t.forEach((t,e)=>{s[e]=t[o],n[t[o]]=!0}),l=Object.keys(n).length):t.forEach((t,o)=>{for(let n=0;n<a.length;++n)if(0===o||a[n][i]+r<=t[e]){s[o]=n,l<n&&(l=n),a[n][i]=t[i];break}if(void 0===s[o]){s[o]=a.length;const e={};e[i]=t[i],a.push(e)}l<s[o]&&(l=s[o])});const h=(l+1)*(this.bucketHeight()+this.gutter());return{bucketMap:s,maxBucket:l,bucketScale:this.height()/h,interpolateY:b().domain([0,l+1]).range([0,Math.min(this.height(),h)])}}data(t){const e=super.data.apply(this,arguments);return arguments.length>0&&(this._minStart=Math.min(...this.data().map(t=>t[1]))??0,this._maxEnd=Math.max(...this.data().map(t=>t[2]))??1,this.measureDataText(!0)),e}_textWidths;_maxFontScale;_characterWidths;_prevFontFamily;_prevFontSize;measureDataText(t=!1){const e={},i={},o=this.fontFamily(),n=this.fontSize(),r=this.bucketHeight();r&&(this._maxFontScale=(r-2*this.rangePadding())/n),(t||this._prevFontFamily!==o||this._prevFontSize!==n)&&(i["."]=s.textSize(".",o,n).width,this.data().forEach(t=>{e[t[0]]||(e[t[0]]=s.textSize(t[0],o,n).width),t[0].split("").forEach(t=>{i[t]||(i[t]=s.textSize(t,o,n).width)})}),this._textWidths=e,this._characterWidths=i),this._prevFontFamily=o,this._prevFontSize=n}truncateText(t,e,i=1){if(this._textWidths[t]*i<e)return t;let o="",s=0;const n=e-3*this._characterWidths["."];for(const r of t){if(s+=this._characterWidths[r],!(s<n))break;o+=r}return n<0?"":o+"..."}resize(t){let e;return e=this.fitWidthToContent()||this.fitHeightToContent()?super.resize.call(this,{width:t.width,height:this._maxY}):super.resize.apply(this,arguments),e}selectionChanged(){}highlightItem(t,e){}click(t,e,i){}dblclick(t,e,i){}mousein(t,e,i){}mouseover(t,e,i){}mouseout(t,e,i){}};e(T,"ReactGantt");let D=T;D.prototype._class+=" timeline_ReactGantt",D.prototype.publish("fitWidthToContent",!1,"boolean","If true, resize will simply reapply the bounding box width"),D.prototype.publish("fitHeightToContent",!1,"boolean","If true, resize will simply reapply the bounding box height"),D.prototype.publish("titleColumn",null,"string","Column name to for the title"),D.prototype.publish("startDateColumn",null,"string","Column name to for the start date"),D.prototype.publish("endDateColumn",null,"string","Column name to for the end date"),D.prototype.publish("iconColumn",null,"string","Column name to for the icon"),D.prototype.publish("colorColumn",null,"string","Column name to for the color"),D.prototype.publish("seriesColumn",null,"string","Column name to for the series identifier"),D.prototype.publish("bucketColumn",null,"string","Column name to for the bucket identifier"),D.prototype.publish("renderMode","default","set","Render modes vary in features and performance",["default","scale-all"]),D.prototype.publish("rangePadding",3,"number","Padding within each range rectangle (pixels)"),D.prototype.publish("fill","#1f77b4","string","Background color of range rectangle"),D.prototype.publish("stroke",null,"string","Color of range rectangle border"),D.prototype.publish("strokeWidth",null,"number","Width of range rectangle border (pixels)"),D.prototype.publish("cornerRadius",3,"number","Space between range buckets (pixels)"),D.prototype.publish("fontFamily",null,"string","Font family within range rectangle",null,{optional:!0}),D.prototype.publish("fontSize",10,"number","Size of font within range rectangle (pixels)"),D.prototype.publish("rangeFontColor","#ecf0f1","html-color","rangeFontColor"),D.prototype.publish("overlapTolerence",2,"number","overlapTolerence"),D.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)"),D.prototype.publish("bucketHeight",100,"number","Max height of range element (pixels)"),D.prototype.publish("gutter",2,"number","Space between range buckets (pixels)"),D.prototype.publish("maxZoom",16,"number","Maximum zoom"),D.prototype.publish("evenSeriesBackground","#FFFFFF","html-color","Background color of even series rows"),D.prototype.publish("oddSeriesBackground","#DDDDDD","html-color","Background color of odd series rows");const M=class _ReactAxisGantt extends n{_topAxis=new o("center").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_gantt=new D("center").stroke("#000000");_bottomAxis=new o("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(){const 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(){const t=this.width(),e=this.height(),i=this.axisHeight(),o=e-2*i,s=this.strokeWidth();this._topRect.attr("height",i).attr("width",t).attr("fill","transparent"),this._topAxisElement.attr("transform","translate(0 0)"),this._topAxis.resize({height:i,width:t}),this._contentRect.attr("height",o).attr("width",t).attr("fill","transparent"),this._contentElement.attr("transform",`translate(0 ${i+s})`),this._gantt.resize({height:o,width:t}),this._bottomRect.attr("height",i).attr("width",t).attr("fill","transparent"),this._bottomAxisElement.attr("transform",`translate(0 ${i+o+s})`),this._bottomAxis.resize({height:i,width:t})}enter(t,e){super.enter(t,e),this._gantt.click=(t,e,i)=>{this.click(t,e,i)},this._gantt.dblclick=(t,e,i)=>{this.dblclick(t,e,i)},this._topAxisElement=e.append("g").attr("class","top-axis-wrapper"),this._topRect=this._topAxisElement.append("rect").attr("class","top-axis-rect"),this._contentElement=e.append("g").attr("class","content-wrapper"),this._contentRect=this._contentElement.append("rect").attr("class","content-rect"),this._bottomAxisElement=e.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=t=>{this.onzoom(t)}}onzoom(t){const e=this.width(),i=this._gantt._minStart,o=this._gantt._maxEnd-i,s=o/e,n=Math.floor(i-s*(t.x/t.k)),r=Math.ceil(o/t.k+n);this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(n).high(r).render(),this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(n).high(r).render()}update(t,e){super.update(t,e),this._topAxis.tickFormat(this.tickFormat()).render(),this._bottomAxis.tickFormat(this.tickFormat()).render(),this._gantt.render()}exit(t,e){this._bottomAxis.target(null),this._gantt.target(null),this._topAxis.target(null),super.exit(t,e)}columns(t){const e=super.columns.apply(this,arguments);return arguments.length>0&&this._gantt.columns(t),e}data(t){const e=super.data.apply(this,arguments);if(arguments.length>0){const t=this.data().map(t=>{const e=[...t];return e[1]=isNaN(t[1])?new Date(t[1]).getTime():Number(t[1]),e[2]=isNaN(t[2])?new Date(t[2]).getTime():Number(t[2]),e});this._gantt._minStart=Math.min(...t.map(t=>t[1]))??0,this._gantt._maxEnd=Math.max(...t.map(t=>t[2]))??1,this._gantt.data(t)}return e}resize(t){const e=super.resize.apply(this,arguments);return this._topAxisElement&&this.resizeWrappers(),e}click(t,e,i){}dblclick(t,e,i){}tooltip(){return this._gantt._tooltip}};e(M,"ReactAxisGantt");let E=M;E.prototype._class+=" timeline_ReactAxisGantt",E.prototype.publish("tickFormat",null,"string","Format rule applied to axis tick labels",void 0,{optional:!0}),E.prototype.publish("axisHeight",22,"number","Height of axes (pixels)"),E.prototype.publish("overlapTolerence",2,"number","overlapTolerence"),E.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)"),E.prototype.publish("axisFontSize",null,"number","Font size of axis tick labels"),E.prototype.publish("axisFontFamily",null,"string","Font family of axis tick labels"),E.prototype.publish("axisTickLength",null,"number","Length of axis ticks"),E.prototype.publishProxy("gutter","_gantt"),E.prototype.publishProxy("renderMode","_gantt"),E.prototype.publishProxy("strokeWidth","_gantt"),E.prototype.publishProxy("fontSize","_gantt"),E.prototype.publishProxy("fontFamily","_gantt"),E.prototype.publishProxy("stroke","_gantt"),E.prototype.publishProxy("cornerRadius","_gantt"),E.prototype.publishProxy("titleColumn","_gantt"),E.prototype.publishProxy("startDateColumn","_gantt"),E.prototype.publishProxy("endDateColumn","_gantt"),E.prototype.publishProxy("iconColumn","_gantt"),E.prototype.publishProxy("colorColumn","_gantt"),E.prototype.publishProxy("bucketColumn","_gantt"),E.prototype.publishProxy("maxZoom","_gantt"),E.prototype.publishProxy("bucketHeight","_gantt");const H=class _ReactAxisGanttSeries extends w{_topAxis=new o("origin").orientation("top").type("linear").shrinkToFit("none").overlapMode("hide").extend(0).tickFormat("d");_gantt=new D("origin").stroke("#000000").fitHeightToContent(!0);_bottomAxis=new o("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){const e=this._gantt.rangeRenderer.apply(this._gantt,arguments);return arguments.length?this:e}resizeWrappers(){const t=this.width(),e=this.height(),i=this.axisHeight(),o=e-2*i;this.bottomHeight(i),this._topWA.resize({width:t,height:i}),this._centerWA.resize({width:t,height:o}),this._bottomWA.resize({width:t,height:i}),this.top().render(),this.bottom().render(),this.center().render()}enter(t,e){super.enter(t,e),this._gantt.click=(t,e,i)=>{this.click(t,e,i)},this._gantt.dblclick=(t,e,i)=>{this.dblclick(t,e,i)},this.top(this._topAxis),this.center(this._gantt),this.bottom(this._bottomAxis),this.resizeWrappers(),this._gantt.zoomedHook=t=>{this.onzoom(t)}}onzoom(t){const e=this.width(),i=this._gantt._minStart,o=this._gantt._maxEnd-i,s=o/e,n=Math.floor(i-s*(t.x/t.k)),r=Math.ceil(o/t.k+n);this._topAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(n).high(r).lazyRender(),this._bottomAxis.fontFamily(this.axisFontFamily()).fontSize(this.axisFontSize()).tickLength(this.axisTickLength()).low(n).high(r).lazyRender()}update(t,e){super.update(t,e),this._topAxis.tickFormat(this.tickFormat()).render(),this._bottomAxis.tickFormat(this.tickFormat()).render(),this._gantt.render()}columns(t){const e=super.columns.apply(this,arguments);return arguments.length>0&&this._gantt.columns(t),e}data(t){const e=super.data.apply(this,arguments);if(arguments.length>0){const t=this.data().map(t=>{const e=[...t];return e[1]=isNaN(t[1])?new Date(t[1]).getTime():Number(t[1]),e[2]=isNaN(t[2])?new Date(t[2]).getTime():Number(t[2]),e});this._gantt._minStart=y(t,t=>t[1]),this._gantt._maxEnd=f(t,t=>t[2]),this._gantt.data(t)}return e}resize(t){const e=super.resize.apply(this,arguments);return this._topAxisElement&&this.resizeWrappers(),e}click(t,e,i){}dblclick(t,e,i){}tooltip(){return this._gantt._tooltip}};e(H,"ReactAxisGanttSeries");let R=H;R.prototype._class+=" timeline_ReactAxisGanttSeries",R.prototype.publish("tickFormat",null,"string","Format rule applied to axis tick labels",void 0,{optional:!0}),R.prototype.publish("axisHeight",22,"number","Height of axes (pixels)"),R.prototype.publish("overlapTolerence",2,"number","overlapTolerence"),R.prototype.publish("smallestRangeWidth",10,"number","Width of the shortest range (pixels)"),R.prototype.publish("axisFontSize",null,"number","Font size of axis tick labels"),R.prototype.publish("axisFontFamily",null,"string","Font family of axis tick labels"),R.prototype.publish("axisTickLength",null,"number","Length of axis ticks"),R.prototype.publishProxy("gutter","_gantt"),R.prototype.publishProxy("renderMode","_gantt"),R.prototype.publishProxy("strokeWidth","_gantt"),R.prototype.publishProxy("fontSize","_gantt"),R.prototype.publishProxy("fontFamily","_gantt"),R.prototype.publishProxy("stroke","_gantt"),R.prototype.publishProxy("cornerRadius","_gantt"),R.prototype.publishProxy("titleColumn","_gantt"),R.prototype.publishProxy("startDateColumn","_gantt"),R.prototype.publishProxy("endDateColumn","_gantt"),R.prototype.publishProxy("iconColumn","_gantt"),R.prototype.publishProxy("colorColumn","_gantt"),R.prototype.publishProxy("seriesColumn","_gantt"),R.prototype.publishProxy("bucketColumn","_gantt"),R.prototype.publishProxy("maxZoom","_gantt"),R.prototype.publishProxy("evenSeriesBackground","_gantt"),R.prototype.publishProxy("oddSeriesBackground","_gantt"),R.prototype.publishProxy("bucketHeight","_gantt");const O=class _ReactTimeline extends E{_axisLabelFormatter;constructor(){super(),this._drawStartPos="origin",this._topAxis.type("time"),this._bottomAxis.type("time"),this.tooltipHTML(t=>{const e=h("%Q"),i=e(t[1]),o=e(t[2]),s=p(this.tooltipTimeFormat());return`<div style="text-align:center;">${t[0]}<br/><br/>${s(i)} -&gt; ${s(o)}</div>`})}update(t,e){if(super.update(t,e),this.timePattern_exists()){let t=1/0,e=-1/0,i="",o="";this.data().map(s=>{const n=new Date(s[1]).getTime(),r=new Date(s[2]).getTime();t>n&&(t=n,i=""+s[1]),e<r&&(e=r,o=""+s[2])});const s=this._axisLabelFormatter?this._axisLabelFormatter:this.tickFormat_exists&&this.tickFormat_exists()?this.tickFormat():void 0;this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(i).high(o),this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(i).high(o),s?(this._topAxis.tickFormat(s),this._bottomAxis.tickFormat(s)):(this._topAxis.tickFormat_reset(),this._bottomAxis.tickFormat_reset()),this._gantt._minStart=t,this._gantt._maxEnd=e}}tooltipHTML(t){return this._tooltipHTML=t,this.tooltip().tooltipHTML(this._tooltipHTML),this}parseAxisValue(t){const e=h("%Q")(t);return p(this.timePattern())(e)}onzoom(t){const e=this.width(),i=this._gantt._minStart,o=this._gantt._maxEnd-i,s=o/e,n=Math.floor(i-s*(t.x/t.k)),r=Math.ceil(o/t.k+n);this._topAxis.low(this.parseAxisValue(n)).high(this.parseAxisValue(r)).render(),this._bottomAxis.low(this.parseAxisValue(n)).high(this.parseAxisValue(r)).render()}};e(O,"ReactTimeline");let B=O;B.prototype._class+=" timeline_ReactTimeline",B.prototype.publish("timePattern","%Y-%m-%d","string","Time pattern used for parsing datetime strings on each data row",null,{optional:!0}),B.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","Time format used in the default html tooltip");const W=h("%Q"),L=class _ReactTimelineSeries extends R{_axisLabelFormatter;constructor(){super(),this._topAxis.type("time"),this._bottomAxis.type("time"),this.tooltipHTML(t=>{const e=W(t[1]),i=W(t[2]),o=p(this.tooltipTimeFormat());return`<div style="text-align:center;">${t[0]}<br/><br/>${o(e)} -&gt; ${o(i)}</div>`})}update(t,e){if(super.update(t,e),this.timePattern_exists()){let t=1/0,e=-1/0,i="",o="";this.data().forEach(s=>{const n=new Date(s[1]).getTime(),r=new Date(s[2]).getTime();t>n&&(t=n,i=""+s[1]),e<r&&(e=r,o=""+s[2])});const s=this._axisLabelFormatter?this._axisLabelFormatter:this.tickFormat_exists&&this.tickFormat_exists()?this.tickFormat():void 0;this._topAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(i).high(o),this._bottomAxis.type("time").timePattern(this.timePattern()).overlapMode("none").low(i).high(o),s?(this._topAxis.tickFormat(s),this._bottomAxis.tickFormat(s)):(this._topAxis.tickFormat_reset(),this._bottomAxis.tickFormat_reset()),this._gantt._minStart=t,this._gantt._maxEnd=e}}tickFormatFunc(t){return arguments.length?(this._axisLabelFormatter=t,this._topAxis.tickFormatFunc(t),this._bottomAxis.tickFormatFunc(t),this):this._axisLabelFormatter}tooltipHTML(t){return this._tooltipHTML=t,this.tooltip().tooltipHTML(this._tooltipHTML),this}parseAxisValue(t){const e=W(t);return p(this.timePattern())(e)}onzoom(t){const e=this.width(),i=this._gantt._minStart,o=this._gantt._maxEnd-i,s=o/e,n=Math.floor(i-s*(t.x/t.k)),r=Math.ceil(o/t.k+n);this._topAxis.low(this.parseAxisValue(n)).high(this.parseAxisValue(r)).render(),this._bottomAxis.low(this.parseAxisValue(n)).high(this.parseAxisValue(r)).render()}_tooltipHTML};e(L,"ReactTimelineSeries");let $=L;$.prototype._class+=" timeline_ReactTimelineSeries",$.prototype.publish("timePattern","%Y-%m-%d","string","Time pattern used for parsing datetime strings on each data row",null,{optional:!0}),$.prototype.publish("tooltipTimeFormat","%Y-%m-%d","string","Time format used in the default html tooltip");export{S as BUILD_VERSION,P as MiniGantt,A as PKG_NAME,v as PKG_VERSION,E as ReactAxisGantt,R as ReactAxisGanttSeries,D as ReactGantt,B as ReactTimeline,$ as ReactTimelineSeries};
1322
2
  //# sourceMappingURL=index.js.map
1323
3
  !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode(".timeline_MiniGantt .line{fill:none;stroke:#d3d3d3;opacity:.7}.timeline_MiniGantt .common_TextBox .rect{fill:#87cefa;stroke:#00f;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}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();