vis-data 7.1.8 → 7.1.10
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/declarations/data-interface.d.ts +0 -46
- package/declarations/data-interface.d.ts.map +1 -1
- package/declarations/data-pipe.d.ts +0 -8
- package/declarations/data-pipe.d.ts.map +1 -1
- package/declarations/data-set-check.d.ts +0 -1
- package/declarations/data-set-check.d.ts.map +1 -1
- package/declarations/data-set-part.d.ts +0 -1
- package/declarations/data-set-part.d.ts.map +1 -1
- package/declarations/data-set.d.ts +14 -28
- package/declarations/data-set.d.ts.map +1 -1
- package/declarations/data-stream.d.ts +0 -18
- package/declarations/data-stream.d.ts.map +1 -1
- package/declarations/data-view-check.d.ts +0 -1
- package/declarations/data-view-check.d.ts.map +1 -1
- package/declarations/data-view.d.ts +9 -15
- package/declarations/data-view.d.ts.map +1 -1
- package/declarations/queue.d.ts +0 -7
- package/declarations/queue.d.ts.map +1 -1
- package/dist/esm.js +133 -266
- package/dist/esm.js.map +1 -1
- package/dist/umd.js +133 -266
- package/dist/umd.js.map +1 -1
- package/esnext/esm/vis-data.js +25 -91
- package/esnext/esm/vis-data.js.map +1 -1
- package/esnext/esm/vis-data.min.js +2 -2
- package/esnext/esm/vis-data.min.js.map +1 -1
- package/esnext/umd/vis-data.js +25 -91
- package/esnext/umd/vis-data.js.map +1 -1
- package/esnext/umd/vis-data.min.js +2 -2
- package/esnext/umd/vis-data.min.js.map +1 -1
- package/package.json +19 -14
- package/peer/esm/vis-data.js +131 -264
- package/peer/esm/vis-data.js.map +1 -1
- package/peer/esm/vis-data.min.js +4 -4
- package/peer/esm/vis-data.min.js.map +1 -1
- package/peer/umd/vis-data.js +131 -264
- package/peer/umd/vis-data.js.map +1 -1
- package/peer/umd/vis-data.min.js +4 -4
- package/peer/umd/vis-data.min.js.map +1 -1
- package/standalone/esm/vis-data.js +131 -264
- package/standalone/esm/vis-data.js.map +1 -1
- package/standalone/esm/vis-data.min.js +4 -4
- package/standalone/esm/vis-data.min.js.map +1 -1
- package/standalone/umd/vis-data.js +131 -264
- package/standalone/umd/vis-data.js.map +1 -1
- package/standalone/umd/vis-data.min.js +4 -4
- package/standalone/umd/vis-data.min.js.map +1 -1
package/esnext/esm/vis-data.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Manage unstructured data using DataSet. Add, update, and remove data, and listen for changes in the data.
|
|
6
6
|
*
|
|
7
|
-
* @version 7.1.
|
|
8
|
-
* @date
|
|
7
|
+
* @version 7.1.10
|
|
8
|
+
* @date 2025-07-06T08:42:20.006Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -30,7 +30,6 @@ import { v4 } from 'uuid';
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Create new data pipe.
|
|
33
|
-
*
|
|
34
33
|
* @param from - The source data set or data view.
|
|
35
34
|
* @remarks
|
|
36
35
|
* Example usage:
|
|
@@ -66,7 +65,6 @@ function createNewDataPipeFrom(from) {
|
|
|
66
65
|
/**
|
|
67
66
|
* Internal implementation of the pipe. This should be accessible only through
|
|
68
67
|
* `createNewDataPipeFrom` from the outside.
|
|
69
|
-
*
|
|
70
68
|
* @typeParam SI - Source item type.
|
|
71
69
|
* @typeParam SP - Source item type's id property name.
|
|
72
70
|
* @typeParam TI - Target item type.
|
|
@@ -86,7 +84,6 @@ class SimpleDataPipe {
|
|
|
86
84
|
};
|
|
87
85
|
/**
|
|
88
86
|
* Create a new data pipe.
|
|
89
|
-
*
|
|
90
87
|
* @param _source - The data set or data view that will be observed.
|
|
91
88
|
* @param _transformers - An array of transforming functions to be used to
|
|
92
89
|
* filter or transform the items in the pipe.
|
|
@@ -118,7 +115,6 @@ class SimpleDataPipe {
|
|
|
118
115
|
}
|
|
119
116
|
/**
|
|
120
117
|
* Apply the transformers to the items.
|
|
121
|
-
*
|
|
122
118
|
* @param items - The items to be transformed.
|
|
123
119
|
* @returns The transformed items.
|
|
124
120
|
*/
|
|
@@ -129,7 +125,6 @@ class SimpleDataPipe {
|
|
|
129
125
|
}
|
|
130
126
|
/**
|
|
131
127
|
* Handle an add event.
|
|
132
|
-
*
|
|
133
128
|
* @param _name - Ignored.
|
|
134
129
|
* @param payload - The payload containing the ids of the added items.
|
|
135
130
|
*/
|
|
@@ -141,7 +136,6 @@ class SimpleDataPipe {
|
|
|
141
136
|
}
|
|
142
137
|
/**
|
|
143
138
|
* Handle an update event.
|
|
144
|
-
*
|
|
145
139
|
* @param _name - Ignored.
|
|
146
140
|
* @param payload - The payload containing the ids of the updated items.
|
|
147
141
|
*/
|
|
@@ -153,7 +147,6 @@ class SimpleDataPipe {
|
|
|
153
147
|
}
|
|
154
148
|
/**
|
|
155
149
|
* Handle a remove event.
|
|
156
|
-
*
|
|
157
150
|
* @param _name - Ignored.
|
|
158
151
|
* @param payload - The payload containing the data of the removed items.
|
|
159
152
|
*/
|
|
@@ -167,7 +160,6 @@ class SimpleDataPipe {
|
|
|
167
160
|
/**
|
|
168
161
|
* Internal implementation of the pipe factory. This should be accessible
|
|
169
162
|
* only through `createNewDataPipeFrom` from the outside.
|
|
170
|
-
*
|
|
171
163
|
* @typeParam TI - Target item type.
|
|
172
164
|
* @typeParam TP - Target item type's id property name.
|
|
173
165
|
*/
|
|
@@ -181,7 +173,6 @@ class DataPipeUnderConstruction {
|
|
|
181
173
|
/**
|
|
182
174
|
* Create a new data pipe factory. This is an internal constructor that
|
|
183
175
|
* should never be called from outside of this file.
|
|
184
|
-
*
|
|
185
176
|
* @param _source - The source data set or data view for this pipe.
|
|
186
177
|
*/
|
|
187
178
|
constructor(_source) {
|
|
@@ -189,7 +180,6 @@ class DataPipeUnderConstruction {
|
|
|
189
180
|
}
|
|
190
181
|
/**
|
|
191
182
|
* Filter the items.
|
|
192
|
-
*
|
|
193
183
|
* @param callback - A filtering function that returns true if given item
|
|
194
184
|
* should be piped and false if not.
|
|
195
185
|
* @returns This factory for further configuration.
|
|
@@ -200,7 +190,6 @@ class DataPipeUnderConstruction {
|
|
|
200
190
|
}
|
|
201
191
|
/**
|
|
202
192
|
* Map each source item to a new type.
|
|
203
|
-
*
|
|
204
193
|
* @param callback - A mapping function that takes a source item and returns
|
|
205
194
|
* corresponding mapped item.
|
|
206
195
|
* @typeParam TI - Target item type.
|
|
@@ -213,7 +202,6 @@ class DataPipeUnderConstruction {
|
|
|
213
202
|
}
|
|
214
203
|
/**
|
|
215
204
|
* Map each source item to zero or more items of a new type.
|
|
216
|
-
*
|
|
217
205
|
* @param callback - A mapping function that takes a source item and returns
|
|
218
206
|
* an array of corresponding mapped items.
|
|
219
207
|
* @typeParam TI - Target item type.
|
|
@@ -226,7 +214,6 @@ class DataPipeUnderConstruction {
|
|
|
226
214
|
}
|
|
227
215
|
/**
|
|
228
216
|
* Connect this pipe to given data set.
|
|
229
|
-
*
|
|
230
217
|
* @param target - The data set that will receive the items from this pipe.
|
|
231
218
|
* @returns The pipe connected between given data sets and performing
|
|
232
219
|
* configured transformation on the processed items.
|
|
@@ -238,7 +225,6 @@ class DataPipeUnderConstruction {
|
|
|
238
225
|
|
|
239
226
|
/**
|
|
240
227
|
* Determine whether a value can be used as an id.
|
|
241
|
-
*
|
|
242
228
|
* @param value - Input value of unknown type.
|
|
243
229
|
* @returns True if the value is valid id, false otherwise.
|
|
244
230
|
*/
|
|
@@ -248,7 +234,6 @@ function isId(value) {
|
|
|
248
234
|
|
|
249
235
|
/**
|
|
250
236
|
* A queue.
|
|
251
|
-
*
|
|
252
237
|
* @typeParam T - The type of method names to be replaced by queued versions.
|
|
253
238
|
*/
|
|
254
239
|
class Queue {
|
|
@@ -261,7 +246,6 @@ class Queue {
|
|
|
261
246
|
_extended = null;
|
|
262
247
|
/**
|
|
263
248
|
* Construct a new Queue.
|
|
264
|
-
*
|
|
265
249
|
* @param options - Queue configuration.
|
|
266
250
|
*/
|
|
267
251
|
constructor(options) {
|
|
@@ -272,7 +256,6 @@ class Queue {
|
|
|
272
256
|
}
|
|
273
257
|
/**
|
|
274
258
|
* Update the configuration of the queue.
|
|
275
|
-
*
|
|
276
259
|
* @param options - Queue configuration.
|
|
277
260
|
*/
|
|
278
261
|
setOptions(options) {
|
|
@@ -287,7 +270,6 @@ class Queue {
|
|
|
287
270
|
/**
|
|
288
271
|
* Extend an object with queuing functionality.
|
|
289
272
|
* The object will be extended with a function flush, and the methods provided in options.replace will be replaced with queued ones.
|
|
290
|
-
*
|
|
291
273
|
* @param object - The object to be extended.
|
|
292
274
|
* @param options - Additional options.
|
|
293
275
|
* @returns The created queue.
|
|
@@ -348,7 +330,6 @@ class Queue {
|
|
|
348
330
|
}
|
|
349
331
|
/**
|
|
350
332
|
* Replace a method on an object with a queued version.
|
|
351
|
-
*
|
|
352
333
|
* @param object - Object having the method.
|
|
353
334
|
* @param method - The method name.
|
|
354
335
|
*/
|
|
@@ -370,7 +351,6 @@ class Queue {
|
|
|
370
351
|
}
|
|
371
352
|
/**
|
|
372
353
|
* Queue a call.
|
|
373
|
-
*
|
|
374
354
|
* @param entry - The function or entry to be queued.
|
|
375
355
|
*/
|
|
376
356
|
queue(entry) {
|
|
@@ -413,7 +393,6 @@ class Queue {
|
|
|
413
393
|
|
|
414
394
|
/**
|
|
415
395
|
* {@link DataSet} code that can be reused in {@link DataView} or other similar implementations of {@link DataInterface}.
|
|
416
|
-
*
|
|
417
396
|
* @typeParam Item - Item type that may or may not have an id.
|
|
418
397
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
419
398
|
*/
|
|
@@ -426,7 +405,6 @@ class DataSetPart {
|
|
|
426
405
|
};
|
|
427
406
|
/**
|
|
428
407
|
* Trigger an event
|
|
429
|
-
*
|
|
430
408
|
* @param event - Event name.
|
|
431
409
|
* @param payload - Event payload.
|
|
432
410
|
* @param senderId - Id of the sender.
|
|
@@ -441,7 +419,6 @@ class DataSetPart {
|
|
|
441
419
|
}
|
|
442
420
|
/**
|
|
443
421
|
* Subscribe to an event, add an event listener.
|
|
444
|
-
*
|
|
445
422
|
* @remarks Non-function callbacks are ignored.
|
|
446
423
|
* @param event - Event name.
|
|
447
424
|
* @param callback - Callback method.
|
|
@@ -454,7 +431,6 @@ class DataSetPart {
|
|
|
454
431
|
}
|
|
455
432
|
/**
|
|
456
433
|
* Unsubscribe from an event, remove an event listener.
|
|
457
|
-
*
|
|
458
434
|
* @remarks If the same callback was subscribed more than once **all** occurences will be removed.
|
|
459
435
|
* @param event - Event name.
|
|
460
436
|
* @param callback - Callback method.
|
|
@@ -474,7 +450,6 @@ class DataSetPart {
|
|
|
474
450
|
|
|
475
451
|
/**
|
|
476
452
|
* Data stream
|
|
477
|
-
*
|
|
478
453
|
* @remarks
|
|
479
454
|
* {@link DataStream} offers an always up to date stream of items from a {@link DataSet} or {@link DataView}.
|
|
480
455
|
* That means that the stream is evaluated at the time of iteration, conversion to another data type or when {@link cache} is called, not when the {@link DataStream} was created.
|
|
@@ -485,7 +460,6 @@ class DataStream {
|
|
|
485
460
|
_pairs;
|
|
486
461
|
/**
|
|
487
462
|
* Create a new data stream.
|
|
488
|
-
*
|
|
489
463
|
* @param pairs - The id, item pairs.
|
|
490
464
|
*/
|
|
491
465
|
constructor(pairs) {
|
|
@@ -525,7 +499,6 @@ class DataStream {
|
|
|
525
499
|
}
|
|
526
500
|
/**
|
|
527
501
|
* Return an array containing all the ids in this stream.
|
|
528
|
-
*
|
|
529
502
|
* @remarks
|
|
530
503
|
* The array may contain duplicities.
|
|
531
504
|
* @returns The array with all ids from this stream.
|
|
@@ -535,7 +508,6 @@ class DataStream {
|
|
|
535
508
|
}
|
|
536
509
|
/**
|
|
537
510
|
* Return an array containing all the items in this stream.
|
|
538
|
-
*
|
|
539
511
|
* @remarks
|
|
540
512
|
* The array may contain duplicities.
|
|
541
513
|
* @returns The array with all items from this stream.
|
|
@@ -545,7 +517,6 @@ class DataStream {
|
|
|
545
517
|
}
|
|
546
518
|
/**
|
|
547
519
|
* Return an array containing all the entries in this stream.
|
|
548
|
-
*
|
|
549
520
|
* @remarks
|
|
550
521
|
* The array may contain duplicities.
|
|
551
522
|
* @returns The array with all entries from this stream.
|
|
@@ -555,7 +526,6 @@ class DataStream {
|
|
|
555
526
|
}
|
|
556
527
|
/**
|
|
557
528
|
* Return an object map containing all the items in this stream accessible by ids.
|
|
558
|
-
*
|
|
559
529
|
* @remarks
|
|
560
530
|
* In case of duplicate ids (coerced to string so `7 == '7'`) the last encoutered appears in the returned object.
|
|
561
531
|
* @returns The object map of all id → item pairs from this stream.
|
|
@@ -569,7 +539,6 @@ class DataStream {
|
|
|
569
539
|
}
|
|
570
540
|
/**
|
|
571
541
|
* Return a map containing all the items in this stream accessible by ids.
|
|
572
|
-
*
|
|
573
542
|
* @returns The map of all id → item pairs from this stream.
|
|
574
543
|
*/
|
|
575
544
|
toMap() {
|
|
@@ -577,7 +546,6 @@ class DataStream {
|
|
|
577
546
|
}
|
|
578
547
|
/**
|
|
579
548
|
* Return a set containing all the (unique) ids in this stream.
|
|
580
|
-
*
|
|
581
549
|
* @returns The set of all ids from this stream.
|
|
582
550
|
*/
|
|
583
551
|
toIdSet() {
|
|
@@ -585,7 +553,6 @@ class DataStream {
|
|
|
585
553
|
}
|
|
586
554
|
/**
|
|
587
555
|
* Return a set containing all the (unique) items in this stream.
|
|
588
|
-
*
|
|
589
556
|
* @returns The set of all items from this stream.
|
|
590
557
|
*/
|
|
591
558
|
toItemSet() {
|
|
@@ -593,7 +560,6 @@ class DataStream {
|
|
|
593
560
|
}
|
|
594
561
|
/**
|
|
595
562
|
* Cache the items from this stream.
|
|
596
|
-
*
|
|
597
563
|
* @remarks
|
|
598
564
|
* This method allows for items to be fetched immediatelly and used (possibly multiple times) later.
|
|
599
565
|
* It can also be used to optimize performance as {@link DataStream} would otherwise reevaluate everything upon each iteration.
|
|
@@ -618,7 +584,6 @@ class DataStream {
|
|
|
618
584
|
}
|
|
619
585
|
/**
|
|
620
586
|
* Get the distinct values of given property.
|
|
621
|
-
*
|
|
622
587
|
* @param callback - The function that picks and possibly converts the property.
|
|
623
588
|
* @typeParam T - The type of the distinct value.
|
|
624
589
|
* @returns A set of all distinct properties.
|
|
@@ -632,7 +597,6 @@ class DataStream {
|
|
|
632
597
|
}
|
|
633
598
|
/**
|
|
634
599
|
* Filter the items of the stream.
|
|
635
|
-
*
|
|
636
600
|
* @param callback - The function that decides whether an item will be included.
|
|
637
601
|
* @returns A new data stream with the filtered items.
|
|
638
602
|
*/
|
|
@@ -650,7 +614,6 @@ class DataStream {
|
|
|
650
614
|
}
|
|
651
615
|
/**
|
|
652
616
|
* Execute a callback for each item of the stream.
|
|
653
|
-
*
|
|
654
617
|
* @param callback - The function that will be invoked for each item.
|
|
655
618
|
*/
|
|
656
619
|
forEach(callback) {
|
|
@@ -660,7 +623,6 @@ class DataStream {
|
|
|
660
623
|
}
|
|
661
624
|
/**
|
|
662
625
|
* Map the items into a different type.
|
|
663
|
-
*
|
|
664
626
|
* @param callback - The function that does the conversion.
|
|
665
627
|
* @typeParam Mapped - The type of the item after mapping.
|
|
666
628
|
* @returns A new data stream with the mapped items.
|
|
@@ -677,7 +639,6 @@ class DataStream {
|
|
|
677
639
|
}
|
|
678
640
|
/**
|
|
679
641
|
* Get the item with the maximum value of given property.
|
|
680
|
-
*
|
|
681
642
|
* @param callback - The function that picks and possibly converts the property.
|
|
682
643
|
* @returns The item with the maximum if found otherwise null.
|
|
683
644
|
*/
|
|
@@ -701,7 +662,6 @@ class DataStream {
|
|
|
701
662
|
}
|
|
702
663
|
/**
|
|
703
664
|
* Get the item with the minimum value of given property.
|
|
704
|
-
*
|
|
705
665
|
* @param callback - The function that picks and possibly converts the property.
|
|
706
666
|
* @returns The item with the minimum if found otherwise null.
|
|
707
667
|
*/
|
|
@@ -725,7 +685,6 @@ class DataStream {
|
|
|
725
685
|
}
|
|
726
686
|
/**
|
|
727
687
|
* Reduce the items into a single value.
|
|
728
|
-
*
|
|
729
688
|
* @param callback - The function that does the reduction.
|
|
730
689
|
* @param accumulator - The initial value of the accumulator.
|
|
731
690
|
* @typeParam T - The type of the accumulated value.
|
|
@@ -739,7 +698,6 @@ class DataStream {
|
|
|
739
698
|
}
|
|
740
699
|
/**
|
|
741
700
|
* Sort the items.
|
|
742
|
-
*
|
|
743
701
|
* @param callback - Item comparator.
|
|
744
702
|
* @returns A new stream with sorted items.
|
|
745
703
|
*/
|
|
@@ -753,7 +711,6 @@ class DataStream {
|
|
|
753
711
|
|
|
754
712
|
/**
|
|
755
713
|
* Add an id to given item if it doesn't have one already.
|
|
756
|
-
*
|
|
757
714
|
* @remarks
|
|
758
715
|
* The item will be modified.
|
|
759
716
|
* @param item - The item that will have an id after a call to this function.
|
|
@@ -791,15 +748,15 @@ function ensureFullItem(item, idProp) {
|
|
|
791
748
|
* // add items
|
|
792
749
|
* // note that the data items can contain different properties and data formats
|
|
793
750
|
* data.add([
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
751
|
+
* {id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
|
|
752
|
+
* {id: 2, text: 'item 2', date: '2013-06-23', group: 2},
|
|
753
|
+
* {id: 3, text: 'item 3', date: '2013-06-25', group: 2},
|
|
754
|
+
* {id: 4, text: 'item 4'}
|
|
798
755
|
* ]);
|
|
799
756
|
*
|
|
800
757
|
* // subscribe to any change in the DataSet
|
|
801
758
|
* data.on('*', function (event, properties, senderId) {
|
|
802
|
-
*
|
|
759
|
+
* console.log('event', event, properties);
|
|
803
760
|
* });
|
|
804
761
|
*
|
|
805
762
|
* // update an existing item
|
|
@@ -818,13 +775,12 @@ function ensureFullItem(item, idProp) {
|
|
|
818
775
|
*
|
|
819
776
|
* // retrieve a filtered subset of the data
|
|
820
777
|
* var items = data.get({
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
778
|
+
* filter: function (item) {
|
|
779
|
+
* return item.group == 1;
|
|
780
|
+
* }
|
|
824
781
|
* });
|
|
825
782
|
* console.log('filtered items', items);
|
|
826
783
|
* ```
|
|
827
|
-
*
|
|
828
784
|
* @typeParam Item - Item type that may or may not have an id.
|
|
829
785
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
830
786
|
*/
|
|
@@ -843,7 +799,6 @@ class DataSet extends DataSetPart {
|
|
|
843
799
|
_queue = null;
|
|
844
800
|
/**
|
|
845
801
|
* Construct a new DataSet.
|
|
846
|
-
*
|
|
847
802
|
* @param data - Initial data or options.
|
|
848
803
|
* @param options - Options (type error if data is also options).
|
|
849
804
|
*/
|
|
@@ -866,7 +821,6 @@ class DataSet extends DataSetPart {
|
|
|
866
821
|
}
|
|
867
822
|
/**
|
|
868
823
|
* Set new options.
|
|
869
|
-
*
|
|
870
824
|
* @param options - The new options.
|
|
871
825
|
*/
|
|
872
826
|
setOptions(options) {
|
|
@@ -904,14 +858,13 @@ class DataSet extends DataSetPart {
|
|
|
904
858
|
*
|
|
905
859
|
* // add items
|
|
906
860
|
* const ids = data.add([
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
861
|
+
* { id: 1, text: 'item 1' },
|
|
862
|
+
* { id: 2, text: 'item 2' },
|
|
863
|
+
* { text: 'item without an id' }
|
|
910
864
|
* ])
|
|
911
865
|
*
|
|
912
866
|
* console.log(ids) // [1, 2, '<UUIDv4>']
|
|
913
867
|
* ```
|
|
914
|
-
*
|
|
915
868
|
* @param data - Items to be added (ids will be generated if missing).
|
|
916
869
|
* @param senderId - Sender id.
|
|
917
870
|
* @returns addedIds - Array with the ids (generated if not present) of the added items.
|
|
@@ -946,7 +899,6 @@ class DataSet extends DataSetPart {
|
|
|
946
899
|
}
|
|
947
900
|
/**
|
|
948
901
|
* Update existing items. When an item does not exist, it will be created.
|
|
949
|
-
*
|
|
950
902
|
* @remarks
|
|
951
903
|
* The provided properties will be merged in the existing item. When an item does not exist, it will be created.
|
|
952
904
|
*
|
|
@@ -1037,7 +989,6 @@ class DataSet extends DataSetPart {
|
|
|
1037
989
|
}
|
|
1038
990
|
/**
|
|
1039
991
|
* Update existing items. When an item does not exist, an error will be thrown.
|
|
1040
|
-
*
|
|
1041
992
|
* @remarks
|
|
1042
993
|
* The provided properties will be deeply merged into the existing item.
|
|
1043
994
|
* When an item does not exist (id not present in the data set or absent), an error will be thrown and nothing will be changed.
|
|
@@ -1331,7 +1282,6 @@ class DataSet extends DataSetPart {
|
|
|
1331
1282
|
}
|
|
1332
1283
|
/**
|
|
1333
1284
|
* Filter the fields of an item.
|
|
1334
|
-
*
|
|
1335
1285
|
* @param item - The item whose fields should be filtered.
|
|
1336
1286
|
* @param fields - The names of the fields that will be kept.
|
|
1337
1287
|
* @typeParam K - Field name type.
|
|
@@ -1353,7 +1303,6 @@ class DataSet extends DataSetPart {
|
|
|
1353
1303
|
}
|
|
1354
1304
|
/**
|
|
1355
1305
|
* Sort the provided array with items.
|
|
1356
|
-
*
|
|
1357
1306
|
* @param items - Items to be sorted in place.
|
|
1358
1307
|
* @param order - A field name or custom sort function.
|
|
1359
1308
|
* @typeParam T - The type of the items in the items array.
|
|
@@ -1390,9 +1339,9 @@ class DataSet extends DataSetPart {
|
|
|
1390
1339
|
* ```javascript
|
|
1391
1340
|
* // create a DataSet
|
|
1392
1341
|
* const data = new vis.DataSet([
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1395
|
-
*
|
|
1342
|
+
* { id: 1, text: 'item 1' },
|
|
1343
|
+
* { id: 2, text: 'item 2' },
|
|
1344
|
+
* { id: 3, text: 'item 3' }
|
|
1396
1345
|
* ])
|
|
1397
1346
|
*
|
|
1398
1347
|
* // remove items
|
|
@@ -1400,7 +1349,6 @@ class DataSet extends DataSetPart {
|
|
|
1400
1349
|
*
|
|
1401
1350
|
* console.log(ids) // [2, 3]
|
|
1402
1351
|
* ```
|
|
1403
|
-
*
|
|
1404
1352
|
* @param id - One or more items or ids of items to be removed.
|
|
1405
1353
|
* @param senderId - Sender id.
|
|
1406
1354
|
* @returns The ids of the removed items.
|
|
@@ -1427,7 +1375,6 @@ class DataSet extends DataSetPart {
|
|
|
1427
1375
|
}
|
|
1428
1376
|
/**
|
|
1429
1377
|
* Remove an item by its id or reference.
|
|
1430
|
-
*
|
|
1431
1378
|
* @param id - Id of an item or the item itself.
|
|
1432
1379
|
* @returns The removed item if removed, null otherwise.
|
|
1433
1380
|
*/
|
|
@@ -1455,7 +1402,6 @@ class DataSet extends DataSetPart {
|
|
|
1455
1402
|
* Clear the entire data set.
|
|
1456
1403
|
*
|
|
1457
1404
|
* After the items are removed, the {@link DataSet} will trigger an event `remove` for all removed items. When a `senderId` is provided, this id will be passed with the triggered event to all subscribers.
|
|
1458
|
-
*
|
|
1459
1405
|
* @param senderId - Sender id.
|
|
1460
1406
|
* @returns removedIds - The ids of all removed items.
|
|
1461
1407
|
*/
|
|
@@ -1472,7 +1418,6 @@ class DataSet extends DataSetPart {
|
|
|
1472
1418
|
}
|
|
1473
1419
|
/**
|
|
1474
1420
|
* Find the item with maximum value of a specified field.
|
|
1475
|
-
*
|
|
1476
1421
|
* @param field - Name of the property that should be searched for max value.
|
|
1477
1422
|
* @returns Item containing max value, or null if no items.
|
|
1478
1423
|
*/
|
|
@@ -1491,7 +1436,6 @@ class DataSet extends DataSetPart {
|
|
|
1491
1436
|
}
|
|
1492
1437
|
/**
|
|
1493
1438
|
* Find the item with minimum value of a specified field.
|
|
1494
|
-
*
|
|
1495
1439
|
* @param field - Name of the property that should be searched for min value.
|
|
1496
1440
|
* @returns Item containing min value, or null if no items.
|
|
1497
1441
|
*/
|
|
@@ -1510,7 +1454,6 @@ class DataSet extends DataSetPart {
|
|
|
1510
1454
|
}
|
|
1511
1455
|
/**
|
|
1512
1456
|
* Find all distinct values of a specified field
|
|
1513
|
-
*
|
|
1514
1457
|
* @param prop - The property name whose distinct values should be returned.
|
|
1515
1458
|
* @returns Unordered array containing all distinct values. Items without specified property are ignored.
|
|
1516
1459
|
*/
|
|
@@ -1539,7 +1482,6 @@ class DataSet extends DataSetPart {
|
|
|
1539
1482
|
}
|
|
1540
1483
|
/**
|
|
1541
1484
|
* Add a single item. Will fail when an item with the same id already exists.
|
|
1542
|
-
*
|
|
1543
1485
|
* @param item - A new item to be added.
|
|
1544
1486
|
* @returns Added item's id. An id is generated when it is not present in the item.
|
|
1545
1487
|
*/
|
|
@@ -1558,7 +1500,6 @@ class DataSet extends DataSetPart {
|
|
|
1558
1500
|
/**
|
|
1559
1501
|
* Update a single item: merge with existing item.
|
|
1560
1502
|
* Will fail when the item has no id, or when there does not exist an item with the same id.
|
|
1561
|
-
*
|
|
1562
1503
|
* @param update - The new item
|
|
1563
1504
|
* @returns The id of the updated item.
|
|
1564
1505
|
*/
|
|
@@ -1610,25 +1551,25 @@ class DataSet extends DataSetPart {
|
|
|
1610
1551
|
* // create a DataSet
|
|
1611
1552
|
* var data = new vis.DataSet();
|
|
1612
1553
|
* data.add([
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
*
|
|
1554
|
+
* {id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
|
|
1555
|
+
* {id: 2, text: 'item 2', date: '2013-06-23', group: 2},
|
|
1556
|
+
* {id: 3, text: 'item 3', date: '2013-06-25', group: 2},
|
|
1557
|
+
* {id: 4, text: 'item 4'}
|
|
1617
1558
|
* ]);
|
|
1618
1559
|
*
|
|
1619
1560
|
* // create a DataView
|
|
1620
1561
|
* // the view will only contain items having a property group with value 1,
|
|
1621
1562
|
* // and will only output fields id, text, and date.
|
|
1622
1563
|
* var view = new vis.DataView(data, {
|
|
1623
|
-
*
|
|
1624
|
-
*
|
|
1625
|
-
*
|
|
1626
|
-
*
|
|
1564
|
+
* filter: function (item) {
|
|
1565
|
+
* return (item.group == 1);
|
|
1566
|
+
* },
|
|
1567
|
+
* fields: ['id', 'text', 'date']
|
|
1627
1568
|
* });
|
|
1628
1569
|
*
|
|
1629
1570
|
* // subscribe to any change in the DataView
|
|
1630
1571
|
* view.on('*', function (event, properties, senderId) {
|
|
1631
|
-
*
|
|
1572
|
+
* console.log('event', event, properties);
|
|
1632
1573
|
* });
|
|
1633
1574
|
*
|
|
1634
1575
|
* // update an item in the data set
|
|
@@ -1641,7 +1582,6 @@ class DataSet extends DataSetPart {
|
|
|
1641
1582
|
* // get all items in the view
|
|
1642
1583
|
* var items = view.get();
|
|
1643
1584
|
* ```
|
|
1644
|
-
*
|
|
1645
1585
|
* @typeParam Item - Item type that may or may not have an id.
|
|
1646
1586
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
1647
1587
|
*/
|
|
@@ -1658,7 +1598,6 @@ class DataView extends DataSetPart {
|
|
|
1658
1598
|
_options;
|
|
1659
1599
|
/**
|
|
1660
1600
|
* Create a DataView.
|
|
1661
|
-
*
|
|
1662
1601
|
* @param data - The instance containing data (directly or indirectly).
|
|
1663
1602
|
* @param options - Options to configure this data view.
|
|
1664
1603
|
*/
|
|
@@ -1672,7 +1611,6 @@ class DataView extends DataSetPart {
|
|
|
1672
1611
|
// and trigger changes accordingly
|
|
1673
1612
|
/**
|
|
1674
1613
|
* Set a data source for the view.
|
|
1675
|
-
*
|
|
1676
1614
|
* @param data - The instance containing data (directly or indirectly).
|
|
1677
1615
|
* @remarks
|
|
1678
1616
|
* Note that when the data view is bound to a data set it won't be garbage
|
|
@@ -1885,7 +1823,6 @@ class DataView extends DataSetPart {
|
|
|
1885
1823
|
}
|
|
1886
1824
|
/**
|
|
1887
1825
|
* Render the instance unusable prior to garbage collection.
|
|
1888
|
-
*
|
|
1889
1826
|
* @remarks
|
|
1890
1827
|
* The intention of this method is to help discover scenarios where the data
|
|
1891
1828
|
* view is being used when the programmer thinks it has been garbage collected
|
|
@@ -1911,7 +1848,6 @@ class DataView extends DataSetPart {
|
|
|
1911
1848
|
}
|
|
1912
1849
|
/**
|
|
1913
1850
|
* Event listener. Will propagate all events from the connected data set to the subscribers of the DataView, but will filter the items and only trigger when there are changes in the filtered data set.
|
|
1914
|
-
*
|
|
1915
1851
|
* @param event - The name of the event.
|
|
1916
1852
|
* @param params - Parameters of the event.
|
|
1917
1853
|
* @param senderId - Id supplied by the sender.
|
|
@@ -1992,7 +1928,6 @@ class DataView extends DataSetPart {
|
|
|
1992
1928
|
|
|
1993
1929
|
/**
|
|
1994
1930
|
* Check that given value is compatible with Vis Data Set interface.
|
|
1995
|
-
*
|
|
1996
1931
|
* @param idProp - The expected property to contain item id.
|
|
1997
1932
|
* @param v - The value to be tested.
|
|
1998
1933
|
* @returns True if all expected values and methods match, false otherwise.
|
|
@@ -2023,7 +1958,6 @@ function isDataSetLike(idProp, v) {
|
|
|
2023
1958
|
|
|
2024
1959
|
/**
|
|
2025
1960
|
* Check that given value is compatible with Vis Data View interface.
|
|
2026
|
-
*
|
|
2027
1961
|
* @param idProp - The expected property to contain item id.
|
|
2028
1962
|
* @param v - The value to be tested.
|
|
2029
1963
|
* @returns True if all expected values and methods match, false otherwise.
|