@hpcc-js/timeline 2.54.1 → 2.56.0

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