timeline-chart 0.3.0-next.f3add09.0 → 0.3.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/README.md +12 -7
- package/lib/bigint-utils.d.ts +1 -0
- package/lib/bigint-utils.js +6 -0
- package/lib/bigint-utils.js.map +1 -1
- package/lib/components/time-graph-annotation.d.ts +9 -2
- package/lib/components/time-graph-annotation.js +15 -2
- package/lib/components/time-graph-annotation.js.map +1 -1
- package/lib/components/time-graph-arrow.d.ts +0 -1
- package/lib/components/time-graph-arrow.js +1 -5
- package/lib/components/time-graph-arrow.js.map +1 -1
- package/lib/components/time-graph-axis-scale.d.ts +4 -1
- package/lib/components/time-graph-axis-scale.js +41 -12
- package/lib/components/time-graph-axis-scale.js.map +1 -1
- package/lib/components/time-graph-component.d.ts +8 -7
- package/lib/components/time-graph-component.js +11 -1
- package/lib/components/time-graph-component.js.map +1 -1
- package/lib/components/time-graph-row.d.ts +33 -3
- package/lib/components/time-graph-row.js +42 -5
- package/lib/components/time-graph-row.js.map +1 -1
- package/lib/components/time-graph-state.d.ts +14 -2
- package/lib/components/time-graph-state.js +77 -37
- package/lib/components/time-graph-state.js.map +1 -1
- package/lib/layer/time-graph-axis.d.ts +2 -0
- package/lib/layer/time-graph-axis.js +4 -1
- package/lib/layer/time-graph-axis.js.map +1 -1
- package/lib/layer/time-graph-chart-arrows.d.ts +6 -2
- package/lib/layer/time-graph-chart-arrows.js +31 -12
- package/lib/layer/time-graph-chart-arrows.js.map +1 -1
- package/lib/layer/time-graph-chart-cursors.d.ts +3 -4
- package/lib/layer/time-graph-chart-cursors.js +34 -60
- package/lib/layer/time-graph-chart-cursors.js.map +1 -1
- package/lib/layer/time-graph-chart-grid.d.ts +1 -1
- package/lib/layer/time-graph-chart-grid.js +4 -2
- package/lib/layer/time-graph-chart-grid.js.map +1 -1
- package/lib/layer/time-graph-chart-layer.d.ts +2 -2
- package/lib/layer/time-graph-chart-layer.js +2 -2
- package/lib/layer/time-graph-chart-layer.js.map +1 -1
- package/lib/layer/time-graph-chart-selection-range.d.ts +2 -3
- package/lib/layer/time-graph-chart-selection-range.js +13 -10
- package/lib/layer/time-graph-chart-selection-range.js.map +1 -1
- package/lib/layer/time-graph-chart.d.ts +67 -22
- package/lib/layer/time-graph-chart.js +434 -171
- package/lib/layer/time-graph-chart.js.map +1 -1
- package/lib/layer/time-graph-layer.d.ts +2 -1
- package/lib/layer/time-graph-layer.js +14 -4
- package/lib/layer/time-graph-layer.js.map +1 -1
- package/lib/layer/time-graph-markers-chart-cursors.d.ts +5 -0
- package/lib/layer/time-graph-markers-chart-cursors.js +78 -0
- package/lib/layer/time-graph-markers-chart-cursors.js.map +1 -0
- package/lib/layer/time-graph-navigator.d.ts +1 -1
- package/lib/layer/time-graph-navigator.js +48 -10
- package/lib/layer/time-graph-navigator.js.map +1 -1
- package/lib/layer/time-graph-range-events-layer.d.ts +3 -3
- package/lib/layer/time-graph-range-events-layer.js +9 -9
- package/lib/layer/time-graph-range-events-layer.js.map +1 -1
- package/lib/layer/time-graph-vertical-scrollbar.d.ts +5 -0
- package/lib/layer/time-graph-vertical-scrollbar.js +65 -14
- package/lib/layer/time-graph-vertical-scrollbar.js.map +1 -1
- package/lib/layer/time-graph-viewport-layer.d.ts +19 -0
- package/lib/layer/time-graph-viewport-layer.js +70 -0
- package/lib/layer/time-graph-viewport-layer.js.map +1 -0
- package/lib/time-graph-container.d.ts +5 -2
- package/lib/time-graph-container.js +19 -0
- package/lib/time-graph-container.js.map +1 -1
- package/lib/time-graph-font-controller.d.ts +16 -5
- package/lib/time-graph-font-controller.js +48 -16
- package/lib/time-graph-font-controller.js.map +1 -1
- package/lib/time-graph-render-controller.d.ts +12 -0
- package/lib/time-graph-render-controller.js +57 -0
- package/lib/time-graph-render-controller.js.map +1 -0
- package/lib/time-graph-row-controller.d.ts +9 -2
- package/lib/time-graph-row-controller.js +41 -2
- package/lib/time-graph-row-controller.js.map +1 -1
- package/lib/time-graph-state-controller.d.ts +33 -6
- package/lib/time-graph-state-controller.js +121 -10
- package/lib/time-graph-state-controller.js.map +1 -1
- package/lib/time-graph-unit-controller.d.ts +14 -4
- package/lib/time-graph-unit-controller.js +27 -4
- package/lib/time-graph-unit-controller.js.map +1 -1
- package/package.json +20 -5
- package/src/bigint-utils.ts +7 -0
- package/src/components/time-graph-annotation.ts +18 -3
- package/src/components/time-graph-arrow.ts +1 -6
- package/src/components/time-graph-axis-scale.ts +51 -13
- package/src/components/time-graph-component.ts +14 -3
- package/src/components/time-graph-row.ts +50 -6
- package/src/components/time-graph-state.ts +84 -36
- package/src/layer/time-graph-axis.ts +7 -2
- package/src/layer/time-graph-chart-arrows.ts +33 -12
- package/src/layer/time-graph-chart-cursors.ts +39 -60
- package/src/layer/time-graph-chart-grid.ts +4 -2
- package/src/layer/time-graph-chart-layer.ts +4 -4
- package/src/layer/time-graph-chart-selection-range.ts +14 -12
- package/src/layer/time-graph-chart.ts +446 -205
- package/src/layer/time-graph-layer.ts +13 -4
- package/src/layer/time-graph-markers-chart-cursors.ts +66 -0
- package/src/layer/time-graph-navigator.ts +51 -13
- package/src/layer/time-graph-range-events-layer.ts +10 -10
- package/src/layer/time-graph-vertical-scrollbar.ts +68 -14
- package/src/layer/time-graph-viewport-layer.ts +57 -0
- package/src/time-graph-container.ts +25 -3
- package/src/time-graph-font-controller.ts +57 -16
- package/src/time-graph-render-controller.ts +65 -0
- package/src/time-graph-row-controller.ts +50 -7
- package/src/time-graph-state-controller.ts +128 -14
- package/src/time-graph-unit-controller.ts +38 -8
- package/jest.config.json +0 -26
- package/lib/components/__tests__/time-graph-arrow.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-arrow.test.js +0 -26
- package/lib/components/__tests__/time-graph-arrow.test.js.map +0 -1
- package/lib/components/__tests__/time-graph-axis-cursor.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-axis-cursor.test.js +0 -17
- package/lib/components/__tests__/time-graph-axis-cursor.test.js.map +0 -1
- package/lib/components/__tests__/time-graph-axis-scale.test.d.ts +0 -1
- package/lib/components/__tests__/time-graph-axis-scale.test.js +0 -33
- package/lib/components/__tests__/time-graph-axis-scale.test.js.map +0 -1
- package/src/components/__tests__/__snapshots__/time-graph-arrow.test.ts.snap +0 -1067
- package/src/components/__tests__/__snapshots__/time-graph-axis-cursor.test.ts.snap +0 -535
- package/src/components/__tests__/time-graph-arrow.test.ts +0 -26
- package/src/components/__tests__/time-graph-axis-cursor.test.ts +0 -17
- package/src/components/__tests__/time-graph-axis-scale.test.ts +0 -34
- package/tsconfig.json +0 -28
|
@@ -29,7 +29,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
29
29
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
30
|
function step(op) {
|
|
31
31
|
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
33
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
34
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
35
|
switch (op[0]) {
|
|
@@ -50,6 +50,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
var __values = (this && this.__values) || function(o) {
|
|
54
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
55
|
+
if (m) return m.call(o);
|
|
56
|
+
if (o && typeof o.length === "number") return {
|
|
57
|
+
next: function () {
|
|
58
|
+
if (o && i >= o.length) o = void 0;
|
|
59
|
+
return { value: o && o[i++], done: !o };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
63
|
+
};
|
|
53
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
65
|
exports.TimeGraphChart = exports.keyBoardNavs = void 0;
|
|
55
66
|
var time_graph_annotation_1 = require("../components/time-graph-annotation");
|
|
@@ -65,24 +76,47 @@ exports.keyBoardNavs = {
|
|
|
65
76
|
"panleft": ['a', 'j'],
|
|
66
77
|
"panright": ['d', 'l']
|
|
67
78
|
};
|
|
79
|
+
var VISIBLE_ROW_BUFFER = 3; // number of buffer rows above and below visible range
|
|
80
|
+
var FINE_RESOLUTION_FACTOR = 1; // fine resolution factor or default to disable coarse update
|
|
68
81
|
var TimeGraphChart = /** @class */ (function (_super) {
|
|
69
82
|
__extends(TimeGraphChart, _super);
|
|
70
|
-
function TimeGraphChart(id, providers, rowController) {
|
|
83
|
+
function TimeGraphChart(id, providers, rowController, _coarseResolutionFactor) {
|
|
84
|
+
if (_coarseResolutionFactor === void 0) { _coarseResolutionFactor = FINE_RESOLUTION_FACTOR; }
|
|
71
85
|
var _this = _super.call(this, id, rowController) || this;
|
|
72
86
|
_this.providers = providers;
|
|
73
87
|
_this.rowController = rowController;
|
|
74
|
-
_this.
|
|
88
|
+
_this._coarseResolutionFactor = _coarseResolutionFactor;
|
|
89
|
+
_this.rowComponents = new Map(); // map of rowId to row component
|
|
90
|
+
_this.selectedStateChangedHandler = [];
|
|
75
91
|
_this.mousePanning = false;
|
|
76
92
|
_this.mouseZooming = false;
|
|
77
93
|
_this.mouseButtons = 0;
|
|
78
|
-
_this.
|
|
94
|
+
_this._filterExpressionsMap = undefined;
|
|
95
|
+
_this._debouncedMaybeFetchNewData = (0, lodash_1.debounce)(function () { return _this.maybeFetchNewData(false); }, 400);
|
|
96
|
+
_this._debouncedMaybeFetchNewDataFine = (0, lodash_1.debounce)(function () { return _this.maybeFetchNewData(false, true); }, 400);
|
|
97
|
+
_this._debouncedMaybeFetchNewDataFineFullSearch = (0, lodash_1.debounce)(function () { return _this.maybeFetchNewData(false, true, true); }, 400);
|
|
79
98
|
// Keep track of the most recently clicked point.
|
|
80
99
|
// If clicked again during _multiClickTime duration (milliseconds) record multi-click
|
|
81
100
|
_this._recentlyClickedGlobal = null;
|
|
82
101
|
_this._multiClickTime = 500;
|
|
83
102
|
_this._mouseClicks = 0;
|
|
84
|
-
|
|
85
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Ensures that we always see the row lines.
|
|
105
|
+
* This is a hacky solution that triggers every view range change.
|
|
106
|
+
*/
|
|
107
|
+
_this.ensureRowLinesFitViewWidth = function () {
|
|
108
|
+
var newRowWidth = _this.stateController.canvasDisplayWidth / _this.stateController.scaleFactor;
|
|
109
|
+
_this.rowComponents.forEach(function (rowComponent) {
|
|
110
|
+
rowComponent.update({
|
|
111
|
+
height: _this.rowController.rowHeight,
|
|
112
|
+
position: {
|
|
113
|
+
x: -_this.stateController.positionOffset.x,
|
|
114
|
+
y: rowComponent.position.y
|
|
115
|
+
},
|
|
116
|
+
width: newRowWidth,
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
};
|
|
86
120
|
_this.isNavigating = false;
|
|
87
121
|
return _this;
|
|
88
122
|
}
|
|
@@ -91,8 +125,8 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
91
125
|
return;
|
|
92
126
|
}
|
|
93
127
|
if (zoomPosition === undefined) {
|
|
94
|
-
var start_1 = this.
|
|
95
|
-
var end_1 = this.
|
|
128
|
+
var start_1 = this.getWorldPixel(this.unitController.selectionRange ? this.unitController.selectionRange.start : BigInt(0));
|
|
129
|
+
var end_1 = this.getWorldPixel(this.unitController.selectionRange ? this.unitController.selectionRange.end : this.stateController.worldRangeLength);
|
|
96
130
|
zoomPosition = (start_1 + end_1) / 2;
|
|
97
131
|
}
|
|
98
132
|
var zoomTime = zoomPosition / this.stateController.zoomFactor;
|
|
@@ -108,7 +142,6 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
108
142
|
};
|
|
109
143
|
}
|
|
110
144
|
};
|
|
111
|
-
;
|
|
112
145
|
TimeGraphChart.prototype.afterAddToContainer = function () {
|
|
113
146
|
var _this = this;
|
|
114
147
|
this.stage.cursor = 'default';
|
|
@@ -173,6 +206,12 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
173
206
|
else if (exports.keyBoardNavs['panright'].indexOf(keyPressed) >= 0) {
|
|
174
207
|
moveHorizontally(horizontalDelta);
|
|
175
208
|
}
|
|
209
|
+
else if (keyPressed === 'ArrowUp') {
|
|
210
|
+
_this.navigateUp();
|
|
211
|
+
}
|
|
212
|
+
else if (keyPressed === 'ArrowDown') {
|
|
213
|
+
_this.navigateDown();
|
|
214
|
+
}
|
|
176
215
|
event.preventDefault();
|
|
177
216
|
}
|
|
178
217
|
if (keyPressed === 'Escape' && _this.mouseZooming) {
|
|
@@ -314,51 +353,87 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
314
353
|
this.onCanvasEvent('contextmenu', this._contextMenuHandler);
|
|
315
354
|
this.rowController.onVerticalOffsetChangedHandler(function (verticalOffset) {
|
|
316
355
|
_this.layer.position.y = -verticalOffset;
|
|
356
|
+
_this._debouncedMaybeFetchNewData();
|
|
317
357
|
});
|
|
318
358
|
this._viewRangeChangedHandler = function () {
|
|
319
|
-
_this.
|
|
320
|
-
|
|
321
|
-
_this.updateZoomingSelection();
|
|
322
|
-
}
|
|
359
|
+
_this.updateZoomingSelection();
|
|
360
|
+
_this.ensureRowLinesFitViewWidth();
|
|
323
361
|
};
|
|
324
362
|
this.unitController.onViewRangeChanged(this._viewRangeChangedHandler);
|
|
325
363
|
this.unitController.onViewRangeChanged(this._debouncedMaybeFetchNewData);
|
|
364
|
+
this._scaleFactorChangedHandler = function () {
|
|
365
|
+
_this.scaleComponents();
|
|
366
|
+
};
|
|
367
|
+
this.stateController.onScaleFactorChange(this._scaleFactorChangedHandler);
|
|
368
|
+
/**
|
|
369
|
+
* We need to explicitly re-render every zoom change because of edge case:
|
|
370
|
+
* WorldRange = Absolute Range && ViewRange < WorldRange
|
|
371
|
+
* When we are at above state, and reset view to home, nothing happens.
|
|
372
|
+
* We already rendered the world and don't rerender (WorldRange doesn't change)
|
|
373
|
+
* this.maybeFetchNewData is called and we don't fetch or trigger viewport.handleOnWorldRange.
|
|
374
|
+
* This is because don't re-render the world since it's we already have the entire trace rendered.
|
|
375
|
+
* We don't currently have any logic for scaling the world down.
|
|
376
|
+
* UpdatingScaleAndPosition also scales everything down nicely when zooming out :)
|
|
377
|
+
* Side effect - stage.width is always reset to renderer.width when this is called.
|
|
378
|
+
*/
|
|
379
|
+
this._zoomRangeChangedHandler = function (zoomFactor) {
|
|
380
|
+
_this.ensureRowLinesFitViewWidth();
|
|
381
|
+
_this.stateController.handleOnWorldRender();
|
|
382
|
+
};
|
|
383
|
+
this.stateController.onZoomChanged(this._zoomRangeChangedHandler);
|
|
326
384
|
if (this.unitController.viewRangeLength && this.stateController.canvasDisplayWidth) {
|
|
327
385
|
this.maybeFetchNewData();
|
|
328
386
|
}
|
|
329
387
|
};
|
|
330
|
-
TimeGraphChart.prototype.updateChart = function () {
|
|
388
|
+
TimeGraphChart.prototype.updateChart = function (filterExpressionsMap) {
|
|
331
389
|
var update = true;
|
|
390
|
+
this._filterExpressionsMap = filterExpressionsMap;
|
|
332
391
|
if (this.unitController && this.stateController) {
|
|
333
392
|
this.maybeFetchNewData(update);
|
|
334
393
|
}
|
|
335
394
|
};
|
|
336
395
|
TimeGraphChart.prototype.update = function () {
|
|
337
|
-
this.
|
|
396
|
+
this.ensureRowLinesFitViewWidth();
|
|
338
397
|
this._debouncedMaybeFetchNewData();
|
|
339
398
|
};
|
|
340
399
|
TimeGraphChart.prototype.updateZoomingSelection = function () {
|
|
341
|
-
if (this.zoomingSelection) {
|
|
400
|
+
if (!this.mouseZooming && this.zoomingSelection) {
|
|
342
401
|
this.removeChild(this.zoomingSelection);
|
|
343
402
|
delete this.zoomingSelection;
|
|
344
403
|
}
|
|
345
|
-
if (this.mouseZooming) {
|
|
346
|
-
|
|
347
|
-
this.
|
|
404
|
+
else if (this.mouseZooming) {
|
|
405
|
+
// The zooming selection should not be scaled. It should use the actual mouse coordinates.
|
|
406
|
+
var x = this.getWorldPixel(this.mouseZoomingStart) / this.stateController.scaleFactor;
|
|
407
|
+
var options = {
|
|
348
408
|
color: 0xbbbbbb,
|
|
349
409
|
opacity: 0.2,
|
|
350
410
|
position: {
|
|
351
|
-
x:
|
|
411
|
+
x: x,
|
|
352
412
|
y: 0
|
|
353
413
|
},
|
|
354
414
|
height: Math.max(this.stateController.canvasDisplayHeight, this.rowController.totalHeight),
|
|
355
|
-
width: this.mouseEndX - mouseStartX
|
|
356
|
-
}
|
|
357
|
-
|
|
415
|
+
width: (this.mouseEndX - this.mouseStartX) / this.stateController.scaleFactor
|
|
416
|
+
};
|
|
417
|
+
if (!this.zoomingSelection) {
|
|
418
|
+
// Add the rectangle if we don't have one
|
|
419
|
+
this.zoomingSelection = new time_graph_rectangle_1.TimeGraphRectangle(options);
|
|
420
|
+
this.addChild(this.zoomingSelection);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
// Update the rectangle if we do
|
|
424
|
+
this.zoomingSelection.update(options);
|
|
425
|
+
}
|
|
358
426
|
}
|
|
359
427
|
};
|
|
428
|
+
TimeGraphChart.prototype.removeChildren = function () {
|
|
429
|
+
this.rowComponents.clear();
|
|
430
|
+
_super.prototype.removeChildren.call(this);
|
|
431
|
+
};
|
|
360
432
|
TimeGraphChart.prototype.destroy = function () {
|
|
433
|
+
this.stateController.removeOnZoomChanged(this._zoomRangeChangedHandler);
|
|
434
|
+
this.stateController.removeOnScaleFactorChanged(this._scaleFactorChangedHandler);
|
|
361
435
|
this.unitController.removeViewRangeChangedHandler(this._debouncedMaybeFetchNewData);
|
|
436
|
+
this.unitController.removeViewRangeChangedHandler(this._viewRangeChangedHandler);
|
|
362
437
|
if (this._viewRangeChangedHandler) {
|
|
363
438
|
this.unitController.removeViewRangeChangedHandler(this._viewRangeChangedHandler);
|
|
364
439
|
}
|
|
@@ -387,46 +462,152 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
387
462
|
this.stage.off('mouseup', this._stageMouseUpHandler);
|
|
388
463
|
this.stage.off('mouseupoutside', this._stageMouseUpHandler);
|
|
389
464
|
}
|
|
465
|
+
this.rowComponents.clear();
|
|
390
466
|
_super.prototype.destroy.call(this);
|
|
391
467
|
};
|
|
392
|
-
TimeGraphChart.prototype.maybeFetchNewData = function (update) {
|
|
468
|
+
TimeGraphChart.prototype.maybeFetchNewData = function (update, fine, fullSearch) {
|
|
393
469
|
return __awaiter(this, void 0, void 0, function () {
|
|
394
|
-
var
|
|
470
|
+
var visibleRowIds, viewRange, resolutionFactor, resolution, rowIds, allRowsUpdated, worldRange, additionalParams, i, request, error_1, i, rowComponent, request, error_2;
|
|
471
|
+
var _this = this;
|
|
395
472
|
return __generator(this, function (_a) {
|
|
396
473
|
switch (_a.label) {
|
|
397
474
|
case 0:
|
|
398
|
-
|
|
475
|
+
this.rowIds = this.providers.rowProvider().rowIds;
|
|
476
|
+
if (update) {
|
|
477
|
+
// update position of existing rows and remove deleted rows
|
|
478
|
+
this.rowComponents.forEach(function (rowComponent, rowId) {
|
|
479
|
+
var index = _this.rowIds.indexOf(rowId);
|
|
480
|
+
if (index == -1) {
|
|
481
|
+
_this.rowComponents.delete(rowId);
|
|
482
|
+
_this.removeChild(rowComponent);
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
rowComponent.position.y = _this.rowController.rowHeight * index;
|
|
486
|
+
rowComponent.providedModel = undefined;
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
// update selected row
|
|
490
|
+
if (this.rowController.selectedRow) {
|
|
491
|
+
this.rowController.selectedRowIndex = this.rowIds.indexOf(this.rowController.selectedRow.id);
|
|
492
|
+
if (this.rowController.selectedRowIndex === -1) {
|
|
493
|
+
this.rowController.selectedRow = undefined;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
// create placeholder rows
|
|
497
|
+
this.rowIds.forEach(function (rowId) {
|
|
498
|
+
if (!_this.rowComponents.get(rowId)) {
|
|
499
|
+
_this.addRow(rowId);
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
visibleRowIds = this.getVisibleRowIds(VISIBLE_ROW_BUFFER);
|
|
399
504
|
viewRange = this.unitController.viewRange;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
505
|
+
resolutionFactor = fine ? FINE_RESOLUTION_FACTOR : this._coarseResolutionFactor;
|
|
506
|
+
resolution = (resolutionFactor * Number(this.unitController.viewRangeLength)) / this.stateController.canvasDisplayWidth;
|
|
507
|
+
rowIds = visibleRowIds.filter(function (rowId) {
|
|
508
|
+
var rowComponent = _this.rowComponents.get(rowId);
|
|
509
|
+
return (update ||
|
|
510
|
+
!rowComponent ||
|
|
511
|
+
!rowComponent.providedModel ||
|
|
512
|
+
viewRange.start < rowComponent.providedModel.range.start || // This logic can be updated for pre-rendering before we reach the end.
|
|
513
|
+
viewRange.end > rowComponent.providedModel.range.end || // This logic can be updated for pre-rendering before we reach the end.
|
|
514
|
+
!(0, lodash_1.isEqual)(_this.stateController.worldRange, rowComponent.providedModel.range) ||
|
|
515
|
+
resolution < rowComponent.providedModel.resolution || !(0, lodash_1.isEqual)(rowComponent.providedModel.filterExpressionsMap, _this._filterExpressionsMap));
|
|
516
|
+
});
|
|
517
|
+
if (!(rowIds.length > 0)) return [3 /*break*/, 11];
|
|
518
|
+
allRowsUpdated = rowIds.length === visibleRowIds.length;
|
|
519
|
+
worldRange = allRowsUpdated ? this.stateController.computeWorldRangeFromViewRange() : this.stateController.worldRange;
|
|
520
|
+
additionalParams = {};
|
|
521
|
+
if (this._filterExpressionsMap) {
|
|
522
|
+
additionalParams['filter_query_parameters'] = { 'filter_expressions_map': this._filterExpressionsMap, 'strategy': fullSearch ? 'DEEP' : 'SAMPLED' };
|
|
523
|
+
}
|
|
524
|
+
if (!fullSearch) return [3 /*break*/, 7];
|
|
525
|
+
i = 0;
|
|
526
|
+
_a.label = 1;
|
|
527
|
+
case 1:
|
|
528
|
+
if (!(i < rowIds.length)) return [3 /*break*/, 6];
|
|
529
|
+
_a.label = 2;
|
|
530
|
+
case 2:
|
|
531
|
+
_a.trys.push([2, 4, , 5]);
|
|
532
|
+
request = { worldRange: worldRange, resolution: resolution, rowIds: [rowIds[i]], additionalParams: additionalParams, fullSearch: fullSearch };
|
|
533
|
+
return [4 /*yield*/, this.fetchRows(request, i === rowIds.length - 1, fine)];
|
|
534
|
+
case 3:
|
|
535
|
+
_a.sent();
|
|
536
|
+
return [3 /*break*/, 5];
|
|
537
|
+
case 4:
|
|
538
|
+
error_1 = _a.sent();
|
|
539
|
+
return [2 /*return*/];
|
|
540
|
+
case 5:
|
|
541
|
+
i++;
|
|
542
|
+
return [3 /*break*/, 1];
|
|
543
|
+
case 6:
|
|
544
|
+
// When row-by-row fetch is completed (not interrupted by new request), update model with filter
|
|
545
|
+
for (i = 0; i < rowIds.length; i++) {
|
|
546
|
+
rowComponent = this.rowComponents.get(rowIds[i]);
|
|
547
|
+
if (rowComponent && rowComponent.providedModel) {
|
|
548
|
+
rowComponent.providedModel.filterExpressionsMap = this._filterExpressionsMap;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return [3 /*break*/, 10];
|
|
552
|
+
case 7:
|
|
553
|
+
_a.trys.push([7, 9, , 10]);
|
|
554
|
+
request = { worldRange: worldRange, resolution: resolution, rowIds: rowIds, additionalParams: additionalParams, fullSearch: fullSearch };
|
|
555
|
+
return [4 /*yield*/, this.fetchRows(request, !fullSearch, fine)];
|
|
556
|
+
case 8:
|
|
557
|
+
_a.sent();
|
|
558
|
+
return [3 /*break*/, 10];
|
|
559
|
+
case 9:
|
|
560
|
+
error_2 = _a.sent();
|
|
561
|
+
return [2 /*return*/];
|
|
562
|
+
case 10: return [3 /*break*/, 12];
|
|
563
|
+
case 11:
|
|
564
|
+
if (!fine && this._coarseResolutionFactor !== FINE_RESOLUTION_FACTOR) {
|
|
565
|
+
// no row to update for coarse resolution, try fine resolution
|
|
566
|
+
this.maybeFetchNewData(update, true);
|
|
567
|
+
}
|
|
568
|
+
_a.label = 12;
|
|
569
|
+
case 12: return [2 /*return*/];
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
});
|
|
573
|
+
};
|
|
574
|
+
TimeGraphChart.prototype.fetchRows = function (request, fetchArrows, fine) {
|
|
575
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
576
|
+
var rowData;
|
|
577
|
+
return __generator(this, function (_a) {
|
|
578
|
+
switch (_a.label) {
|
|
579
|
+
case 0:
|
|
405
580
|
if ((0, lodash_1.isEqual)(request, this.ongoingRequest)) {
|
|
406
581
|
// request ignored because equal to ongoing request
|
|
407
582
|
return [2 /*return*/];
|
|
408
583
|
}
|
|
584
|
+
this._debouncedMaybeFetchNewDataFine.cancel();
|
|
585
|
+
this._debouncedMaybeFetchNewDataFineFullSearch.cancel();
|
|
409
586
|
_a.label = 1;
|
|
410
587
|
case 1:
|
|
411
588
|
_a.trys.push([1, , 3, 4]);
|
|
412
589
|
this.ongoingRequest = request;
|
|
413
|
-
return [4 /*yield*/, this.providers.dataProvider(
|
|
590
|
+
return [4 /*yield*/, this.providers.dataProvider(request.worldRange, request.resolution, fetchArrows, request.rowIds, request.additionalParams)];
|
|
414
591
|
case 2:
|
|
415
592
|
rowData = _a.sent();
|
|
416
593
|
if (!(0, lodash_1.isEqual)(request, this.ongoingRequest)) {
|
|
417
594
|
// response discarded because not equal to ongoing request
|
|
418
|
-
return [2 /*return
|
|
595
|
+
return [2 /*return*/, Promise.reject(new Error("Ongoing request updated"))];
|
|
419
596
|
}
|
|
420
597
|
if (rowData) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
598
|
+
if (!request.fullSearch) {
|
|
599
|
+
this.stateController.worldRange = request.worldRange;
|
|
600
|
+
this.stateController.worldZoomFactor = this.stateController.zoomFactor;
|
|
601
|
+
this.stateController.resetScale();
|
|
602
|
+
}
|
|
603
|
+
this.addOrUpdateRows(rowData);
|
|
426
604
|
if (this.isNavigating) {
|
|
427
605
|
this.selectStateInNavigation();
|
|
428
606
|
}
|
|
429
607
|
if (this.mouseZooming) {
|
|
608
|
+
if (this.zoomingSelection) {
|
|
609
|
+
this.removeChild(this.zoomingSelection);
|
|
610
|
+
}
|
|
430
611
|
delete this.zoomingSelection;
|
|
431
612
|
this.updateZoomingSelection();
|
|
432
613
|
}
|
|
@@ -437,132 +618,103 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
437
618
|
this.ongoingRequest = undefined;
|
|
438
619
|
}
|
|
439
620
|
this.isNavigating = false;
|
|
621
|
+
if (!fine && this._coarseResolutionFactor !== FINE_RESOLUTION_FACTOR) {
|
|
622
|
+
this._debouncedMaybeFetchNewDataFine();
|
|
623
|
+
}
|
|
624
|
+
if (this._filterExpressionsMap && !request.fullSearch && (fine || this._coarseResolutionFactor === FINE_RESOLUTION_FACTOR)) {
|
|
625
|
+
// fine resolution done for sampled search, time for deep search in fine res
|
|
626
|
+
this._debouncedMaybeFetchNewDataFineFullSearch();
|
|
627
|
+
}
|
|
440
628
|
return [7 /*endfinally*/];
|
|
441
|
-
case 4:
|
|
629
|
+
case 4:
|
|
630
|
+
// After we build the new world from new data, execute render handlers.
|
|
631
|
+
// Only execute after first, coarse render. Don't need to repeat after second, fine render.
|
|
632
|
+
this.stateController.handleOnWorldRender();
|
|
633
|
+
return [2 /*return*/];
|
|
442
634
|
}
|
|
443
635
|
});
|
|
444
636
|
});
|
|
445
637
|
};
|
|
446
|
-
TimeGraphChart.prototype.
|
|
638
|
+
TimeGraphChart.prototype.handleSelectedStateChange = function () {
|
|
447
639
|
var _this = this;
|
|
448
|
-
|
|
449
|
-
this.rows.forEach(function (row) {
|
|
450
|
-
var rowComponent = _this.rowComponents.get(row);
|
|
451
|
-
if (rowComponent) {
|
|
452
|
-
var opts = {
|
|
453
|
-
height: _this.rowController.rowHeight,
|
|
454
|
-
position: {
|
|
455
|
-
x: 0,
|
|
456
|
-
y: rowComponent.position.y
|
|
457
|
-
},
|
|
458
|
-
width: _this.stateController.canvasDisplayWidth
|
|
459
|
-
};
|
|
460
|
-
rowComponent.update(opts);
|
|
461
|
-
}
|
|
462
|
-
var lastX;
|
|
463
|
-
var lastTime;
|
|
464
|
-
var lastBlank = false;
|
|
465
|
-
row.states.forEach(function (state, elementIndex) {
|
|
466
|
-
var _a;
|
|
467
|
-
var el = _this.rowStateComponents.get(state);
|
|
468
|
-
var start = state.range.start;
|
|
469
|
-
var xStart = _this.getPixel(start - _this.unitController.viewRange.start);
|
|
470
|
-
if (el) {
|
|
471
|
-
var end = state.range.end;
|
|
472
|
-
var xEnd = _this.getPixel(end - _this.unitController.viewRange.start);
|
|
473
|
-
var opts = {
|
|
474
|
-
height: el.height,
|
|
475
|
-
position: {
|
|
476
|
-
x: xStart,
|
|
477
|
-
y: el.position.y
|
|
478
|
-
},
|
|
479
|
-
width: Math.max(1, xEnd - xStart),
|
|
480
|
-
displayWidth: _this.getPixel(bigint_utils_1.BIMath.min(_this.unitController.viewRange.end, end)) - _this.getPixel(bigint_utils_1.BIMath.max(_this.unitController.viewRange.start, start))
|
|
481
|
-
};
|
|
482
|
-
el.update(opts);
|
|
483
|
-
}
|
|
484
|
-
if (rowComponent && row.gapStyle) {
|
|
485
|
-
_this.updateGap(state, rowComponent, row.gapStyle, xStart, lastX, lastTime, lastBlank);
|
|
486
|
-
}
|
|
487
|
-
lastX = Math.max(xStart + 1, _this.getPixel(state.range.end - _this.unitController.viewRange.start));
|
|
488
|
-
lastTime = state.range.end;
|
|
489
|
-
lastBlank = (((_a = state.data) === null || _a === void 0 ? void 0 : _a.style) === undefined);
|
|
490
|
-
});
|
|
491
|
-
row.annotations.forEach(function (annotation, elementIndex) {
|
|
492
|
-
var el = _this.rowAnnotationComponents.get(annotation);
|
|
493
|
-
if (el) {
|
|
494
|
-
// only handle ticks for now
|
|
495
|
-
var start = annotation.range.start;
|
|
496
|
-
var opts = {
|
|
497
|
-
position: {
|
|
498
|
-
x: _this.getPixel(start - _this.unitController.viewRange.start),
|
|
499
|
-
y: el.displayObject.y
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
el.update(opts);
|
|
503
|
-
}
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
}
|
|
640
|
+
this.selectedStateChangedHandler.forEach(function (handler) { return handler(_this.selectedStateModel); });
|
|
507
641
|
};
|
|
508
|
-
TimeGraphChart.prototype.
|
|
642
|
+
TimeGraphChart.prototype.addOrUpdateRows = function (rowData) {
|
|
509
643
|
var _this = this;
|
|
510
|
-
this.
|
|
644
|
+
if (!this.stateController) {
|
|
645
|
+
throw 'Add this TimeGraphChart to a container before adding rows.';
|
|
646
|
+
}
|
|
647
|
+
var providedModel = { range: rowData.range, resolution: rowData.resolution };
|
|
648
|
+
rowData.rows.forEach(function (row) {
|
|
649
|
+
var rowComponent = _this.rowComponents.get(row.id);
|
|
650
|
+
if (rowComponent) {
|
|
651
|
+
_this.removeChild(rowComponent);
|
|
652
|
+
}
|
|
653
|
+
_this.addRow(row.id, row, providedModel);
|
|
654
|
+
});
|
|
511
655
|
};
|
|
512
|
-
TimeGraphChart.prototype.addRow = function (
|
|
656
|
+
TimeGraphChart.prototype.addRow = function (rowId, row, providedModel) {
|
|
513
657
|
var _this = this;
|
|
514
|
-
var
|
|
658
|
+
var id = 'row_' + rowId;
|
|
659
|
+
var rowIndex = this.rowIds.indexOf(rowId);
|
|
515
660
|
var rowStyle = this.providers.rowStyleProvider ? this.providers.rowStyleProvider(row) : undefined;
|
|
516
|
-
var rowComponent = new time_graph_row_1.TimeGraphRow(
|
|
661
|
+
var rowComponent = new time_graph_row_1.TimeGraphRow(id, {
|
|
517
662
|
position: {
|
|
518
663
|
x: 0,
|
|
519
|
-
y:
|
|
664
|
+
y: this.rowController.rowHeight * rowIndex
|
|
520
665
|
},
|
|
521
|
-
width: this.
|
|
522
|
-
height:
|
|
666
|
+
width: this.rowWidth,
|
|
667
|
+
height: this.rowController.rowHeight
|
|
523
668
|
}, rowIndex, row, rowStyle);
|
|
524
669
|
rowComponent.displayObject.interactive = true;
|
|
525
670
|
rowComponent.displayObject.on('click', (function (e) {
|
|
526
671
|
_this.selectRow(row);
|
|
527
672
|
}).bind(this));
|
|
528
673
|
this.addChild(rowComponent);
|
|
529
|
-
this.rowComponents.set(
|
|
530
|
-
if (this.rowController.
|
|
674
|
+
this.rowComponents.set(rowId, rowComponent);
|
|
675
|
+
if (this.rowController.selectedRowIndex == rowIndex) {
|
|
531
676
|
this.selectRow(row);
|
|
532
677
|
}
|
|
678
|
+
if (row && providedModel) {
|
|
679
|
+
this.updateRow(rowComponent, row, providedModel);
|
|
680
|
+
}
|
|
681
|
+
};
|
|
682
|
+
TimeGraphChart.prototype.updateRow = function (rowComponent, row, providedModel) {
|
|
683
|
+
var _this = this;
|
|
533
684
|
var lastX;
|
|
534
685
|
var lastTime;
|
|
535
686
|
var lastBlank = false;
|
|
536
687
|
row.states.forEach(function (stateModel) {
|
|
537
688
|
var _a, _b;
|
|
538
|
-
var x = _this.
|
|
689
|
+
var x = _this.getWorldPixel(stateModel.range.start);
|
|
539
690
|
if ((_a = stateModel.data) === null || _a === void 0 ? void 0 : _a.style) {
|
|
540
691
|
var el = _this.createNewState(stateModel, rowComponent);
|
|
541
692
|
if (el) {
|
|
542
693
|
_this.addElementInteractions(el);
|
|
543
|
-
|
|
544
|
-
if (_this.selectedStateModel && _this.rowController.selectedRow
|
|
545
|
-
&& _this.rowController.selectedRow.id === row.id
|
|
546
|
-
&& _this.selectedStateModel.range.start === el.model.range.start
|
|
547
|
-
&& _this.selectedStateModel.range.end === el.model.range.end) {
|
|
548
|
-
_this.selectState(el.model);
|
|
549
|
-
}
|
|
694
|
+
rowComponent.addState(el);
|
|
550
695
|
}
|
|
551
696
|
}
|
|
552
697
|
if (row.gapStyle) {
|
|
553
698
|
_this.updateGap(stateModel, rowComponent, row.gapStyle, x, lastX, lastTime, lastBlank);
|
|
554
699
|
}
|
|
555
|
-
lastX = Math.max(x + 1, _this.
|
|
700
|
+
lastX = Math.max(x + 1, _this.getWorldPixel(stateModel.range.end));
|
|
556
701
|
lastTime = stateModel.range.end;
|
|
557
702
|
lastBlank = (((_b = stateModel.data) === null || _b === void 0 ? void 0 : _b.style) === undefined);
|
|
558
703
|
});
|
|
704
|
+
if (this.rowController.selectedRow && this.unitController.selectionRange && this.rowController.selectedRow.id === row.id) {
|
|
705
|
+
var state = row.states.find(function (state) {
|
|
706
|
+
return _this.unitController.selectionRange && state.range.start <= _this.unitController.selectionRange.start && state.range.end > _this.unitController.selectionRange.start;
|
|
707
|
+
});
|
|
708
|
+
this.selectState(state);
|
|
709
|
+
}
|
|
559
710
|
row.annotations.forEach(function (annotation) {
|
|
560
711
|
var el = _this.createNewAnnotation(annotation, rowComponent);
|
|
561
712
|
if (el) {
|
|
562
713
|
_this.addElementInteractions(el);
|
|
563
|
-
|
|
714
|
+
rowComponent.addAnnotation(el);
|
|
564
715
|
}
|
|
565
716
|
});
|
|
717
|
+
rowComponent.providedModel = providedModel;
|
|
566
718
|
};
|
|
567
719
|
TimeGraphChart.prototype.updateGap = function (state, rowComponent, gapStyle, x, lastX, lastTime, lastBlank) {
|
|
568
720
|
var _a, _b, _c, _d;
|
|
@@ -595,38 +747,35 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
595
747
|
};
|
|
596
748
|
var gap_1 = this.createNewState(stateModel, rowComponent);
|
|
597
749
|
if (gap_1) {
|
|
598
|
-
|
|
750
|
+
rowComponent.addChild(gap_1);
|
|
599
751
|
if (state.data) {
|
|
600
752
|
state.data['gap'] = gap_1;
|
|
601
753
|
}
|
|
754
|
+
this.addElementInteractions(gap_1);
|
|
602
755
|
}
|
|
603
756
|
}
|
|
604
757
|
}
|
|
605
758
|
else {
|
|
606
759
|
if (state.data && ((_c = state.data) === null || _c === void 0 ? void 0 : _c.gap)) {
|
|
607
|
-
|
|
760
|
+
rowComponent.removeChild((_d = state.data) === null || _d === void 0 ? void 0 : _d.gap);
|
|
608
761
|
state.data.gap = undefined;
|
|
609
762
|
}
|
|
610
763
|
}
|
|
611
764
|
};
|
|
612
765
|
TimeGraphChart.prototype.createNewAnnotation = function (annotation, rowComponent) {
|
|
613
|
-
var start = this.
|
|
766
|
+
var start = this.getWorldPixel(annotation.range.start);
|
|
614
767
|
var el;
|
|
615
768
|
var elementStyle = this.providers.rowAnnotationStyleProvider ? this.providers.rowAnnotationStyleProvider(annotation) : undefined;
|
|
616
|
-
el = new time_graph_annotation_1.TimeGraphAnnotationComponent(annotation.id, annotation, { position: { x: start, y: rowComponent.position.y + (rowComponent.height * 0.5) } }, elementStyle, rowComponent);
|
|
617
|
-
this.rowAnnotationComponents.set(annotation, el);
|
|
769
|
+
el = new time_graph_annotation_1.TimeGraphAnnotationComponent(annotation.id, annotation, { position: { x: start, y: rowComponent.position.y + (rowComponent.height * 0.5) } }, elementStyle, rowComponent, this.stateController.scaleFactor);
|
|
618
770
|
return el;
|
|
619
771
|
};
|
|
620
772
|
TimeGraphChart.prototype.createNewState = function (stateModel, rowComponent) {
|
|
621
|
-
var xStart = this.
|
|
622
|
-
var xEnd = this.
|
|
773
|
+
var xStart = this.getWorldPixel(stateModel.range.start, true);
|
|
774
|
+
var xEnd = this.getWorldPixel(stateModel.range.end, true);
|
|
623
775
|
var el;
|
|
624
|
-
var
|
|
625
|
-
var displayEnd = this.getPixel(bigint_utils_1.BIMath.min(stateModel.range.end, this.unitController.viewRange.end));
|
|
626
|
-
var displayWidth = displayEnd - displayStart;
|
|
776
|
+
var displayWidth = xEnd - xStart;
|
|
627
777
|
var elementStyle = this.providers.stateStyleProvider ? this.providers.stateStyleProvider(stateModel) : undefined;
|
|
628
|
-
el = new time_graph_state_1.TimeGraphStateComponent(stateModel.id, stateModel, xStart, xEnd, rowComponent, elementStyle, displayWidth);
|
|
629
|
-
this.rowStateComponents.set(stateModel, el);
|
|
778
|
+
el = new time_graph_state_1.TimeGraphStateComponent(stateModel.id, stateModel, xStart, xEnd, rowComponent, elementStyle, displayWidth, this.stateController.scaleFactor);
|
|
630
779
|
return el;
|
|
631
780
|
};
|
|
632
781
|
TimeGraphChart.prototype.addElementInteractions = function (el) {
|
|
@@ -642,7 +791,7 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
642
791
|
_this.selectState(el.model);
|
|
643
792
|
}
|
|
644
793
|
// Mouse clicks count keeps increasing without limit as long as we keep clicking on the same coordinate.
|
|
645
|
-
if (_this._recentlyClickedGlobal &&
|
|
794
|
+
if (_this._recentlyClickedGlobal && _this._recentlyClickedGlobal.equals(e.data.global)) {
|
|
646
795
|
_this._mouseClicks++;
|
|
647
796
|
}
|
|
648
797
|
else {
|
|
@@ -681,46 +830,49 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
681
830
|
}
|
|
682
831
|
}).bind(this));
|
|
683
832
|
};
|
|
684
|
-
TimeGraphChart.prototype.
|
|
685
|
-
var _this = this;
|
|
686
|
-
if (!this.stateController) {
|
|
687
|
-
throw ('Add this TimeGraphChart to a container before adding rows.');
|
|
688
|
-
}
|
|
689
|
-
this.rowComponents = new Map();
|
|
690
|
-
this.rowStateComponents = new Map();
|
|
691
|
-
this.rowAnnotationComponents = new Map();
|
|
692
|
-
this.rowController.rowHeight = height;
|
|
693
|
-
rows.forEach(function (row, index) {
|
|
694
|
-
_this.addRow(row, height, index);
|
|
695
|
-
});
|
|
696
|
-
};
|
|
697
|
-
TimeGraphChart.prototype.setRowModel = function (rows) {
|
|
698
|
-
this.rows = rows;
|
|
699
|
-
};
|
|
700
|
-
TimeGraphChart.prototype.updateElementStyle = function (model) {
|
|
833
|
+
TimeGraphChart.prototype.updateStateStyle = function (model) {
|
|
701
834
|
var style = this.providers.stateStyleProvider && this.providers.stateStyleProvider(model);
|
|
702
|
-
var component = this.
|
|
835
|
+
var component = this.getStateById(model.id);
|
|
703
836
|
component && style && (component.style = style);
|
|
704
837
|
};
|
|
705
838
|
TimeGraphChart.prototype.updateRowStyle = function (model) {
|
|
706
839
|
var style = this.providers.rowStyleProvider && this.providers.rowStyleProvider(model);
|
|
707
|
-
var component = this.rowComponents.get(model);
|
|
840
|
+
var component = this.rowComponents.get(model.id);
|
|
708
841
|
component && style && (component.style = style);
|
|
709
842
|
};
|
|
710
843
|
TimeGraphChart.prototype.registerMouseInteractions = function (interactions) {
|
|
711
844
|
this.mouseInteractions = interactions;
|
|
712
845
|
};
|
|
713
846
|
TimeGraphChart.prototype.onSelectedStateChanged = function (handler) {
|
|
714
|
-
this.
|
|
847
|
+
this.selectedStateChangedHandler.push(handler);
|
|
715
848
|
};
|
|
716
|
-
TimeGraphChart.prototype.
|
|
717
|
-
|
|
849
|
+
TimeGraphChart.prototype.getRowModel = function (index) {
|
|
850
|
+
var _a;
|
|
851
|
+
if (index >= this.rowIds.length) {
|
|
852
|
+
return undefined;
|
|
853
|
+
}
|
|
854
|
+
return (_a = this.rowComponents.get(this.rowIds[index])) === null || _a === void 0 ? void 0 : _a.model;
|
|
718
855
|
};
|
|
719
|
-
TimeGraphChart.prototype.
|
|
720
|
-
var
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
856
|
+
TimeGraphChart.prototype.getStateById = function (id) {
|
|
857
|
+
var e_1, _a;
|
|
858
|
+
var state = undefined;
|
|
859
|
+
try {
|
|
860
|
+
for (var _b = __values(this.rowComponents.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
861
|
+
var rowComponent = _c.value;
|
|
862
|
+
state = rowComponent.getStateById(id);
|
|
863
|
+
if (state) {
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
869
|
+
finally {
|
|
870
|
+
try {
|
|
871
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
872
|
+
}
|
|
873
|
+
finally { if (e_1) throw e_1.error; }
|
|
874
|
+
}
|
|
875
|
+
return state;
|
|
724
876
|
};
|
|
725
877
|
TimeGraphChart.prototype.selectRow = function (row) {
|
|
726
878
|
if (this.rowController.selectedRow) {
|
|
@@ -728,37 +880,46 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
728
880
|
this.updateRowStyle(this.rowController.selectedRow);
|
|
729
881
|
}
|
|
730
882
|
this.rowController.selectedRow = row;
|
|
731
|
-
row
|
|
732
|
-
|
|
883
|
+
if (row) {
|
|
884
|
+
this.rowController.selectedRowIndex = this.rowIds.indexOf(row.id);
|
|
885
|
+
row.selected = true;
|
|
886
|
+
this.updateRowStyle(row);
|
|
887
|
+
}
|
|
733
888
|
};
|
|
734
889
|
TimeGraphChart.prototype.getSelectedState = function () {
|
|
735
890
|
return this.selectedStateModel;
|
|
736
891
|
};
|
|
737
892
|
TimeGraphChart.prototype.selectState = function (model) {
|
|
893
|
+
if (this.selectedStateModel === model) {
|
|
894
|
+
return;
|
|
895
|
+
}
|
|
738
896
|
if (this.selectedStateModel) {
|
|
739
897
|
delete this.selectedStateModel.selected;
|
|
740
|
-
this.
|
|
898
|
+
this.updateStateStyle(this.selectedStateModel);
|
|
741
899
|
}
|
|
742
900
|
if (model) {
|
|
743
|
-
var
|
|
744
|
-
if (
|
|
745
|
-
var row =
|
|
901
|
+
var state = this.getStateById(model.id);
|
|
902
|
+
if (state) {
|
|
903
|
+
var row = state.row;
|
|
746
904
|
if (row) {
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
this.updateElementStyle(this.selectedStateModel);
|
|
905
|
+
state.model.selected = true;
|
|
906
|
+
this.updateStateStyle(state.model);
|
|
750
907
|
this.selectRow(row.model);
|
|
751
908
|
}
|
|
752
909
|
}
|
|
753
910
|
}
|
|
754
|
-
|
|
755
|
-
this.selectedStateModel = undefined;
|
|
756
|
-
}
|
|
911
|
+
this.selectedStateModel = model;
|
|
757
912
|
this.handleSelectedStateChange();
|
|
758
913
|
};
|
|
759
914
|
TimeGraphChart.prototype.setNavigationFlag = function (flag) {
|
|
760
915
|
this.isNavigating = flag;
|
|
761
916
|
};
|
|
917
|
+
TimeGraphChart.prototype.selectAndReveal = function (rowIndex) {
|
|
918
|
+
if (rowIndex >= 0 && rowIndex < this.rowIds.length) {
|
|
919
|
+
this.rowController.selectedRowIndex = rowIndex;
|
|
920
|
+
this.navigate(rowIndex, true);
|
|
921
|
+
}
|
|
922
|
+
};
|
|
762
923
|
TimeGraphChart.prototype.selectStateInNavigation = function () {
|
|
763
924
|
var row = this.rowController.selectedRow;
|
|
764
925
|
if (row && this.unitController.selectionRange) {
|
|
@@ -768,6 +929,108 @@ var TimeGraphChart = /** @class */ (function (_super) {
|
|
|
768
929
|
}
|
|
769
930
|
this.setNavigationFlag(false);
|
|
770
931
|
};
|
|
932
|
+
TimeGraphChart.prototype.navigateDown = function () {
|
|
933
|
+
if (this.rowIds.length > 0) {
|
|
934
|
+
this.rowController.selectedRowIndex = Math.min(this.rowController.selectedRowIndex + 1, this.rowIds.length - 1);
|
|
935
|
+
this.navigate(this.rowController.selectedRowIndex);
|
|
936
|
+
}
|
|
937
|
+
};
|
|
938
|
+
TimeGraphChart.prototype.navigateUp = function () {
|
|
939
|
+
if (this.rowIds.length > 0) {
|
|
940
|
+
this.rowController.selectedRowIndex = Math.max(this.rowController.selectedRowIndex - 1, 0);
|
|
941
|
+
this.navigate(this.rowController.selectedRowIndex);
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
TimeGraphChart.prototype.navigate = function (rowIndex, center) {
|
|
945
|
+
var _this = this;
|
|
946
|
+
this.ensureVisible(rowIndex, center);
|
|
947
|
+
var selectedRowId = this.rowIds[rowIndex];
|
|
948
|
+
var selectedRowComponent = this.rowComponents.get(selectedRowId);
|
|
949
|
+
if (!selectedRowComponent) {
|
|
950
|
+
this.selectRow(undefined);
|
|
951
|
+
this.selectState(undefined);
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
var selectedRow = selectedRowComponent.model;
|
|
955
|
+
this.selectRow(selectedRow);
|
|
956
|
+
var state = selectedRow === null || selectedRow === void 0 ? void 0 : selectedRow.states.find(function (state) {
|
|
957
|
+
return _this.unitController.selectionRange && state.range.start <= _this.unitController.selectionRange.start && state.range.end > _this.unitController.selectionRange.start;
|
|
958
|
+
});
|
|
959
|
+
this.selectState(state);
|
|
960
|
+
};
|
|
961
|
+
TimeGraphChart.prototype.getVisibleRowIds = function (buffer) {
|
|
962
|
+
var visibleRowIds = [];
|
|
963
|
+
var rowHeight = this.rowController.rowHeight;
|
|
964
|
+
// return all rows that intersect the visible height range with a number of buffer rows
|
|
965
|
+
var minY = this.rowController.verticalOffset - buffer * rowHeight;
|
|
966
|
+
var maxY = this.rowController.verticalOffset + this.stateController.canvasDisplayHeight + buffer * rowHeight;
|
|
967
|
+
this.rowIds.forEach(function (rowId, index) {
|
|
968
|
+
var y = rowHeight * index;
|
|
969
|
+
if (y + rowHeight >= minY && y <= maxY) {
|
|
970
|
+
visibleRowIds.push(rowId);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
return visibleRowIds;
|
|
974
|
+
};
|
|
975
|
+
TimeGraphChart.prototype.ensureVisible = function (rowIndex, center) {
|
|
976
|
+
if (rowIndex === -1) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
if (rowIndex * this.rowController.rowHeight < this.rowController.verticalOffset) {
|
|
980
|
+
center ? this.centerRow(rowIndex) : this.rowController.verticalOffset = rowIndex * this.rowController.rowHeight;
|
|
981
|
+
}
|
|
982
|
+
else if ((rowIndex + 1) * this.rowController.rowHeight > this.rowController.verticalOffset + this.stateController.canvasDisplayHeight) {
|
|
983
|
+
center ? this.centerRow(rowIndex) : this.rowController.verticalOffset = (rowIndex + 1) * this.rowController.rowHeight - this.stateController.canvasDisplayHeight;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
TimeGraphChart.prototype.centerRow = function (rowIndex) {
|
|
987
|
+
if (rowIndex === -1) {
|
|
988
|
+
return;
|
|
989
|
+
}
|
|
990
|
+
var rowHeight = this.rowController.rowHeight;
|
|
991
|
+
var canvasDisplayHeight = this.stateController.canvasDisplayHeight;
|
|
992
|
+
var numberOfVisibleRows = Math.floor(canvasDisplayHeight / rowHeight);
|
|
993
|
+
var halfVizRows = Math.floor(numberOfVisibleRows / 2);
|
|
994
|
+
var numberOfRows = this.rowComponents.size;
|
|
995
|
+
if (rowIndex < halfVizRows) {
|
|
996
|
+
// Index too low to center.
|
|
997
|
+
this.rowController.verticalOffset = 0;
|
|
998
|
+
}
|
|
999
|
+
else if (rowIndex > (numberOfRows - halfVizRows - 1)) {
|
|
1000
|
+
// Index too high to center.
|
|
1001
|
+
this.rowController.verticalOffset = (numberOfRows - numberOfVisibleRows) * rowHeight;
|
|
1002
|
+
}
|
|
1003
|
+
else {
|
|
1004
|
+
// Can be centered.
|
|
1005
|
+
var numberOfHiddenRows = rowIndex - halfVizRows;
|
|
1006
|
+
this.rowController.verticalOffset = numberOfHiddenRows * rowHeight;
|
|
1007
|
+
}
|
|
1008
|
+
};
|
|
1009
|
+
TimeGraphChart.prototype.scaleComponents = function () {
|
|
1010
|
+
var _this = this;
|
|
1011
|
+
this.rowComponents.forEach(function (rowComponent) {
|
|
1012
|
+
var row = rowComponent.model;
|
|
1013
|
+
row === null || row === void 0 ? void 0 : row.states.forEach(function (state) {
|
|
1014
|
+
var el = rowComponent.getStateById(state.id);
|
|
1015
|
+
if (el) {
|
|
1016
|
+
el.scaleLabel(_this.stateController.scaleFactor);
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
row === null || row === void 0 ? void 0 : row.annotations.forEach(function (annotation) {
|
|
1020
|
+
var el = rowComponent.getAnnotationById(annotation.id);
|
|
1021
|
+
if (el) {
|
|
1022
|
+
el.scaleAnnotation(_this.stateController.scaleFactor);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
});
|
|
1026
|
+
};
|
|
1027
|
+
Object.defineProperty(TimeGraphChart.prototype, "rowWidth", {
|
|
1028
|
+
get: function () {
|
|
1029
|
+
return Number(this.stateController.worldRangeLength) * this.stateController.zoomFactor;
|
|
1030
|
+
},
|
|
1031
|
+
enumerable: false,
|
|
1032
|
+
configurable: true
|
|
1033
|
+
});
|
|
771
1034
|
return TimeGraphChart;
|
|
772
1035
|
}(time_graph_chart_layer_1.TimeGraphChartLayer));
|
|
773
1036
|
exports.TimeGraphChart = TimeGraphChart;
|