@hpcc-js/timeline 3.2.0 → 3.2.2

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