ngx-vis 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2053 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { EventEmitter, Injectable, Output, Input, Directive, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
4
- export { DataSet } from 'vis-data';
5
- import { Network } from 'vis-network';
6
- import { Timeline } from 'vis-timeline';
7
-
8
- /**
9
- * A service to create, manage and control Network instances.
10
- *
11
- * @export
12
- * @class NetworkService
13
- */
14
- class VisNetworkService {
15
- /**
16
- * Fired when the user clicks the mouse or taps on a touchscreen device.
17
- *
18
- * @type {EventEmitter<any>}
19
- * @memberOf NetworkService
20
- */
21
- click = new EventEmitter();
22
- /**
23
- * Fired when the user double clicks the mouse or double taps on a touchscreen device.
24
- * Since a double click is in fact 2 clicks, 2 click events are fired, followed by a double click event.
25
- * If you do not want to use the click events if a double click event is fired,
26
- * just check the time between click events before processing them.
27
- *
28
- * @type {EventEmitter<any>}
29
- * @memberOf NetworkService
30
- */
31
- doubleClick = new EventEmitter();
32
- /**
33
- * Fired when the user click on the canvas with the right mouse button.
34
- * The right mouse button does not select by default.
35
- * You can use the method getNodeAt to select the node if you want.
36
- *
37
- * @type {EventEmitter<any>}
38
- * @memberOf NetworkService
39
- */
40
- oncontext = new EventEmitter();
41
- /**
42
- * Fired when the user clicks and holds the mouse or taps and holds on a touchscreen device.
43
- * A click event is also fired in this case.
44
- *
45
- * @type {EventEmitter<any>}
46
- * @memberOf NetworkService
47
- */
48
- hold = new EventEmitter();
49
- /**
50
- * Fired after drawing on the canvas has been completed.
51
- * Can be used to draw on top of the network.
52
- *
53
- * @type {EventEmitter<any>}
54
- * @memberOf NetworkService
55
- */
56
- release = new EventEmitter();
57
- /**
58
- * Fired when the selection has changed by user action.
59
- * This means a node or edge has been selected, added to the selection or deselected.
60
- * All select events are only triggered on click and hold.
61
- *
62
- * @type {EventEmitter<any>}
63
- * @memberOf NetworkService
64
- */
65
- select = new EventEmitter();
66
- /**
67
- * Fired when a node has been selected by the user.
68
- *
69
- * @type {EventEmitter<any>}
70
- * @memberOf NetworkService
71
- */
72
- selectNode = new EventEmitter();
73
- /**
74
- * Fired when a edge has been selected by the user.
75
- *
76
- * @type {EventEmitter<any>}
77
- * @memberOf NetworkService
78
- */
79
- selectEdge = new EventEmitter();
80
- /**
81
- * Fired when a node (or nodes) has (or have) been deselected by the user.
82
- * The previous selection is the list of nodes and edges that were selected before the last user event.
83
- *
84
- * @type {EventEmitter<any>}
85
- * @memberOf NetworkService
86
- */
87
- deselectNode = new EventEmitter();
88
- /**
89
- * Fired when a edge (or edges) has (or have) been deselected by the user.
90
- * The previous selection is the list of nodes and edges that were selected before the last user event.
91
- *
92
- * @type {EventEmitter<any>}
93
- * @memberOf NetworkService
94
- */
95
- deselectEdge = new EventEmitter();
96
- /**
97
- * Fired when starting a drag.
98
- *
99
- * @type {EventEmitter<any>}
100
- * @memberOf NetworkService
101
- */
102
- dragStart = new EventEmitter();
103
- /**
104
- * Fired when dragging node(s) or the view.
105
- *
106
- * @type {EventEmitter<any>}
107
- * @memberOf NetworkService
108
- */
109
- dragging = new EventEmitter();
110
- /**
111
- * Fired when the drag has finished.
112
- *
113
- * @type {EventEmitter<any>}
114
- * @memberOf NetworkService
115
- */
116
- dragEnd = new EventEmitter();
117
- /**
118
- * Fired if the option interaction:{hover:true} is enabled and the mouse hovers over a node.
119
- *
120
- * @type {EventEmitter<any>}
121
- * @memberOf NetworkService
122
- */
123
- hoverNode = new EventEmitter();
124
- /**
125
- * Fired if the option interaction:{hover:true} is enabled and
126
- * the mouse moved away from a node it was hovering over before.
127
- *
128
- * @type {EventEmitter<any>}
129
- * @memberOf NetworkService
130
- */
131
- blurNode = new EventEmitter();
132
- /**
133
- * Fired if the option interaction:{hover:true} is enabled and the mouse hovers over an edge.
134
- *
135
- * @type {EventEmitter<any>}
136
- * @memberOf NetworkService
137
- */
138
- hoverEdge = new EventEmitter();
139
- /**
140
- * Fired if the option interaction:{hover:true} is enabled and
141
- * the mouse moved away from an edge it was hovering over before.
142
- *
143
- * @type {EventEmitter<any>}
144
- * @memberOf NetworkService
145
- */
146
- blurEdge = new EventEmitter();
147
- /**
148
- * Fired when the user zooms in or out.
149
- *
150
- * @type {EventEmitter<any>}
151
- * @memberOf NetworkService
152
- */
153
- zoom = new EventEmitter();
154
- /**
155
- * Fired when the popup (tooltip) is shown.
156
- *
157
- * @type {EventEmitter<any>}
158
- * @memberOf NetworkService
159
- */
160
- showPopup = new EventEmitter();
161
- /**
162
- * Fired when the popup (tooltip) is hidden.
163
- *
164
- * @type {EventEmitter<any>}
165
- * @memberOf NetworkService
166
- */
167
- hidePopup = new EventEmitter();
168
- /**
169
- * Fired when stabilization starts.
170
- * This is also the case when you drag a node and the physics
171
- * simulation restarts to stabilize again.
172
- * Stabilization does not neccesarily imply 'without showing'.
173
- *
174
- * @type {EventEmitter<any>}
175
- * @memberOf NetworkService
176
- */
177
- startStabilizing = new EventEmitter();
178
- /**
179
- * Fired when a multiple of the updateInterval number of iterations is reached.
180
- * This only occurs in the 'hidden' stabilization.
181
- *
182
- * @type {EventEmitter<any>}
183
- * @memberOf NetworkService
184
- */
185
- stabilizationProgress = new EventEmitter();
186
- /**
187
- * Fired when the 'hidden' stabilization finishes.
188
- * This does not necessarily mean the network is stabilized;
189
- * it could also mean that the amount of iterations defined in the options has been reached.
190
- *
191
- * @type {EventEmitter<any>}
192
- * @memberOf NetworkService
193
- */
194
- stabilizationIterationsDone = new EventEmitter();
195
- /**
196
- * Fired when the 'hidden' stabilization finishes.
197
- * This does not necessarily mean the network is stabilized;
198
- * it could also mean that the amount of iterations defined in the options has been reached.
199
- *
200
- * @type {EventEmitter<any>}
201
- * @memberOf NetworkService
202
- */
203
- stabilized = new EventEmitter();
204
- /**
205
- * Fired when the size of the canvas has been resized,
206
- * either by a redraw call when the container div has changed in size,
207
- * a setSize() call with new values or a setOptions() with new width and/or height values.
208
- *
209
- * @type {EventEmitter<any>}
210
- * @memberOf NetworkService
211
- */
212
- resize = new EventEmitter();
213
- /**
214
- * Fired before the redrawing begins.
215
- * The simulation step has completed at this point.
216
- * Can be used to move custom elements before starting drawing the new frame.
217
- *
218
- * @type {EventEmitter<any>}
219
- * @memberOf NetworkService
220
- */
221
- initRedraw = new EventEmitter();
222
- /**
223
- * Fired after the canvas has been cleared, scaled and translated to
224
- * the viewing position but before all edges and nodes are drawn.
225
- * Can be used to draw behind the network.
226
- *
227
- * @type {EventEmitter<any>}
228
- * @memberOf NetworkService
229
- */
230
- beforeDrawing = new EventEmitter();
231
- /**
232
- * Fired after drawing on the canvas has been completed.
233
- * Can be used to draw on top of the network.
234
- *
235
- * @type {EventEmitter<any>}
236
- * @memberOf NetworkService
237
- */
238
- afterDrawing = new EventEmitter();
239
- /**
240
- * Fired when an animation is finished.
241
- *
242
- * @type {EventEmitter<any>}
243
- * @memberOf NetworkService
244
- */
245
- animationFinished = new EventEmitter();
246
- /**
247
- * Fired when a user changes any option in the configurator.
248
- * The options object can be used with the setOptions method or stringified using JSON.stringify().
249
- * You do not have to manually put the options into the network: this is done automatically.
250
- * You can use the event to store user options in the database.
251
- *
252
- * @type {EventEmitter<any>}
253
- * @memberOf NetworkService
254
- */
255
- configChange = new EventEmitter();
256
- networks = {};
257
- /**
258
- * Creates a new network instance.
259
- *
260
- * @param {string} visNetwork The network name/identifier.
261
- * @param {HTMLElement} container The HTML element that contains the network view.
262
- * @param {Data} data The initial network nodes and edges.
263
- * @param {Options} [options] The network options.
264
- *
265
- * @throws {Error} Thrown when a network with the same name already exists.
266
- *
267
- * @memberOf NetworkService
268
- */
269
- create(visNetwork, container, data, options) {
270
- if (this.networks[visNetwork]) {
271
- throw new Error(`Network with id ${visNetwork} already exists.`);
272
- }
273
- this.networks[visNetwork] = new Network(container, data, options);
274
- }
275
- /**
276
- * Remove the network from the DOM and remove all Hammer bindings and references.
277
- *
278
- * @param {string} visNetwork The network name/identifier.
279
- *
280
- * @memberOf NetworkService
281
- */
282
- destroy(visNetwork) {
283
- if (this.networks[visNetwork]) {
284
- this.networks[visNetwork].destroy();
285
- delete this.networks[visNetwork];
286
- }
287
- }
288
- /**
289
- * Activates an event.
290
- *
291
- * @param {string} visNetwork The network name/identifier.
292
- * @param {NetworkEvents} eventName The event name.
293
- * @param {boolean} preventDefault Stops the default behavior of the event.
294
- * @returns {boolean} Returns true when the event was activated.
295
- *
296
- * @memberOf NetworkService
297
- */
298
- on(visNetwork, eventName, preventDefault) {
299
- if (this.networks[visNetwork]) {
300
- /* tslint:disable */
301
- const that = this;
302
- /* tslint:enable */
303
- this.networks[visNetwork].on(eventName, (params) => {
304
- const emitter = that[eventName];
305
- if (emitter) {
306
- emitter.emit(params ? [visNetwork].concat(params) : visNetwork);
307
- }
308
- if (preventDefault && params.event) {
309
- params.event.preventDefault();
310
- }
311
- });
312
- return true;
313
- }
314
- return false;
315
- }
316
- /**
317
- * Deactivates an event.
318
- *
319
- * @param {string} visNetwork The network name/identifier.
320
- * @param {NetworkEvents} eventName The event name.
321
- *
322
- * @memberOf NetworkService
323
- */
324
- off(visNetwork, eventName) {
325
- if (this.networks[visNetwork]) {
326
- this.networks[visNetwork].off(eventName);
327
- }
328
- }
329
- /**
330
- * Activates an event listener only once.
331
- * After it has taken place, the event listener will be removed.
332
- *
333
- * @param {string} visNetwork The network name/identifier.
334
- * @param {NetworkEvents} eventName The event name.
335
- * @returns {boolean} Returns true when the event was activated.
336
- *
337
- * @memberOf NetworkService
338
- */
339
- once(visNetwork, eventName) {
340
- if (this.networks[visNetwork]) {
341
- /* tslint:disable */
342
- const that = this;
343
- /* tslint:disable */
344
- this.networks[visNetwork].on(eventName, (params) => {
345
- const emitter = that[eventName];
346
- if (emitter) {
347
- emitter.emit(params ? [visNetwork].concat(params) : visNetwork);
348
- this.off(visNetwork, eventName);
349
- }
350
- });
351
- return true;
352
- }
353
- return false;
354
- }
355
- /**
356
- * Override all the data in the network.
357
- * If stabilization is enabled in the physics module,
358
- * the network will stabilize again.
359
- * This method is also performed when first initializing the network.
360
- *
361
- * @param {string} visNetwork The network name/identifier.
362
- * @param {Data} data The network data.
363
- *
364
- * @throws {Error} Thrown when the network does not exist.
365
- *
366
- * @memberOf NetworkService
367
- */
368
- setData(visNetwork, data) {
369
- if (this.networks[visNetwork]) {
370
- this.networks[visNetwork].setData(data);
371
- }
372
- else {
373
- throw new Error(`Network with id ${visNetwork} not found.`);
374
- }
375
- }
376
- /**
377
- * Set the options.
378
- *
379
- * @param {string} visNetwork The network name/identifier.
380
- * @param {Options} options The network options.
381
- *
382
- * @throws {Error} Thrown when the network does not exist.
383
- *
384
- * @memberOf NetworkService
385
- */
386
- setOptions(visNetwork, options) {
387
- if (this.networks[visNetwork]) {
388
- this.networks[visNetwork].setOptions(options);
389
- }
390
- else {
391
- throw new Error(`Network with id ${visNetwork} not found.`);
392
- }
393
- }
394
- /**
395
- * Selects the nodes corresponding to the id's in the input array.
396
- * This method unselects all other objects before selecting its own objects.
397
- * Does not fire events.
398
- *
399
- * @param {string} visNetwork The network name/identifier.
400
- * @param {IdType[]} nodeIds The node ids that should be selected.
401
- * @param {boolean} [highlightEdges] If highlightEdges is true or undefined,
402
- * the neighbouring edges will also be selected.
403
- *
404
- * @throws {Error} Thrown when the network does not exist.
405
- *
406
- * @memberOf NetworkService
407
- */
408
- selectNodes(visNetwork, nodeIds, highlightEdges) {
409
- if (this.networks[visNetwork]) {
410
- this.networks[visNetwork].selectNodes(nodeIds, highlightEdges);
411
- }
412
- else {
413
- throw new Error(`Network with id ${visNetwork} not found.`);
414
- }
415
- }
416
- /**
417
- * Selects the nodes and edges corresponding to the id's in the input arrays.
418
- * Does not fire events.
419
- *
420
- * @param {string} visNetwork The network name/identifier.
421
- * @param { nodes: IdType[], edges: IdType[] } selection The node and edge ids that should be selected.
422
- * @param { unselectAll?: boolean, highlightEdges?: boolean } [options]
423
- * If unselectAll is true or undefined, the other objects will be deselected.
424
- * If highlightEdges is true or undefined, the neighbouring edges will also be selected.
425
- *
426
- * @throws {Error} Thrown when the network does not exist.
427
- *
428
- * @memberOf NetworkService
429
- */
430
- setSelection(visNetwork, selection, options = {}) {
431
- if (this.networks[visNetwork]) {
432
- this.networks[visNetwork].setSelection(selection, options);
433
- }
434
- else {
435
- throw new Error(`Network with id ${visNetwork} not found.`);
436
- }
437
- }
438
- /**
439
- * Returns an object with selected nodes and edges ids.
440
- *
441
- * @param {string} visNetwork The network name/identifier.
442
- * @returns {{ nodes: IdType[], edges: IdType[] }}
443
- * The selected node and edge ids or undefined when the network does not exist.
444
- *
445
- * @memberOf NetworkService
446
- */
447
- getSelection(visNetwork) {
448
- if (this.networks[visNetwork]) {
449
- return this.networks[visNetwork].getSelection();
450
- }
451
- return undefined;
452
- }
453
- /**
454
- * Returns an array of selected node ids.
455
- *
456
- * @param {string} visNetwork The network name/identifier.
457
- * @returns {IdType[]} The selected node ids or undefined when the network does not exist.
458
- *
459
- * @memberOf NetworkService
460
- */
461
- getSelectedNodes(visNetwork) {
462
- if (this.networks[visNetwork]) {
463
- return this.networks[visNetwork].getSelectedNodes();
464
- }
465
- return undefined;
466
- }
467
- /**
468
- * Returns an array of selected edge ids.
469
- *
470
- * @param {string} visNetwork The network name/identifier.
471
- * @returns {IdType[]} The selected edge ids or undefined when the network does not exist.
472
- *
473
- * @memberOf NetworkService
474
- */
475
- getSelectedEdges(visNetwork) {
476
- if (this.networks[visNetwork]) {
477
- return this.networks[visNetwork].getSelectedEdges();
478
- }
479
- return undefined;
480
- }
481
- /**
482
- * Unselect all objects.
483
- * Does not fire events.
484
- *
485
- * @param {string} visNetwork The network name/identifier.
486
- *
487
- * @throws {Error} Thrown when the network does not exist.
488
- *
489
- * @memberOf NetworkService
490
- */
491
- unselectAll(visNetwork) {
492
- if (this.networks[visNetwork]) {
493
- this.networks[visNetwork].unselectAll();
494
- }
495
- else {
496
- throw new Error(`Network with id ${visNetwork} not found.`);
497
- }
498
- }
499
- /**
500
- * Zooms out so all nodes fit on the canvas.
501
- *
502
- * @param {string} visNetwork The network name/identifier.
503
- * @param {VisFitOptions} [options] Options to customize.
504
- *
505
- * @throws {Error} Thrown when the network does not exist.
506
- *
507
- * @memberOf NetworkService
508
- */
509
- fit(visNetwork, options) {
510
- if (this.networks[visNetwork]) {
511
- this.networks[visNetwork].fit(options);
512
- }
513
- else {
514
- throw new Error(`Network with id ${visNetwork} not found.`);
515
- }
516
- }
517
- /**
518
- * Redraw the network.
519
- *
520
- * @param {string} visNetwork The network name/identifier.
521
- *
522
- * @throws {Error} Thrown when the network does not exist.
523
- *
524
- * @memberOf NetworkService
525
- */
526
- redraw(visNetwork) {
527
- if (this.networks[visNetwork]) {
528
- this.networks[visNetwork].redraw();
529
- }
530
- else {
531
- throw new Error(`Network with id ${visNetwork} not found.`);
532
- }
533
- }
534
- /**
535
- * Go into addNode mode. Having edit mode or manipulation enabled is not required.
536
- * To get out of this mode, call disableEditMode(). The callback functions defined in handlerFunctions still apply.
537
- * To use these methods without having the manipulation GUI, make sure you set enabled to false.
538
- *
539
- * @param {string} visNetwork The network name/identifier.
540
- *
541
- * @throws {Error} Thrown when the network does not exist.
542
- *
543
- * @memberOf NetworkService
544
- */
545
- addNodeMode(visNetwork) {
546
- if (this.networks[visNetwork]) {
547
- this.networks[visNetwork].addNodeMode();
548
- }
549
- else {
550
- throw new Error(`Network with id ${visNetwork} not found.`);
551
- }
552
- }
553
- /**
554
- * Programatically enable the edit mode.
555
- * Similar effect to pressing the edit button.
556
- *
557
- * @param {string} visNetwork The network name/identifier.
558
- *
559
- * @throws {Error} Thrown when the network does not exist.
560
- *
561
- * @memberOf NetworkService
562
- */
563
- enableEditMode(visNetwork) {
564
- if (this.networks[visNetwork]) {
565
- this.networks[visNetwork].enableEditMode();
566
- }
567
- else {
568
- throw new Error(`Network with id ${visNetwork} not found.`);
569
- }
570
- }
571
- /**
572
- * Go into addEdge mode.
573
- * The explaination from addNodeMode applies here as well.
574
- *
575
- * @param {string} visNetwork The network name/identifier.
576
- *
577
- * @throws {Error} Thrown when the network does not exist.
578
- *
579
- * @memberOf NetworkService
580
- */
581
- addEdgeMode(visNetwork) {
582
- if (this.networks[visNetwork]) {
583
- this.networks[visNetwork].addEdgeMode();
584
- }
585
- else {
586
- throw new Error(`Network with id ${visNetwork} not found.`);
587
- }
588
- }
589
- /**
590
- * Programatically disable the edit mode.
591
- * Similar effect to pressing the close icon
592
- * (small cross in the corner of the toolbar).
593
- *
594
- * @param {string} visNetwork The network name/identifier.
595
- *
596
- * @throws {Error} Thrown when the network does not exist.
597
- *
598
- * @memberOf NetworkService
599
- */
600
- disableEditMode(visNetwork) {
601
- if (this.networks[visNetwork]) {
602
- this.networks[visNetwork].disableEditMode();
603
- }
604
- else {
605
- throw new Error(`Network with id ${visNetwork} not found.`);
606
- }
607
- }
608
- /**
609
- * Delete selected.
610
- * Having edit mode or manipulation enabled is not required.
611
- *
612
- * @param {string} visNetwork The network name/identifier.
613
- *
614
- * @throws {Error} Thrown when the network does not exist.
615
- *
616
- * @memberOf NetworkService
617
- */
618
- deleteSelected(visNetwork) {
619
- if (this.networks[visNetwork]) {
620
- this.networks[visNetwork].deleteSelected();
621
- }
622
- else {
623
- throw new Error(`Network with id ${visNetwork} not found.`);
624
- }
625
- }
626
- /**
627
- * Makes a cluster.
628
- *
629
- * @param {string} visNetwork The network name/identifier.
630
- * @param {ClusterOptions} [options] The joinCondition function is presented with all nodes.
631
- *
632
- * @throws {Error} Thrown when the network does not exist.
633
- *
634
- * @memberOf NetworkService
635
- */
636
- cluster(visNetwork, options) {
637
- if (this.networks[visNetwork]) {
638
- this.networks[visNetwork].cluster(options);
639
- }
640
- else {
641
- throw new Error(`Network with id ${visNetwork} not found.`);
642
- }
643
- }
644
- /**
645
- * This method looks at the provided node and makes a cluster of it and all it's connected nodes.
646
- * The behaviour can be customized by proving the options object.
647
- * All options of this object are explained below.
648
- * The joinCondition is only presented with the connected nodes.
649
- *
650
- * @param {string} visNetwork The network name/identifier.
651
- * @param {IdType} nodeId the id of the node
652
- * @param {ClusterOptions} [options] the cluster options
653
- *
654
- * @memberOf NetworkService
655
- */
656
- clusterByConnection(visNetwork, nodeId, options) {
657
- if (this.networks[visNetwork]) {
658
- this.networks[visNetwork].clusterByConnection(nodeId, options);
659
- }
660
- else {
661
- throw new Error(`Network with id ${visNetwork} not found.`);
662
- }
663
- }
664
- /**
665
- * This method checks all nodes in the network and those with a equal or higher
666
- * amount of edges than specified with the hubsize qualify.
667
- * If a hubsize is not defined, the hubsize will be determined as the average
668
- * value plus two standard deviations.
669
- * For all qualifying nodes, clusterByConnection is performed on each of them.
670
- * The options object is described for clusterByConnection and does the same here.
671
- *
672
- * @param {string} visNetwork The network name/identifier.
673
- * @param {number} [hubsize] optional hubsize
674
- * @param {ClusterOptions} [options] optional cluster options
675
- *
676
- * @memberOf NetworkService
677
- */
678
- clusterByHubsize(visNetwork, hubsize, options) {
679
- if (this.networks[visNetwork]) {
680
- this.networks[visNetwork].clusterByHubsize(hubsize, options);
681
- }
682
- else {
683
- throw new Error(`Network with id ${visNetwork} not found.`);
684
- }
685
- }
686
- /**
687
- * This method will cluster all nodes with 1 edge with their respective connected node.
688
- *
689
- * @param {string} visNetwork The network name/identifier.
690
- * @param {ClusterOptions} [options] optional cluster options
691
- *
692
- * @memberOf NetworkService
693
- */
694
- clusterOutliers(visNetwork, options) {
695
- if (this.networks[visNetwork]) {
696
- this.networks[visNetwork].clusterOutliers(options);
697
- }
698
- else {
699
- throw new Error(`Network with id ${visNetwork} not found.`);
700
- }
701
- }
702
- /**
703
- * Nodes can be in clusters.
704
- * Clusters can also be in clusters.
705
- * This function returns an array of nodeIds showing where the node is.
706
- *
707
- * Example:
708
- * cluster 'A' contains cluster 'B', cluster 'B' contains cluster 'C',
709
- * cluster 'C' contains node 'fred'.
710
- *
711
- * network.clustering.findNode('fred') will return ['A','B','C','fred'].
712
- *
713
- * @param {string} visNetwork The network name/identifier.
714
- * @param {IdType} nodeId the node id.
715
- * @returns {IdType[]} an array of nodeIds showing where the node is
716
- *
717
- * @memberOf NetworkService
718
- */
719
- findNode(visNetwork, nodeId) {
720
- if (this.networks[visNetwork]) {
721
- return this.networks[visNetwork].findNode(nodeId);
722
- }
723
- else {
724
- throw new Error(`Network with id ${visNetwork} not found.`);
725
- }
726
- }
727
- /**
728
- * Similar to findNode in that it returns all the edge ids that were
729
- * created from the provided edge during clustering.
730
- *
731
- * @param {string} visNetwork The network name/identifier.
732
- * @param {IdType} baseEdgeId the base edge id
733
- * @returns {IdType[]} an array of edgeIds
734
- *
735
- * @memberOf NetworkService
736
- */
737
- getClusteredEdges(visNetwork, baseEdgeId) {
738
- if (this.networks[visNetwork]) {
739
- return this.networks[visNetwork].getClusteredEdges(baseEdgeId);
740
- }
741
- else {
742
- throw new Error(`Network with id ${visNetwork} not found.`);
743
- }
744
- }
745
- /**
746
- * When a clusteredEdgeId is available, this method will return the original
747
- * baseEdgeId provided in data.edges ie.
748
- * After clustering the 'SelectEdge' event is fired but provides only the clustered edge.
749
- * This method can then be used to return the baseEdgeId.
750
- *
751
- * @param {string} visNetwork The network name/identifier.
752
- * @param {IdType} clusteredEdgeId
753
- * @returns {IdType}
754
- *
755
- * @memberOf NetworkService
756
- *
757
- */
758
- getBaseEdge(visNetwork, clusteredEdgeId) {
759
- if (this.networks[visNetwork]) {
760
- return this.networks[visNetwork].getBaseEdge(clusteredEdgeId);
761
- }
762
- else {
763
- throw new Error(`Network with id ${visNetwork} not found.`);
764
- }
765
- }
766
- /**
767
- * Visible edges between clustered nodes are not the same edge as the ones provided
768
- * in data.edges passed on network creation. With each layer of clustering, copies of
769
- * the edges between clusters are created and the previous edges are hidden,
770
- * until the cluster is opened. This method takes an edgeId (ie. a base edgeId from data.edges)
771
- * and applys the options to it and any edges that were created from it while clustering.
772
- *
773
- * @param {string} visNetwork The network name/identifier.
774
- * @param {IdType} startEdgeId
775
- * @param {VisEdgeOptions} [options]
776
- *
777
- * @memberOf NetworkService
778
- *
779
- */
780
- updateEdge(visNetwork, startEdgeId, options) {
781
- if (this.networks[visNetwork]) {
782
- this.networks[visNetwork].updateEdge(startEdgeId, options);
783
- }
784
- else {
785
- throw new Error(`Network with id ${visNetwork} not found.`);
786
- }
787
- }
788
- /**
789
- * Clustered Nodes when created are not contained in the original data.nodes
790
- * passed on network creation. This method updates the cluster node.
791
- *
792
- * @param {string} visNetwork The network name/identifier.
793
- * @param {IdType} clusteredNodeId
794
- * @param {NodeOptions} options
795
- *
796
- * @memberOf NetworkService
797
- */
798
- updateClusteredNode(visNetwork, clusteredNodeId, options) {
799
- if (this.networks[visNetwork]) {
800
- this.networks[visNetwork].updateClusteredNode(clusteredNodeId, options);
801
- }
802
- else {
803
- throw new Error(`Network with id ${visNetwork} not found.`);
804
- }
805
- }
806
- /**
807
- * Returns an array of all nodeIds of the nodes that
808
- * would be released if you open the cluster.
809
- *
810
- * @param {string} visNetwork The network name/identifier.
811
- * @param {IdType} clusterNodeId the id of the cluster node
812
- * @returns {IdType[]}
813
- *
814
- * @memberOf NetworkService
815
- */
816
- getNodesInCluster(visNetwork, clusterNodeId) {
817
- if (this.networks[visNetwork]) {
818
- return this.networks[visNetwork].getNodesInCluster(clusterNodeId);
819
- }
820
- else {
821
- throw new Error(`Network with id ${visNetwork} not found.`);
822
- }
823
- }
824
- /**
825
- * Opens the cluster, releases the contained nodes and edges,
826
- * removing the cluster node and cluster edges.
827
- *
828
- * @param {string} visNetwork The network name/identifier.
829
- * @param {IdType} nodeId The node id that represents the cluster.
830
- * @param {OpenClusterOptions} [options] Cluster options.
831
- *
832
- * @throws {Error} Thrown when the network does not exist.
833
- *
834
- * @memberOf NetworkService
835
- */
836
- openCluster(visNetwork, nodeId, options) {
837
- if (this.networks[visNetwork]) {
838
- this.networks[visNetwork].openCluster(nodeId, options);
839
- }
840
- else {
841
- throw new Error(`Network with id ${visNetwork} not found.`);
842
- }
843
- }
844
- /**
845
- * Returns true if the node whose ID has been supplied is a cluster.
846
- *
847
- * @param {string} visNetwork The network name/identifier.
848
- * @param {IdType} nodeId The associated node id.
849
- * @returns {boolean} True if the node whose ID has been supplied is a cluster.
850
- *
851
- * @memberOf NetworkService
852
- */
853
- isCluster(visNetwork, nodeId) {
854
- if (this.networks[visNetwork]) {
855
- return this.networks[visNetwork].isCluster(nodeId);
856
- }
857
- return false;
858
- }
859
- /**
860
- * If you like the layout of your network and would like it to start in the same way next time,
861
- * ask for the seed using this method and put it in the layout.randomSeed option.
862
- *
863
- * @param {string} visNetwork The network name/identifier.
864
- * @returns {number} The seed of the current network or -1 when the network is not defined.
865
- *
866
- * @memberOf NetworkService
867
- */
868
- getSeed(visNetwork) {
869
- if (this.networks[visNetwork]) {
870
- return this.networks[visNetwork].getSeed();
871
- }
872
- return -1;
873
- }
874
- /**
875
- * This function converts canvas coordinates to coordinates on the DOM.
876
- * Input and output are in the form of {x:Number,y:Number}.
877
- * The DOM values are relative to the network container.
878
- *
879
- * @param {string} visNetwork The network name/identifier.
880
- * @param {Position} position The canvas position.
881
- * @returns {Position} The DOM position.
882
- *
883
- * @memberOf NetworkService
884
- */
885
- canvasToDOM(visNetwork, position) {
886
- return this.networks[visNetwork].canvasToDOM(position);
887
- }
888
- /**
889
- * This function converts DOM coordinates to coordinates on the canvas.
890
- * Input and output are in the form of {x:Number,y:Number}.
891
- * The DOM values are relative to the network container.
892
- *
893
- * @param {string} visNetwork The network name/identifier.
894
- * @param {Position} position The DOM position.
895
- * @returns {Position} The canvas position.
896
- *
897
- * @memberOf NetworkService
898
- */
899
- DOMtoCanvas(visNetwork, position) {
900
- return this.networks[visNetwork].DOMtoCanvas(position);
901
- }
902
- /**
903
- * This function looks up the node at the given DOM coordinates on the canvas.
904
- * Input and output are in the form of {x:Number,y:Number}.
905
- * The DOM values are relative to the network container -> DOM not Canvas coords.
906
- *
907
- * @param {string} visNetwork The network name/identifier.
908
- * @param {Position} position The DOM position.
909
- * @returns {IdType} nodeId The associated node id.
910
- *
911
- * @memberOf NetworkService
912
- */
913
- getNodeAt(visNetwork, position) {
914
- return this.networks[visNetwork].getNodeAt(position);
915
- }
916
- /**
917
- * This function looks up the edge at the given DOM coordinates on the canvas.
918
- * Input and output are in the form of {x:Number,y:Number}.
919
- * The DOM values are relative to the network container -> DOM not Canvas coords.
920
- *
921
- * @param {string} visNetwork The network name/identifier.
922
- * @param {Position} position The DOM position.
923
- * @returns {IdType} edgeId The associated edge id.
924
- *
925
- * @memberOf NetworkService
926
- */
927
- getEdgeAt(visNetwork, position) {
928
- return this.networks[visNetwork].getEdgeAt(position);
929
- }
930
- /**
931
- * This function looks up the edges for a given nodeId.
932
- * The DOM values are relative to the network container -> DOM not Canvas coords.
933
- *
934
- * @param {string} visNetwork The network name/identifier.
935
- * @param {IdType} nodeId The associated node id.
936
- * @returns {IdType[]} Return array of edge ids
937
- *
938
- * @memberOf NetworkService
939
- */
940
- getConnectedEdges(visNetwork, nodeId) {
941
- return this.networks[visNetwork].getConnectedEdges(nodeId);
942
- }
943
- /**
944
- * Returns an array of nodeIds of the all the nodes that are directly connected to this node.
945
- * If you supply an edgeId, vis will first match the id to nodes.
946
- * If no match is found, it will search in the edgelist and return an array: [fromId, toId].
947
- *
948
- * @param {string} visNetwork The network name/identifier.
949
- * @param nodeOrEdgeId a node or edge id
950
- * @returns {IdType[]} Return array of node ids
951
- */
952
- getConnectedNodes(visNetwork, nodeOrEdgeId) {
953
- return this.networks[visNetwork].getConnectedNodes(nodeOrEdgeId);
954
- }
955
- /**
956
- * Returns the positions of the nodes.
957
- * @param {string} visNetwork The network name/identifier.
958
- * @param {Array.<Node.id>|String} [ids] --> optional, can be array of nodeIds, can be string
959
- * @returns {{}}
960
- */
961
- getPositions(visNetwork, nodeIds) {
962
- return this.networks[visNetwork].getPositions(nodeIds);
963
- }
964
- /**
965
- * Returns the positions of the nodes.
966
- * @param {string} visNetwork The network name/identifier.
967
- */
968
- getBoundingBox(visNetwork, nodeId) {
969
- return this.networks[visNetwork].getBoundingBox(nodeId);
970
- }
971
- /**
972
- * Returns the positions of the nodes.
973
- * @param {string} visNetwork The network name/identifier.
974
- */
975
- storePositions(visNetwork) {
976
- return this.networks[visNetwork].storePositions();
977
- }
978
- /**
979
- * You can animate or move the camera using the moveTo method.
980
- *
981
- * @param {string} visNetwork The network name/identifier.
982
- * @param {MoveToOptions} options Options for moveTo function.
983
- */
984
- moveTo(visNetwork, moveToOptions) {
985
- return this.networks[visNetwork].moveTo(moveToOptions);
986
- }
987
- /**
988
- * Start the physics simulation.
989
- * This is normally done whenever needed and is only really useful
990
- * if you stop the simulation yourself and wish to continue it afterwards.
991
- * @param {string} visNetwork The network name/identifier.
992
- */
993
- startSimulation(visNetwork) {
994
- return this.networks[visNetwork].startSimulation();
995
- }
996
- /**
997
- * This stops the physics simulation and triggers a stabilized event.
998
- * Tt can be restarted by dragging a node,
999
- * altering the dataset or calling startSimulation().
1000
- * @param {string} visNetwork The network name/identifier.
1001
- */
1002
- stopSimulation(visNetwork) {
1003
- return this.networks[visNetwork].stopSimulation();
1004
- }
1005
- /**
1006
- * Returns the current scale of the network. 1.0 is comparible to 100%, 0 is zoomed out infinitely.
1007
- *
1008
- * @param {string} visNetwork The network name/identifier.
1009
- *
1010
- * @throws {Error} Thrown when the network does not exist.
1011
- *
1012
- * @memberOf NetworkService
1013
- */
1014
- getScale(visNetwork) {
1015
- if (this.networks[visNetwork]) {
1016
- return this.networks[visNetwork].getScale();
1017
- }
1018
- else {
1019
- throw new Error(`Network with id ${visNetwork} not found.`);
1020
- }
1021
- }
1022
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisNetworkService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1023
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisNetworkService });
1024
- }
1025
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisNetworkService, decorators: [{
1026
- type: Injectable
1027
- }] });
1028
-
1029
- /**
1030
- * Use this directive with a div container to show network data.
1031
- *
1032
- * @export
1033
- * @class VisNetworkDirective
1034
- * @implements {OnInit}
1035
- * @implements {OnDestroy}
1036
- * @implements {OnChanges}
1037
- */
1038
- class VisNetworkDirective {
1039
- elementRef;
1040
- visNetworkService;
1041
- /**
1042
- * The name or identifier of the network (must be unique in your application).
1043
- * This property is used once on init and must not be changed.
1044
- *
1045
- * @type {string}
1046
- * @memberOf VisNetworkDirective
1047
- */
1048
- visNetwork;
1049
- /**
1050
- * The data that will be used to create the network.
1051
- * Changes to the nodes or edges property won't be detected but
1052
- * changes to the reference of this object.
1053
- * Changes lead to a call to setData of this network instance.
1054
- *
1055
- * @type {Data}
1056
- * @memberOf VisNetworkDirective
1057
- */
1058
- visNetworkData;
1059
- /**
1060
- * The options that will be used with this network instance.
1061
- * Only reference changes to the whole options object will be detected
1062
- * but not changes to properties.
1063
- * Changes lead to a call to setOptions of the network instance.
1064
- *
1065
- * @type {VisOptions}
1066
- * @memberOf VisNetworkDirective
1067
- */
1068
- visNetworkOptions;
1069
- /**
1070
- * This event will be raised when the network is initialized.
1071
- * At this point of time the network is successfully registered
1072
- * with the VisNetworkService and you can register to events.
1073
- * The event data is the name of the network as a string.
1074
- *
1075
- * @type {EventEmitter<any>}
1076
- * @memberOf VisNetworkDirective
1077
- */
1078
- initialized = new EventEmitter();
1079
- visNetworkContainer;
1080
- isInitialized = false;
1081
- /**
1082
- * Creates an instance of VisNetworkDirective.
1083
- *
1084
- * @param {ElementRef} elementRef The HTML element reference.
1085
- * @param {VisNetworkService} visNetworkService The VisNetworkService.
1086
- *
1087
- * @memberOf VisNetworkDirective
1088
- */
1089
- constructor(elementRef, visNetworkService) {
1090
- this.elementRef = elementRef;
1091
- this.visNetworkService = visNetworkService;
1092
- this.visNetworkContainer = elementRef.nativeElement;
1093
- }
1094
- /**
1095
- * Create the network when at least visNetwork and visData
1096
- * are defined.
1097
- *
1098
- * @memberOf VisNetworkDirective
1099
- */
1100
- ngOnInit() {
1101
- if (!this.isInitialized && this.visNetwork && this.visNetworkData) {
1102
- this.createNetwork();
1103
- }
1104
- }
1105
- /**
1106
- * Update the network data or options on reference changes to
1107
- * the visData or visOptions properties.
1108
- *
1109
- * @param {{[propName: string]: SimpleChange}} changes
1110
- *
1111
- * @memberOf VisNetworkDirective
1112
- */
1113
- ngOnChanges(changes) {
1114
- if (!this.isInitialized && this.visNetwork && this.visNetworkData) {
1115
- this.createNetwork();
1116
- }
1117
- for (const propertyName in changes) {
1118
- if (changes.hasOwnProperty(propertyName)) {
1119
- const change = changes[propertyName];
1120
- if (!change.isFirstChange()) {
1121
- if (propertyName === 'visNetworkData') {
1122
- this.visNetworkService.setData(this.visNetwork, changes[propertyName].currentValue);
1123
- }
1124
- if (propertyName === 'visNetworkOptions') {
1125
- this.visNetworkService.setOptions(this.visNetwork, changes[propertyName].currentValue);
1126
- }
1127
- }
1128
- }
1129
- }
1130
- }
1131
- /**
1132
- * Calls the destroy function for this network instance.
1133
- *
1134
- * @memberOf VisNetworkDirective
1135
- */
1136
- ngOnDestroy() {
1137
- this.isInitialized = false;
1138
- this.visNetworkService.destroy(this.visNetwork);
1139
- }
1140
- createNetwork() {
1141
- this.visNetworkService.create(this.visNetwork, this.visNetworkContainer, this.visNetworkData, this.visNetworkOptions);
1142
- this.isInitialized = true;
1143
- this.initialized.emit(this.visNetwork);
1144
- }
1145
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisNetworkDirective, deps: [{ token: i0.ElementRef }, { token: VisNetworkService }], target: i0.ɵɵFactoryTarget.Directive });
1146
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.6", type: VisNetworkDirective, isStandalone: true, selector: "[visNetwork]", inputs: { visNetwork: "visNetwork", visNetworkData: "visNetworkData", visNetworkOptions: "visNetworkOptions" }, outputs: { initialized: "initialized" }, usesOnChanges: true, ngImport: i0 });
1147
- }
1148
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisNetworkDirective, decorators: [{
1149
- type: Directive,
1150
- args: [{
1151
- selector: '[visNetwork]',
1152
- }]
1153
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: VisNetworkService }], propDecorators: { visNetwork: [{
1154
- type: Input,
1155
- args: ['visNetwork']
1156
- }], visNetworkData: [{
1157
- type: Input
1158
- }], visNetworkOptions: [{
1159
- type: Input
1160
- }], initialized: [{
1161
- type: Output
1162
- }] } });
1163
-
1164
- /**
1165
- * A service to create, manage and control VisTimeline instances.
1166
- *
1167
- * @export
1168
- * @class VisTimelineService
1169
- */
1170
- class VisTimelineService {
1171
- ngZone;
1172
- /**
1173
- * Fired when the current time bar redraws.
1174
- * The rate depends on the zoom level.
1175
- *
1176
- * @type {EventEmitter<any>}
1177
- * @memberOf VisTimelineService
1178
- */
1179
- currentTimeTick = new EventEmitter();
1180
- /**
1181
- * Fired when clicked inside the Timeline.
1182
- *
1183
- * @type {EventEmitter<any>}
1184
- * @memberOf VisTimelineService
1185
- */
1186
- click = new EventEmitter();
1187
- /**
1188
- * Fired when right-clicked inside the Timeline.
1189
- * Note that in order to prevent the context menu from showing up,
1190
- * default behavior of the event must be stopped.
1191
- *
1192
- * @type {EventEmitter<any>}
1193
- * @memberOf VisTimelineService
1194
- */
1195
- contextmenu = new EventEmitter();
1196
- /**
1197
- * Fired when double clicked inside the Timeline.
1198
- *
1199
- * @type {EventEmitter<any>}
1200
- * @memberOf VisTimelineService
1201
- */
1202
- doubleClick = new EventEmitter();
1203
- /**
1204
- * Fired after the dragging of a group is finished.
1205
- *
1206
- * @type {EventEmitter<any>}
1207
- * @memberOf VisTimelineService
1208
- */
1209
- groupDragged = new EventEmitter();
1210
- /**
1211
- * Fired once after each graph redraw.
1212
- *
1213
- * @type {EventEmitter<any>}
1214
- * @memberOf VisTimelineService
1215
- */
1216
- changed = new EventEmitter();
1217
- /**
1218
- * Fired repeatedly when the timeline window is being changed.
1219
- *
1220
- * @type {EventEmitter<any>}
1221
- * @memberOf VisTimelineService
1222
- */
1223
- rangechange = new EventEmitter();
1224
- /**
1225
- * Fired once after the timeline window has been changed.
1226
- *
1227
- * @type {EventEmitter<any>}
1228
- * @memberOf VisTimelineService
1229
- */
1230
- rangechanged = new EventEmitter();
1231
- /**
1232
- * Fired after the user selects or deselects items by tapping or holding them.
1233
- * When a use taps an already selected item, the select event is fired again.
1234
- * Not fired when the method setSelectionis executed.
1235
- *
1236
- * @type {EventEmitter<any>}
1237
- * @memberOf VisTimelineService
1238
- */
1239
- select = new EventEmitter();
1240
- /**
1241
- * Fired when the user moves the mouse over an item.
1242
- *
1243
- * @type {EventEmitter<any>}
1244
- * @memberOf VisTimelineService
1245
- */
1246
- itemover = new EventEmitter();
1247
- /**
1248
- * Fired when the user moves the mouse out of an item.
1249
- *
1250
- * @type {EventEmitter<any>}
1251
- * @memberOf VisTimelineService
1252
- */
1253
- itemout = new EventEmitter();
1254
- /**
1255
- * Fired repeatedly when the user is dragging the custom time bar.
1256
- * Only available when the custom time bar is enabled.
1257
- *
1258
- * @type {EventEmitter<any>}
1259
- * @memberOf VisTimelineService
1260
- */
1261
- timechange = new EventEmitter();
1262
- /**
1263
- * Fired once after the user has dragged the custom time bar.
1264
- * Only available when the custom time bar is enabled.
1265
- *
1266
- * @type {EventEmitter<any>}
1267
- * @memberOf VisTimelineService
1268
- */
1269
- timechanged = new EventEmitter();
1270
- events = new Map();
1271
- timelines = {};
1272
- constructor(ngZone) {
1273
- this.ngZone = ngZone;
1274
- }
1275
- /**
1276
- * Creates a new timeline instance.
1277
- *
1278
- * @param {string} visTimeline The timeline name/identifier.
1279
- * @param {HTMLElement} container The HTML element that contains the timeline view.
1280
- * @param {VisTimelineItems} items The initial timeline items.
1281
- * @param {VisTimelineOptions} [options] The timeline options.
1282
- *
1283
- * @throws {Error} Thrown when timeline already exists.
1284
- *
1285
- * @memberOf VisTimelineService
1286
- */
1287
- createWithItems(visTimeline, container, items, options) {
1288
- if (this.timelines[visTimeline]) {
1289
- throw new Error(this.alreadyExistsError(visTimeline));
1290
- }
1291
- this.timelines[visTimeline] = this.ngZone.runOutsideAngular(() => new Timeline(container, items, this.wrapCallbacksWithNgZone(options)));
1292
- }
1293
- /**
1294
- * Creates a new timeline instance.
1295
- *
1296
- * @param {string} visTimeline The timeline name/identifier.
1297
- * @param {HTMLElement} container The HTML element that contains the timeline view.
1298
- * @param {VisTimelineItems} items The initial timeline items.
1299
- * @param {VisTimelineGroups} groups The initial timeline groups.
1300
- * @param {VisTimelineOptions} [options] The timeline options.
1301
- *
1302
- * @throws {Error} Thrown when timeline already exists.
1303
- *
1304
- * @memberOf VisTimelineService
1305
- */
1306
- createWithItemsAndGroups(visTimeline, container, items, groups, options) {
1307
- if (this.timelines[visTimeline]) {
1308
- throw new Error(this.alreadyExistsError(visTimeline));
1309
- }
1310
- this.timelines[visTimeline] = this.ngZone.runOutsideAngular(() => new Timeline(container, items, groups, this.wrapCallbacksWithNgZone(options)));
1311
- }
1312
- /**
1313
- * Add new vertical bar representing a custom time that can be dragged by the user.
1314
- * The id is added as CSS class name of the custom time bar,
1315
- * allowing to style multiple time bars differently.
1316
- *
1317
- * @param {string} visTimeline The timeline name/identifier.
1318
- * @param {DateType} time Parameter time can be a Date, Number, or String, and is new Date() by default.
1319
- * @param {IdType} [id] Parameter id can be Number or String and is undefined by default.
1320
- * @returns {IdType} The method returns id of the created bar.
1321
- *
1322
- * @throws {Error} Thrown when timeline does not exist.
1323
- *
1324
- * @memberOf VisTimelineService
1325
- */
1326
- addCustomTime(visTimeline, time, id) {
1327
- if (this.timelines[visTimeline]) {
1328
- return this.timelines[visTimeline].addCustomTime(time, id);
1329
- }
1330
- else {
1331
- throw new Error(this.doesNotExistError(visTimeline));
1332
- }
1333
- }
1334
- /**
1335
- * Adjust the visible window such that it fits all items.
1336
- * See also function focus(id).
1337
- *
1338
- * @param {string} visTimeline The timeline name/identifier.
1339
- * @param {TimelineAnimationOptions} [options] Optional options.
1340
- *
1341
- * @throws {Error} Thrown when timeline does not exist.
1342
- *
1343
- * @memberOf VisTimelineService
1344
- */
1345
- fit(visTimeline, options) {
1346
- if (this.timelines[visTimeline]) {
1347
- this.timelines[visTimeline].fit(options);
1348
- }
1349
- else {
1350
- throw new Error(this.doesNotExistError(visTimeline));
1351
- }
1352
- }
1353
- /**
1354
- * Adjust the visible window such that the selected item is centered on screen.
1355
- *
1356
- * @param {string} visTimeline The timeline name/identifier.
1357
- * @param {IdType} id The id of the item.
1358
- * @param {TimelineAnimationOptions} [options] Options options.
1359
- *
1360
- * @throws {Error} Thrown when timeline does not exist.
1361
- *
1362
- * @memberOf VisTimelineService
1363
- */
1364
- focusOnId(visTimeline, id, options) {
1365
- if (this.timelines[visTimeline]) {
1366
- this.timelines[visTimeline].focus(id, options);
1367
- }
1368
- else {
1369
- throw new Error(this.doesNotExistError(visTimeline));
1370
- }
1371
- }
1372
- /**
1373
- * Adjust the visible window such that the selected items are centered on screen.
1374
- *
1375
- * @param {string} visTimeline The timeline name/identifier.
1376
- * @param {IdType[]} ids The item ids.
1377
- * @param {TimelineAnimationOptions} [options] Optional options.
1378
- *
1379
- * @throws {Error} Thrown when timeline does not exist.
1380
- *
1381
- * @memberOf VisTimelineService
1382
- */
1383
- focusOnIds(visTimeline, ids, options) {
1384
- if (this.timelines[visTimeline]) {
1385
- this.timelines[visTimeline].focus(ids, options);
1386
- }
1387
- else {
1388
- throw new Error(this.doesNotExistError(visTimeline));
1389
- }
1390
- }
1391
- /**
1392
- * Get the current time.
1393
- * Only applicable when option showCurrentTime is true.
1394
- *
1395
- * @param {string} visTimeline The timeline name/identifier.
1396
- * @returns {Date} The current time.
1397
- *
1398
- * @throws {Error} Thrown when timeline does not exist.
1399
- *
1400
- * @memberOf VisTimelineService
1401
- */
1402
- getCurrentTime(visTimeline) {
1403
- if (this.timelines[visTimeline]) {
1404
- return this.timelines[visTimeline].getCurrentTime();
1405
- }
1406
- else {
1407
- throw new Error(this.doesNotExistError(visTimeline));
1408
- }
1409
- }
1410
- /**
1411
- * Retrieve the custom time from the custom time bar with given id.
1412
- * Id is undefined by default.
1413
- *
1414
- * @param {string} visTimeline The timeline name/identifier.
1415
- * @param {IdType} [id] The time bar id.
1416
- * @returns {Date} The custom time.
1417
- *
1418
- * @throws {Error} Thrown when timeline does not exist.
1419
- *
1420
- * @memberOf VisTimelineService
1421
- */
1422
- getCustomTime(visTimeline, id) {
1423
- if (this.timelines[visTimeline]) {
1424
- return this.timelines[visTimeline].getCustomTime(id);
1425
- }
1426
- else {
1427
- throw new Error(this.doesNotExistError(visTimeline));
1428
- }
1429
- }
1430
- /**
1431
- * Returns an Object with relevant properties from an event.
1432
- *
1433
- * @param {string} visTimeline The timeline name/identifier.
1434
- * @param {Event} event The event.
1435
- * @returns {VisTimelineEventPropertiesResult} Properties of an event
1436
- *
1437
- * @throws {Error} Thrown when timeline does not exist.
1438
- *
1439
- * @memberOf VisTimelineService
1440
- */
1441
- getEventProperties(visTimeline, event) {
1442
- if (this.timelines[visTimeline]) {
1443
- return this.timelines[visTimeline].getEventProperties(event);
1444
- }
1445
- else {
1446
- throw new Error(this.doesNotExistError(visTimeline));
1447
- }
1448
- }
1449
- /**
1450
- * Get the range of all the items as an object containing min: Date and max: Date.
1451
- *
1452
- * @param {string} visTimeline The timeline name/identifier.
1453
- * @returns {{ min: Date, max: Date }} The min and max dates.
1454
- *
1455
- * @throws {Error} Thrown when timeline does not exist.
1456
- *
1457
- * @memberOf VisTimelineService
1458
- */
1459
- getItemRange(visTimeline) {
1460
- if (this.timelines[visTimeline]) {
1461
- return this.timelines[visTimeline].getItemRange();
1462
- }
1463
- else {
1464
- throw new Error(this.doesNotExistError(visTimeline));
1465
- }
1466
- }
1467
- /**
1468
- * Get an array with the ids of the currently selected items.
1469
- *
1470
- * @param {string} visTimeline The timeline name/identifier.
1471
- * @returns {IdType[]} The currently selected items.
1472
- *
1473
- * @throws {Error} Thrown when timeline does not exist.
1474
- *
1475
- * @memberOf VisTimelineService
1476
- */
1477
- getSelection(visTimeline) {
1478
- if (this.timelines[visTimeline]) {
1479
- return this.timelines[visTimeline].getSelection();
1480
- }
1481
- else {
1482
- throw new Error(this.doesNotExistError(visTimeline));
1483
- }
1484
- }
1485
- /**
1486
- * Get an array with the ids of the currently visible items.
1487
- *
1488
- * @param {string} visTimeline The timeline name/identifier.
1489
- * @returns {IdType[]} The currently visible items.
1490
- *
1491
- * @throws {Error} Thrown when timeline does not exist.
1492
- *
1493
- * @memberOf VisTimelineService
1494
- */
1495
- getVisibleItems(visTimeline) {
1496
- if (this.timelines[visTimeline]) {
1497
- return this.timelines[visTimeline].getVisibleItems();
1498
- }
1499
- else {
1500
- throw new Error(this.doesNotExistError(visTimeline));
1501
- }
1502
- }
1503
- /**
1504
- * Get the current visible window.
1505
- *
1506
- * @param {string} visTimeline The timeline name/identifier.
1507
- * @returns {{ start: Date, end: Date }} Returns an object with properties start: Date and end: Date.
1508
- *
1509
- * @throws {Error} Thrown when timeline does not exist.
1510
- *
1511
- * @memberOf VisTimelineService
1512
- */
1513
- getWindow(visTimeline) {
1514
- if (this.timelines[visTimeline]) {
1515
- return this.timelines[visTimeline].getWindow();
1516
- }
1517
- else {
1518
- throw new Error(this.doesNotExistError(visTimeline));
1519
- }
1520
- }
1521
- /**
1522
- * Move the window such that given time is centered on screen.
1523
- *
1524
- * @param {string} visTimeline The timeline name/identifier.
1525
- * @param {DateType} time Parameter time can be a Date, Number, or String.
1526
- * @param {TimelineAnimationOptions} [options] Optional options.
1527
- *
1528
- * @throws {Error} Thrown when timeline does not exist.
1529
- *
1530
- * @memberOf VisTimelineService
1531
- */
1532
- moveTo(visTimeline, time, options) {
1533
- if (this.timelines[visTimeline]) {
1534
- this.timelines[visTimeline].moveTo(time, options);
1535
- }
1536
- else {
1537
- throw new Error(this.doesNotExistError(visTimeline));
1538
- }
1539
- }
1540
- /**
1541
- * Force a redraw of the Timeline.
1542
- * The size of all items will be recalculated.
1543
- * Can be useful to manually redraw when option autoResize=false and the window has been resized,
1544
- * or when the items CSS has been changed.
1545
- *
1546
- * @param {string} visTimeline The timeline name/identifier.
1547
- *
1548
- * @throws {Error} Thrown when timeline does not exist.
1549
- *
1550
- * @memberOf VisTimelineService
1551
- */
1552
- redraw(visTimeline) {
1553
- if (this.timelines[visTimeline]) {
1554
- this.timelines[visTimeline].redraw();
1555
- }
1556
- else {
1557
- throw new Error(this.doesNotExistError(visTimeline));
1558
- }
1559
- }
1560
- /**
1561
- * Remove vertical bars previously added to the timeline via addCustomTime method.
1562
- *
1563
- * @param {string} visTimeline The timeline name/identifier.
1564
- * @param {IdType} id Parameter id is the ID of the custom vertical bar returned by addCustomTime method.
1565
- *
1566
- * @throws {Error} Thrown when timeline does not exist.
1567
- *
1568
- * @memberOf VisTimelineService
1569
- */
1570
- removeCustomTime(visTimeline, id) {
1571
- if (this.timelines[visTimeline]) {
1572
- this.timelines[visTimeline].removeCustomTime(id);
1573
- }
1574
- else {
1575
- throw new Error(this.doesNotExistError(visTimeline));
1576
- }
1577
- }
1578
- /**
1579
- * Set a current time.
1580
- * This can be used for example to ensure that a client's time is synchronized
1581
- * with a shared server time.
1582
- * Only applicable when option showCurrentTime is true.
1583
- *
1584
- * @param {string} visTimeline The timeline name/identifier.
1585
- * @param {DateType} time time can be a Date object, numeric timestamp, or ISO date string.
1586
- *
1587
- * @throws {Error} Thrown when timeline does not exist.
1588
- *
1589
- * @memberOf VisTimelineService
1590
- */
1591
- setCurrentTime(visTimeline, time) {
1592
- if (this.timelines[visTimeline]) {
1593
- this.timelines[visTimeline].setCurrentTime(time);
1594
- }
1595
- else {
1596
- throw new Error(this.doesNotExistError(visTimeline));
1597
- }
1598
- }
1599
- /**
1600
- * Adjust the time of a custom time bar.
1601
- *
1602
- * @param {string} visTimeline The timeline name/identifier.
1603
- * @param {DateType} time Parameter time can be a Date object, numeric timestamp, or ISO date string.
1604
- * @param {IdType} [id] Parameter id is the id of the custom time bar, and is undefined by default.
1605
- *
1606
- * @throws {Error} Thrown when timeline does not exist.
1607
- *
1608
- * @memberOf VisTimelineService
1609
- */
1610
- setCustomTime(visTimeline, time, id) {
1611
- if (this.timelines[visTimeline]) {
1612
- this.timelines[visTimeline].setCustomTime(time, id);
1613
- }
1614
- else {
1615
- throw new Error(this.doesNotExistError(visTimeline));
1616
- }
1617
- }
1618
- /**
1619
- * Adjust the title attribute of a custom time bar.
1620
- *
1621
- * @param {string} visTimeline The timeline name/identifier.
1622
- * @param {string} title Parameter title is the string to be set as title.
1623
- * Use empty string to hide the title completely.
1624
- * @param {IdType} [id] Parameter id is the id of the custom time bar, and is undefined by default.
1625
- *
1626
- * @throws {Error} Thrown when timeline does not exist.
1627
- *
1628
- * @memberOf VisTimelineService
1629
- */
1630
- setCustomTimeTitle(visTimeline, title, id) {
1631
- if (this.timelines[visTimeline]) {
1632
- this.timelines[visTimeline].setCustomTimeTitle(title, id);
1633
- }
1634
- else {
1635
- throw new Error(this.doesNotExistError(visTimeline));
1636
- }
1637
- }
1638
- /**
1639
- * Set both groups and items at once.
1640
- * Both properties are optional.
1641
- * This is a convenience method for individually calling both setItems(items) and setGroups(groups).
1642
- * Both items and groups can be an Array with Objects, a DataSet (offering 2 way data binding),
1643
- * or a DataView (offering 1 way data binding).
1644
- * For each of the groups, the items of the timeline are filtered on the property group,
1645
- * which must correspond with the id of the group.
1646
- *
1647
- * @param {string} visTimeline The timeline name/identifier.
1648
- * @param {{ groups?: VisTimelineGroups; items?: VisTimelineItems }} data The new timline data.
1649
- *
1650
- * @throws {Error} Thrown when timeline does not exist.
1651
- *
1652
- * @memberOf VisTimelineService
1653
- */
1654
- setData(visTimeline, data) {
1655
- if (this.timelines[visTimeline]) {
1656
- this.timelines[visTimeline].setData(data);
1657
- }
1658
- else {
1659
- throw new Error(this.doesNotExistError(visTimeline));
1660
- }
1661
- }
1662
- /**
1663
- * Set a data set with groups for the Timeline.
1664
- * For each of the groups, the items of the timeline are filtered on the property group,
1665
- * which must correspond with the id of the group.
1666
- *
1667
- * @param {string} visTimeline The timeline name/identifier.
1668
- * @param {VisTimelineGroups} groups a DataSet (offering 2 way data binding)
1669
- *
1670
- * @throws {Error} Thrown when timeline does not exist.
1671
- *
1672
- * @memberOf VisTimelineService
1673
- */
1674
- setGroups(visTimeline, groups) {
1675
- if (this.timelines[visTimeline]) {
1676
- this.timelines[visTimeline].setGroups(groups);
1677
- }
1678
- else {
1679
- throw new Error(this.doesNotExistError(visTimeline));
1680
- }
1681
- }
1682
- /**
1683
- * Set a data set with items for the Timeline.
1684
- *
1685
- * @param {string} visTimeline The timeline name/identifier.
1686
- * @param {VisTimelineItems} items can be an Array with Objects, a DataSet (offering 2 way data binding)
1687
- *
1688
- * @throws {Error} Thrown when timeline does not exist.
1689
- *
1690
- * @memberOf VisTimelineService
1691
- */
1692
- setItems(visTimeline, items) {
1693
- if (this.timelines[visTimeline]) {
1694
- this.timelines[visTimeline].setItems(items);
1695
- }
1696
- else {
1697
- throw new Error(this.doesNotExistError(visTimeline));
1698
- }
1699
- }
1700
- /**
1701
- * Set or update options.
1702
- * It is possible to change any option of the timeline at any time.
1703
- * You can for example switch orientation on the fly.
1704
- *
1705
- * @param {string} visTimeline The timeline name/identifier.
1706
- * @param {VisTimelineOptions} options The new options of the timeline.
1707
- *
1708
- * @throws {Error} Thrown when timeline does not exist.
1709
- *
1710
- * @memberOf VisTimelineService
1711
- */
1712
- setOptions(visTimeline, options) {
1713
- if (this.timelines[visTimeline]) {
1714
- this.timelines[visTimeline].setOptions(options);
1715
- }
1716
- else {
1717
- throw new Error(this.doesNotExistError(visTimeline));
1718
- }
1719
- }
1720
- /**
1721
- * Select one item by its id.#
1722
- * The currently selected items will be unselected.
1723
- *
1724
- * @param {string} visTimeline The timeline name/identifier.
1725
- * @param {IdType} id The id of the item that should be selected.
1726
- *
1727
- * @throws {Error} Thrown when timeline does not exist.
1728
- *
1729
- * @memberOf VisTimelineService
1730
- */
1731
- setSelectionToId(visTimeline, id) {
1732
- if (this.timelines[visTimeline]) {
1733
- this.timelines[visTimeline].setSelection(id);
1734
- }
1735
- else {
1736
- throw new Error(this.doesNotExistError(visTimeline));
1737
- }
1738
- }
1739
- /**
1740
- * Select multiple items by their id.
1741
- * The currently selected items will be unselected.
1742
- * To unselect all selected items, call `setSelection([])`.
1743
- *
1744
- * @param {string} visTimeline The timeline name/identifier.
1745
- * @param {IdType[]} ids The ids of the irems that should be selected.
1746
- *
1747
- * @throws {Error} Thrown when timeline does not exist.
1748
- *
1749
- * @memberOf VisTimelineService
1750
- */
1751
- setSelectionToIds(visTimeline, ids) {
1752
- if (this.timelines[visTimeline]) {
1753
- this.timelines[visTimeline].setSelection(ids);
1754
- }
1755
- else {
1756
- throw new Error(this.doesNotExistError(visTimeline));
1757
- }
1758
- }
1759
- /**
1760
- * Set the current visible window.
1761
- *
1762
- * If the parameter value of start or end is null, the parameter will be left unchanged.
1763
- *
1764
- * @param {string} visTimeline The timeline name/identifier.
1765
- * @param {DateType} start The parameters start can be a Date, Number, or String.
1766
- * @param {DateType} end The parameters end can be a Date, Number, or String.
1767
- * @param {TimelineAnimationOptions} [options] Optional options.
1768
- *
1769
- * @throws {Error} Thrown when timeline does not exist.
1770
- *
1771
- * @memberOf VisTimelineService
1772
- */
1773
- setWindow(visTimeline, start, end, options) {
1774
- if (this.timelines[visTimeline]) {
1775
- this.timelines[visTimeline].setWindow(start, end, options);
1776
- }
1777
- else {
1778
- throw new Error(this.doesNotExistError(visTimeline));
1779
- }
1780
- }
1781
- /**
1782
- * Destroy the Timeline.
1783
- * The timeline is removed from memory.
1784
- * All DOM elements and event listeners are cleaned up.
1785
- *
1786
- * @param {string} visTimeline The timeline name/identifier.
1787
- *
1788
- * @memberOf VisTimelineService
1789
- */
1790
- destroy(visTimeline) {
1791
- if (this.timelines[visTimeline]) {
1792
- this.timelines[visTimeline].destroy();
1793
- delete this.timelines[visTimeline];
1794
- }
1795
- }
1796
- /**
1797
- * Activates an event.
1798
- *
1799
- * @param {string} visTimeline The timeline name/identifier.
1800
- * @param {string} eventName The event name.
1801
- * @param {boolean} preventDefault Stops the default behavior of the event.
1802
- * @returns {boolean} Returns true when the event was activated.
1803
- *
1804
- * @memberOf VisTimelineService
1805
- */
1806
- on(visTimeline, eventName, preventDefault) {
1807
- if (this.timelines[visTimeline]) {
1808
- this.events.set(eventName, new EventEmitter());
1809
- // tslint:disable-next-line
1810
- const that = this;
1811
- this.timelines[visTimeline].on(eventName, (params) => {
1812
- const emitter = (that[eventName] || that.events.get(eventName));
1813
- if (emitter) {
1814
- emitter.emit(params ? [visTimeline].concat(params) : visTimeline);
1815
- }
1816
- if (preventDefault && params.event) {
1817
- params.event.preventDefault();
1818
- }
1819
- });
1820
- return true;
1821
- }
1822
- return false;
1823
- }
1824
- /**
1825
- * Deactivates an event.
1826
- *
1827
- * @param {string} visTimeline The timeline name/identifier.
1828
- * @param {string} eventName The event name.
1829
- *
1830
- * @memberOf VisTimelineService
1831
- */
1832
- off(visTimeline, eventName) {
1833
- if (this.timelines[visTimeline]) {
1834
- this.events.delete(eventName);
1835
- this.timelines[visTimeline].off(eventName, undefined);
1836
- }
1837
- }
1838
- /**
1839
- * Get the event emitter associated with the specified event name.
1840
- * @param {string} eventName The event name.
1841
- * @returns {EventEmitter<any>} The event emitter of the specified event name.
1842
- */
1843
- getEmitter(eventName) {
1844
- return this.events.get(eventName);
1845
- }
1846
- doesNotExistError(visTimeline) {
1847
- return `Timeline with id ${visTimeline} does not exist.`;
1848
- }
1849
- alreadyExistsError(visTimeline) {
1850
- return `Timeline with id ${visTimeline} already exists.`;
1851
- }
1852
- wrapCallbacksWithNgZone(options) {
1853
- const updatedOptions = { ...options };
1854
- const callbackFunctions = [
1855
- 'onAdd',
1856
- 'onAddGroup',
1857
- 'onDropObjectOnItem',
1858
- 'onInitialDrawComplete',
1859
- 'onUpdate',
1860
- 'onMove',
1861
- 'onMoveGroup',
1862
- 'onMoving',
1863
- 'onRemove',
1864
- 'onRemoveGroup',
1865
- ];
1866
- callbackFunctions
1867
- .filter((callbackFunction) => updatedOptions.hasOwnProperty(callbackFunction))
1868
- .forEach((callbackFunction) => {
1869
- updatedOptions[callbackFunction] = (...params) => this.ngZone.run(() => options[callbackFunction](...params));
1870
- });
1871
- return updatedOptions;
1872
- }
1873
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisTimelineService, deps: [{ token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
1874
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisTimelineService });
1875
- }
1876
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisTimelineService, decorators: [{
1877
- type: Injectable
1878
- }], ctorParameters: () => [{ type: i0.NgZone }] });
1879
-
1880
- /**
1881
- * Use this directive with a div container to show timeline data.
1882
- *
1883
- * @export
1884
- * @class VisTimelineDirective
1885
- * @implements {OnInit}
1886
- * @implements {OnDestroy}
1887
- * @implements {OnChanges}
1888
- */
1889
- class VisTimelineDirective {
1890
- elementRef;
1891
- visTimelineService;
1892
- /**
1893
- * The name or identifier of the timeline (must be unique in your application).
1894
- * This property is used once on init and must not be changed.
1895
- *
1896
- * @type {string}
1897
- * @memberOf VisTimelineDirective
1898
- */
1899
- visTimeline;
1900
- /**
1901
- * The data that will be used to create the timeline.
1902
- * Changes will be detected. If the reference changes then
1903
- * setData will be called on this timeline instance.
1904
- *
1905
- * @type {VisTimelineItems}
1906
- * @memberOf VisTimelineDirective
1907
- */
1908
- visTimelineItems;
1909
- /**
1910
- * The groups that will be used to create the timeline.
1911
- * Changes will be detected. If the reference changes then
1912
- * setGroups will be called on this timeline instance.
1913
- *
1914
- * @type {VisTimelineGroups}
1915
- * @memberOf VisTimelineDirective
1916
- */
1917
- visTimelineGroups;
1918
- /**
1919
- * The options that will be used with this timeline.
1920
- * Changes will be detected. If the reference changes then
1921
- * setOptions will be called on this timeline instance.
1922
- *
1923
- * @type {VisTimelineOptions}
1924
- * @memberOf VisTimelineDirective
1925
- */
1926
- visTimelineOptions;
1927
- /**
1928
- * This event will be raised when the timline is initialized.
1929
- * At this point of time the timeline is successfully registered
1930
- * with the VisNetworkService and you can register to events.
1931
- * The event data is the name of the timeline as a string.
1932
- *
1933
- * @type {EventEmitter<any>}
1934
- * @memberOf VisTimelineDirective
1935
- */
1936
- initialized = new EventEmitter();
1937
- visTimelineContainer;
1938
- isInitialized = false;
1939
- /**
1940
- * Creates an instance of VisTimelineDirective.
1941
- *
1942
- * @param {ElementRef} elementRef The HTML element reference.
1943
- * @param {VisTimelineService} visTimelineService The VisTimelineService.
1944
- *
1945
- * @memberOf VisTimelineDirective
1946
- */
1947
- constructor(elementRef, visTimelineService) {
1948
- this.elementRef = elementRef;
1949
- this.visTimelineService = visTimelineService;
1950
- this.visTimelineContainer = elementRef.nativeElement;
1951
- }
1952
- /**
1953
- * Create the timeline when at least visNetwork and visNetworkData
1954
- * are defined.
1955
- *
1956
- * @memberOf VisTimelineDirective
1957
- */
1958
- ngOnInit() {
1959
- if (!this.isInitialized && this.visTimeline && this.visTimelineItems) {
1960
- this.createTimeline();
1961
- }
1962
- }
1963
- /**
1964
- * Update the timeline data, groups or options on reference changes to
1965
- * the visTimelineItems, visTimelineGroups or visTimelineOptions properties.
1966
- *
1967
- * @param {{[propName: string]: SimpleChange}} changes
1968
- *
1969
- * @memberOf VisTimelineDirective
1970
- */
1971
- ngOnChanges(changes) {
1972
- if (!this.isInitialized && this.visTimeline && this.visTimelineItems) {
1973
- this.createTimeline();
1974
- }
1975
- for (const propertyName in changes) {
1976
- if (changes.hasOwnProperty(propertyName)) {
1977
- const change = changes[propertyName];
1978
- if (!change.isFirstChange()) {
1979
- if (propertyName === 'visTimelineItems') {
1980
- this.visTimelineService.setItems(this.visTimeline, changes[propertyName].currentValue);
1981
- }
1982
- if (propertyName === 'visTimelineOptions') {
1983
- this.visTimelineService.setOptions(this.visTimeline, changes[propertyName].currentValue);
1984
- }
1985
- if (propertyName === 'visTimelineGroups') {
1986
- this.visTimelineService.setGroups(this.visTimeline, changes[propertyName].currentValue);
1987
- }
1988
- }
1989
- }
1990
- }
1991
- }
1992
- /**
1993
- * Calls the destroy function for this timeline instance.
1994
- *
1995
- *
1996
- * @memberOf VisTimelineDirective
1997
- */
1998
- ngOnDestroy() {
1999
- this.isInitialized = false;
2000
- this.visTimelineService.destroy(this.visTimeline);
2001
- }
2002
- createTimeline() {
2003
- if (this.visTimelineGroups) {
2004
- this.visTimelineService.createWithItemsAndGroups(this.visTimeline, this.visTimelineContainer, this.visTimelineItems, this.visTimelineGroups, this.visTimelineOptions);
2005
- }
2006
- else {
2007
- this.visTimelineService.createWithItems(this.visTimeline, this.visTimelineContainer, this.visTimelineItems, this.visTimelineOptions);
2008
- }
2009
- this.isInitialized = true;
2010
- this.initialized.emit(this.visTimeline);
2011
- }
2012
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisTimelineDirective, deps: [{ token: i0.ElementRef }, { token: VisTimelineService }], target: i0.ɵɵFactoryTarget.Directive });
2013
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.6", type: VisTimelineDirective, isStandalone: true, selector: "[visTimeline]", inputs: { visTimeline: "visTimeline", visTimelineItems: "visTimelineItems", visTimelineGroups: "visTimelineGroups", visTimelineOptions: "visTimelineOptions" }, outputs: { initialized: "initialized" }, usesOnChanges: true, ngImport: i0 });
2014
- }
2015
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisTimelineDirective, decorators: [{
2016
- type: Directive,
2017
- args: [{
2018
- selector: '[visTimeline]',
2019
- }]
2020
- }], ctorParameters: () => [{ type: i0.ElementRef }, { type: VisTimelineService }], propDecorators: { visTimeline: [{
2021
- type: Input,
2022
- args: ['visTimeline']
2023
- }], visTimelineItems: [{
2024
- type: Input
2025
- }], visTimelineGroups: [{
2026
- type: Input
2027
- }], visTimelineOptions: [{
2028
- type: Input
2029
- }], initialized: [{
2030
- type: Output
2031
- }] } });
2032
-
2033
- class VisModule {
2034
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2035
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.6", ngImport: i0, type: VisModule, imports: [CommonModule, VisNetworkDirective, VisTimelineDirective], exports: [VisNetworkDirective, VisTimelineDirective] });
2036
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisModule, providers: [VisNetworkService, VisTimelineService], imports: [CommonModule] });
2037
- }
2038
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: VisModule, decorators: [{
2039
- type: NgModule,
2040
- args: [{
2041
- imports: [CommonModule, VisNetworkDirective, VisTimelineDirective],
2042
- exports: [VisNetworkDirective, VisTimelineDirective],
2043
- providers: [VisNetworkService, VisTimelineService],
2044
- schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
2045
- }]
2046
- }] });
2047
-
2048
- /**
2049
- * Generated bundle index. Do not edit.
2050
- */
2051
-
2052
- export { VisModule, VisNetworkDirective, VisNetworkService, VisTimelineDirective, VisTimelineService };
2053
- //# sourceMappingURL=ngxvis.mjs.map