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