vis-data 7.1.1 → 7.1.4
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 +1 -28
- 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.map +1 -1
- package/declarations/data-set.d.ts +0 -16
- package/declarations/data-set.d.ts.map +1 -1
- package/declarations/data-stream.d.ts +0 -16
- 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 +0 -1
- package/declarations/data-view.d.ts.map +1 -1
- package/declarations/queue.d.ts +0 -1
- package/declarations/queue.d.ts.map +1 -1
- package/dist/esm.js +7716 -2996
- package/dist/esm.js.map +1 -1
- package/dist/umd.js +12503 -7782
- package/dist/umd.js.map +1 -1
- package/esnext/esm/vis-data.js +64 -101
- package/esnext/esm/vis-data.js.map +1 -1
- package/esnext/esm/vis-data.min.js +3 -3
- package/esnext/esm/vis-data.min.js.map +1 -1
- package/esnext/umd/vis-data.js +67 -106
- package/esnext/umd/vis-data.js.map +1 -1
- package/esnext/umd/vis-data.min.js +3 -3
- package/esnext/umd/vis-data.min.js.map +1 -1
- package/package.json +36 -33
- package/peer/esm/vis-data.js +7713 -2991
- package/peer/esm/vis-data.js.map +1 -1
- package/peer/esm/vis-data.min.js +8 -27
- package/peer/esm/vis-data.min.js.map +1 -1
- package/peer/umd/vis-data.js +12459 -7737
- package/peer/umd/vis-data.js.map +1 -1
- package/peer/umd/vis-data.min.js +9 -28
- package/peer/umd/vis-data.min.js.map +1 -1
- package/standalone/esm/vis-data.js +7713 -2991
- package/standalone/esm/vis-data.js.map +1 -1
- package/standalone/esm/vis-data.min.js +8 -27
- package/standalone/esm/vis-data.min.js.map +1 -1
- package/standalone/umd/vis-data.js +12459 -7737
- package/standalone/umd/vis-data.js.map +1 -1
- package/standalone/umd/vis-data.min.js +9 -28
- package/standalone/umd/vis-data.min.js.map +1 -1
package/esnext/umd/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.4
|
|
8
|
+
* @date 2022-03-15T15:23:59.245Z
|
|
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
|
|
@@ -28,12 +28,11 @@
|
|
|
28
28
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vis-util/esnext/umd/vis-util.js'), require('uuid')) :
|
|
29
29
|
typeof define === 'function' && define.amd ? define(['exports', 'vis-util/esnext/umd/vis-util.js', 'uuid'], factory) :
|
|
30
30
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vis = global.vis || {}, global.vis, global.uuidv4));
|
|
31
|
-
}(this, (function (exports, esnext, uuid) {
|
|
31
|
+
})(this, (function (exports, esnext, uuid) {
|
|
32
32
|
/**
|
|
33
33
|
* Create new data pipe.
|
|
34
34
|
*
|
|
35
35
|
* @param from - The source data set or data view.
|
|
36
|
-
*
|
|
37
36
|
* @remarks
|
|
38
37
|
* Example usage:
|
|
39
38
|
* ```typescript
|
|
@@ -60,7 +59,6 @@
|
|
|
60
59
|
*
|
|
61
60
|
* pipe.start();
|
|
62
61
|
* ```
|
|
63
|
-
*
|
|
64
62
|
* @returns A factory whose methods can be used to configure the pipe.
|
|
65
63
|
*/
|
|
66
64
|
function createNewDataPipeFrom(from) {
|
|
@@ -76,6 +74,17 @@
|
|
|
76
74
|
* @typeParam TP - Target item type's id property name.
|
|
77
75
|
*/
|
|
78
76
|
class SimpleDataPipe {
|
|
77
|
+
_source;
|
|
78
|
+
_transformers;
|
|
79
|
+
_target;
|
|
80
|
+
/**
|
|
81
|
+
* Bound listeners for use with `DataInterface['on' | 'off']`.
|
|
82
|
+
*/
|
|
83
|
+
_listeners = {
|
|
84
|
+
add: this._add.bind(this),
|
|
85
|
+
remove: this._remove.bind(this),
|
|
86
|
+
update: this._update.bind(this),
|
|
87
|
+
};
|
|
79
88
|
/**
|
|
80
89
|
* Create a new data pipe.
|
|
81
90
|
*
|
|
@@ -88,14 +97,6 @@
|
|
|
88
97
|
this._source = _source;
|
|
89
98
|
this._transformers = _transformers;
|
|
90
99
|
this._target = _target;
|
|
91
|
-
/**
|
|
92
|
-
* Bound listeners for use with `DataInterface['on' | 'off']`.
|
|
93
|
-
*/
|
|
94
|
-
this._listeners = {
|
|
95
|
-
add: this._add.bind(this),
|
|
96
|
-
remove: this._remove.bind(this),
|
|
97
|
-
update: this._update.bind(this),
|
|
98
|
-
};
|
|
99
100
|
}
|
|
100
101
|
/** @inheritDoc */
|
|
101
102
|
all() {
|
|
@@ -120,7 +121,6 @@
|
|
|
120
121
|
* Apply the transformers to the items.
|
|
121
122
|
*
|
|
122
123
|
* @param items - The items to be transformed.
|
|
123
|
-
*
|
|
124
124
|
* @returns The transformed items.
|
|
125
125
|
*/
|
|
126
126
|
_transformItems(items) {
|
|
@@ -173,6 +173,12 @@
|
|
|
173
173
|
* @typeParam TP - Target item type's id property name.
|
|
174
174
|
*/
|
|
175
175
|
class DataPipeUnderConstruction {
|
|
176
|
+
_source;
|
|
177
|
+
/**
|
|
178
|
+
* Array transformers used to transform items within the pipe. This is typed
|
|
179
|
+
* as any for the sake of simplicity.
|
|
180
|
+
*/
|
|
181
|
+
_transformers = [];
|
|
176
182
|
/**
|
|
177
183
|
* Create a new data pipe factory. This is an internal constructor that
|
|
178
184
|
* should never be called from outside of this file.
|
|
@@ -181,18 +187,12 @@
|
|
|
181
187
|
*/
|
|
182
188
|
constructor(_source) {
|
|
183
189
|
this._source = _source;
|
|
184
|
-
/**
|
|
185
|
-
* Array transformers used to transform items within the pipe. This is typed
|
|
186
|
-
* as any for the sake of simplicity.
|
|
187
|
-
*/
|
|
188
|
-
this._transformers = [];
|
|
189
190
|
}
|
|
190
191
|
/**
|
|
191
192
|
* Filter the items.
|
|
192
193
|
*
|
|
193
194
|
* @param callback - A filtering function that returns true if given item
|
|
194
195
|
* should be piped and false if not.
|
|
195
|
-
*
|
|
196
196
|
* @returns This factory for further configuration.
|
|
197
197
|
*/
|
|
198
198
|
filter(callback) {
|
|
@@ -204,10 +204,8 @@
|
|
|
204
204
|
*
|
|
205
205
|
* @param callback - A mapping function that takes a source item and returns
|
|
206
206
|
* corresponding mapped item.
|
|
207
|
-
*
|
|
208
207
|
* @typeParam TI - Target item type.
|
|
209
208
|
* @typeParam TP - Target item type's id property name.
|
|
210
|
-
*
|
|
211
209
|
* @returns This factory for further configuration.
|
|
212
210
|
*/
|
|
213
211
|
map(callback) {
|
|
@@ -219,10 +217,8 @@
|
|
|
219
217
|
*
|
|
220
218
|
* @param callback - A mapping function that takes a source item and returns
|
|
221
219
|
* an array of corresponding mapped items.
|
|
222
|
-
*
|
|
223
220
|
* @typeParam TI - Target item type.
|
|
224
221
|
* @typeParam TP - Target item type's id property name.
|
|
225
|
-
*
|
|
226
222
|
* @returns This factory for further configuration.
|
|
227
223
|
*/
|
|
228
224
|
flatMap(callback) {
|
|
@@ -233,7 +229,6 @@
|
|
|
233
229
|
* Connect this pipe to given data set.
|
|
234
230
|
*
|
|
235
231
|
* @param target - The data set that will receive the items from this pipe.
|
|
236
|
-
*
|
|
237
232
|
* @returns The pipe connected between given data sets and performing
|
|
238
233
|
* configured transformation on the processed items.
|
|
239
234
|
*/
|
|
@@ -246,7 +241,6 @@
|
|
|
246
241
|
* Determine whether a value can be used as an id.
|
|
247
242
|
*
|
|
248
243
|
* @param value - Input value of unknown type.
|
|
249
|
-
*
|
|
250
244
|
* @returns True if the value is valid id, false otherwise.
|
|
251
245
|
*/
|
|
252
246
|
function isId(value) {
|
|
@@ -259,15 +253,19 @@
|
|
|
259
253
|
* @typeParam T - The type of method names to be replaced by queued versions.
|
|
260
254
|
*/
|
|
261
255
|
class Queue {
|
|
256
|
+
/** Delay in milliseconds. If defined the queue will be periodically flushed. */
|
|
257
|
+
delay;
|
|
258
|
+
/** Maximum number of entries in the queue before it will be flushed. */
|
|
259
|
+
max;
|
|
260
|
+
_queue = [];
|
|
261
|
+
_timeout = null;
|
|
262
|
+
_extended = null;
|
|
262
263
|
/**
|
|
263
264
|
* Construct a new Queue.
|
|
264
265
|
*
|
|
265
266
|
* @param options - Queue configuration.
|
|
266
267
|
*/
|
|
267
268
|
constructor(options) {
|
|
268
|
-
this._queue = [];
|
|
269
|
-
this._timeout = null;
|
|
270
|
-
this._extended = null;
|
|
271
269
|
// options
|
|
272
270
|
this.delay = null;
|
|
273
271
|
this.max = Infinity;
|
|
@@ -293,7 +291,6 @@
|
|
|
293
291
|
*
|
|
294
292
|
* @param object - The object to be extended.
|
|
295
293
|
* @param options - Additional options.
|
|
296
|
-
*
|
|
297
294
|
* @returns The created queue.
|
|
298
295
|
*/
|
|
299
296
|
static extend(object, options) {
|
|
@@ -422,22 +419,12 @@
|
|
|
422
419
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
423
420
|
*/
|
|
424
421
|
class DataSetPart {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
};
|
|
432
|
-
/**
|
|
433
|
-
* @deprecated Use on instead (PS: DataView.subscribe === DataView.on).
|
|
434
|
-
*/
|
|
435
|
-
this.subscribe = DataSetPart.prototype.on;
|
|
436
|
-
/**
|
|
437
|
-
* @deprecated Use off instead (PS: DataView.unsubscribe === DataView.off).
|
|
438
|
-
*/
|
|
439
|
-
this.unsubscribe = DataSetPart.prototype.off;
|
|
440
|
-
}
|
|
422
|
+
_subscribers = {
|
|
423
|
+
"*": [],
|
|
424
|
+
add: [],
|
|
425
|
+
remove: [],
|
|
426
|
+
update: [],
|
|
427
|
+
};
|
|
441
428
|
/**
|
|
442
429
|
* Trigger an event
|
|
443
430
|
*
|
|
@@ -457,7 +444,6 @@
|
|
|
457
444
|
* Subscribe to an event, add an event listener.
|
|
458
445
|
*
|
|
459
446
|
* @remarks Non-function callbacks are ignored.
|
|
460
|
-
*
|
|
461
447
|
* @param event - Event name.
|
|
462
448
|
* @param callback - Callback method.
|
|
463
449
|
*/
|
|
@@ -471,13 +457,20 @@
|
|
|
471
457
|
* Unsubscribe from an event, remove an event listener.
|
|
472
458
|
*
|
|
473
459
|
* @remarks If the same callback was subscribed more than once **all** occurences will be removed.
|
|
474
|
-
*
|
|
475
460
|
* @param event - Event name.
|
|
476
461
|
* @param callback - Callback method.
|
|
477
462
|
*/
|
|
478
463
|
off(event, callback) {
|
|
479
464
|
this._subscribers[event] = this._subscribers[event].filter((subscriber) => subscriber !== callback);
|
|
480
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* @deprecated Use on instead (PS: DataView.subscribe === DataView.on).
|
|
468
|
+
*/
|
|
469
|
+
subscribe = DataSetPart.prototype.on;
|
|
470
|
+
/**
|
|
471
|
+
* @deprecated Use off instead (PS: DataView.unsubscribe === DataView.off).
|
|
472
|
+
*/
|
|
473
|
+
unsubscribe = DataSetPart.prototype.off;
|
|
481
474
|
}
|
|
482
475
|
|
|
483
476
|
/**
|
|
@@ -487,10 +480,10 @@
|
|
|
487
480
|
* [[DataStream]] offers an always up to date stream of items from a [[DataSet]] or [[DataView]].
|
|
488
481
|
* That means that the stream is evaluated at the time of iteration, conversion to another data type or when [[cache]] is called, not when the [[DataStream]] was created.
|
|
489
482
|
* Multiple invocations of for example [[toItemArray]] may yield different results (if the data source like for example [[DataSet]] gets modified).
|
|
490
|
-
*
|
|
491
483
|
* @typeParam Item - The item type this stream is going to work with.
|
|
492
484
|
*/
|
|
493
485
|
class DataStream {
|
|
486
|
+
_pairs;
|
|
494
487
|
/**
|
|
495
488
|
* Create a new data stream.
|
|
496
489
|
*
|
|
@@ -536,7 +529,6 @@
|
|
|
536
529
|
*
|
|
537
530
|
* @remarks
|
|
538
531
|
* The array may contain duplicities.
|
|
539
|
-
*
|
|
540
532
|
* @returns The array with all ids from this stream.
|
|
541
533
|
*/
|
|
542
534
|
toIdArray() {
|
|
@@ -547,7 +539,6 @@
|
|
|
547
539
|
*
|
|
548
540
|
* @remarks
|
|
549
541
|
* The array may contain duplicities.
|
|
550
|
-
*
|
|
551
542
|
* @returns The array with all items from this stream.
|
|
552
543
|
*/
|
|
553
544
|
toItemArray() {
|
|
@@ -558,7 +549,6 @@
|
|
|
558
549
|
*
|
|
559
550
|
* @remarks
|
|
560
551
|
* The array may contain duplicities.
|
|
561
|
-
*
|
|
562
552
|
* @returns The array with all entries from this stream.
|
|
563
553
|
*/
|
|
564
554
|
toEntryArray() {
|
|
@@ -569,7 +559,6 @@
|
|
|
569
559
|
*
|
|
570
560
|
* @remarks
|
|
571
561
|
* In case of duplicate ids (coerced to string so `7 == '7'`) the last encoutered appears in the returned object.
|
|
572
|
-
*
|
|
573
562
|
* @returns The object map of all id → item pairs from this stream.
|
|
574
563
|
*/
|
|
575
564
|
toObjectMap() {
|
|
@@ -623,7 +612,6 @@
|
|
|
623
612
|
* ds.clear()
|
|
624
613
|
* chachedStream // Still has all the items.
|
|
625
614
|
* ```
|
|
626
|
-
*
|
|
627
615
|
* @returns A new [[DataStream]] with cached items (detached from the original [[DataSet]]).
|
|
628
616
|
*/
|
|
629
617
|
cache() {
|
|
@@ -633,9 +621,7 @@
|
|
|
633
621
|
* Get the distinct values of given property.
|
|
634
622
|
*
|
|
635
623
|
* @param callback - The function that picks and possibly converts the property.
|
|
636
|
-
*
|
|
637
624
|
* @typeParam T - The type of the distinct value.
|
|
638
|
-
*
|
|
639
625
|
* @returns A set of all distinct properties.
|
|
640
626
|
*/
|
|
641
627
|
distinct(callback) {
|
|
@@ -649,7 +635,6 @@
|
|
|
649
635
|
* Filter the items of the stream.
|
|
650
636
|
*
|
|
651
637
|
* @param callback - The function that decides whether an item will be included.
|
|
652
|
-
*
|
|
653
638
|
* @returns A new data stream with the filtered items.
|
|
654
639
|
*/
|
|
655
640
|
filter(callback) {
|
|
@@ -678,9 +663,7 @@
|
|
|
678
663
|
* Map the items into a different type.
|
|
679
664
|
*
|
|
680
665
|
* @param callback - The function that does the conversion.
|
|
681
|
-
*
|
|
682
666
|
* @typeParam Mapped - The type of the item after mapping.
|
|
683
|
-
*
|
|
684
667
|
* @returns A new data stream with the mapped items.
|
|
685
668
|
*/
|
|
686
669
|
map(callback) {
|
|
@@ -697,7 +680,6 @@
|
|
|
697
680
|
* Get the item with the maximum value of given property.
|
|
698
681
|
*
|
|
699
682
|
* @param callback - The function that picks and possibly converts the property.
|
|
700
|
-
*
|
|
701
683
|
* @returns The item with the maximum if found otherwise null.
|
|
702
684
|
*/
|
|
703
685
|
max(callback) {
|
|
@@ -722,7 +704,6 @@
|
|
|
722
704
|
* Get the item with the minimum value of given property.
|
|
723
705
|
*
|
|
724
706
|
* @param callback - The function that picks and possibly converts the property.
|
|
725
|
-
*
|
|
726
707
|
* @returns The item with the minimum if found otherwise null.
|
|
727
708
|
*/
|
|
728
709
|
min(callback) {
|
|
@@ -748,9 +729,7 @@
|
|
|
748
729
|
*
|
|
749
730
|
* @param callback - The function that does the reduction.
|
|
750
731
|
* @param accumulator - The initial value of the accumulator.
|
|
751
|
-
*
|
|
752
732
|
* @typeParam T - The type of the accumulated value.
|
|
753
|
-
*
|
|
754
733
|
* @returns The reduced value.
|
|
755
734
|
*/
|
|
756
735
|
reduce(callback, accumulator) {
|
|
@@ -763,7 +742,6 @@
|
|
|
763
742
|
* Sort the items.
|
|
764
743
|
*
|
|
765
744
|
* @param callback - Item comparator.
|
|
766
|
-
*
|
|
767
745
|
* @returns A new stream with sorted items.
|
|
768
746
|
*/
|
|
769
747
|
sort(callback) {
|
|
@@ -779,13 +757,10 @@
|
|
|
779
757
|
*
|
|
780
758
|
* @remarks
|
|
781
759
|
* The item will be modified.
|
|
782
|
-
*
|
|
783
760
|
* @param item - The item that will have an id after a call to this function.
|
|
784
761
|
* @param idProp - The key of the id property.
|
|
785
|
-
*
|
|
786
762
|
* @typeParam Item - Item type that may or may not have an id.
|
|
787
763
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
788
|
-
*
|
|
789
764
|
* @returns true
|
|
790
765
|
*/
|
|
791
766
|
function ensureFullItem(item, idProp) {
|
|
@@ -855,6 +830,18 @@
|
|
|
855
830
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
856
831
|
*/
|
|
857
832
|
class DataSet extends DataSetPart {
|
|
833
|
+
/** Flush all queued calls. */
|
|
834
|
+
flush;
|
|
835
|
+
/** @inheritDoc */
|
|
836
|
+
length;
|
|
837
|
+
/** @inheritDoc */
|
|
838
|
+
get idProp() {
|
|
839
|
+
return this._idProp;
|
|
840
|
+
}
|
|
841
|
+
_options;
|
|
842
|
+
_data;
|
|
843
|
+
_idProp;
|
|
844
|
+
_queue = null;
|
|
858
845
|
/**
|
|
859
846
|
* Construct a new DataSet.
|
|
860
847
|
*
|
|
@@ -863,7 +850,6 @@
|
|
|
863
850
|
*/
|
|
864
851
|
constructor(data, options) {
|
|
865
852
|
super();
|
|
866
|
-
this._queue = null;
|
|
867
853
|
// correctly read optional arguments
|
|
868
854
|
if (data && !Array.isArray(data)) {
|
|
869
855
|
options = data;
|
|
@@ -879,10 +865,6 @@
|
|
|
879
865
|
}
|
|
880
866
|
this.setOptions(options);
|
|
881
867
|
}
|
|
882
|
-
/** @inheritDoc */
|
|
883
|
-
get idProp() {
|
|
884
|
-
return this._idProp;
|
|
885
|
-
}
|
|
886
868
|
/**
|
|
887
869
|
* Set new options.
|
|
888
870
|
*
|
|
@@ -933,9 +915,7 @@
|
|
|
933
915
|
*
|
|
934
916
|
* @param data - Items to be added (ids will be generated if missing).
|
|
935
917
|
* @param senderId - Sender id.
|
|
936
|
-
*
|
|
937
918
|
* @returns addedIds - Array with the ids (generated if not present) of the added items.
|
|
938
|
-
*
|
|
939
919
|
* @throws When an item with the same id as any of the added items already exists.
|
|
940
920
|
*/
|
|
941
921
|
add(data, senderId) {
|
|
@@ -994,12 +974,9 @@
|
|
|
994
974
|
*
|
|
995
975
|
* ## Warning for TypeScript users
|
|
996
976
|
* This method may introduce partial items into the data set. Use add or updateOnly instead for better type safety.
|
|
997
|
-
*
|
|
998
977
|
* @param data - Items to be updated (if the id is already present) or added (if the id is missing).
|
|
999
978
|
* @param senderId - Sender id.
|
|
1000
|
-
*
|
|
1001
979
|
* @returns updatedIds - The ids of the added (these may be newly generated if there was no id in the item from the data) or updated items.
|
|
1002
|
-
*
|
|
1003
980
|
* @throws When the supplied data is neither an item nor an array of items.
|
|
1004
981
|
*/
|
|
1005
982
|
update(data, senderId) {
|
|
@@ -1088,12 +1065,9 @@
|
|
|
1088
1065
|
*
|
|
1089
1066
|
* console.log(ids) // [2]
|
|
1090
1067
|
* ```
|
|
1091
|
-
*
|
|
1092
1068
|
* @param data - Updates (the id and optionally other props) to the items in this data set.
|
|
1093
1069
|
* @param senderId - Sender id.
|
|
1094
|
-
*
|
|
1095
1070
|
* @returns updatedIds - The ids of the updated items.
|
|
1096
|
-
*
|
|
1097
1071
|
* @throws When the supplied data is neither an item nor an array of items, when the ids are missing.
|
|
1098
1072
|
*/
|
|
1099
1073
|
updateOnly(data, senderId) {
|
|
@@ -1108,7 +1082,7 @@
|
|
|
1108
1082
|
}
|
|
1109
1083
|
return { oldData, update };
|
|
1110
1084
|
})
|
|
1111
|
-
.map(({ oldData, update }) => {
|
|
1085
|
+
.map(({ oldData, update, }) => {
|
|
1112
1086
|
const id = oldData[this._idProp];
|
|
1113
1087
|
const updatedData = esnext.pureDeepObjectAssign(oldData, update);
|
|
1114
1088
|
this._data.set(id, updatedData);
|
|
@@ -1361,9 +1335,7 @@
|
|
|
1361
1335
|
*
|
|
1362
1336
|
* @param item - The item whose fields should be filtered.
|
|
1363
1337
|
* @param fields - The names of the fields that will be kept.
|
|
1364
|
-
*
|
|
1365
1338
|
* @typeParam K - Field name type.
|
|
1366
|
-
*
|
|
1367
1339
|
* @returns The item without any additional fields.
|
|
1368
1340
|
*/
|
|
1369
1341
|
_filterFields(item, fields) {
|
|
@@ -1385,7 +1357,6 @@
|
|
|
1385
1357
|
*
|
|
1386
1358
|
* @param items - Items to be sorted in place.
|
|
1387
1359
|
* @param order - A field name or custom sort function.
|
|
1388
|
-
*
|
|
1389
1360
|
* @typeParam T - The type of the items in the items array.
|
|
1390
1361
|
*/
|
|
1391
1362
|
_sort(items, order) {
|
|
@@ -1433,7 +1404,6 @@
|
|
|
1433
1404
|
*
|
|
1434
1405
|
* @param id - One or more items or ids of items to be removed.
|
|
1435
1406
|
* @param senderId - Sender id.
|
|
1436
|
-
*
|
|
1437
1407
|
* @returns The ids of the removed items.
|
|
1438
1408
|
*/
|
|
1439
1409
|
remove(id, senderId) {
|
|
@@ -1460,7 +1430,6 @@
|
|
|
1460
1430
|
* Remove an item by its id or reference.
|
|
1461
1431
|
*
|
|
1462
1432
|
* @param id - Id of an item or the item itself.
|
|
1463
|
-
*
|
|
1464
1433
|
* @returns The removed item if removed, null otherwise.
|
|
1465
1434
|
*/
|
|
1466
1435
|
_remove(id) {
|
|
@@ -1489,7 +1458,6 @@
|
|
|
1489
1458
|
* After the items are removed, the [[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.
|
|
1490
1459
|
*
|
|
1491
1460
|
* @param senderId - Sender id.
|
|
1492
|
-
*
|
|
1493
1461
|
* @returns removedIds - The ids of all removed items.
|
|
1494
1462
|
*/
|
|
1495
1463
|
clear(senderId) {
|
|
@@ -1507,7 +1475,6 @@
|
|
|
1507
1475
|
* Find the item with maximum value of a specified field.
|
|
1508
1476
|
*
|
|
1509
1477
|
* @param field - Name of the property that should be searched for max value.
|
|
1510
|
-
*
|
|
1511
1478
|
* @returns Item containing max value, or null if no items.
|
|
1512
1479
|
*/
|
|
1513
1480
|
max(field) {
|
|
@@ -1527,7 +1494,6 @@
|
|
|
1527
1494
|
* Find the item with minimum value of a specified field.
|
|
1528
1495
|
*
|
|
1529
1496
|
* @param field - Name of the property that should be searched for min value.
|
|
1530
|
-
*
|
|
1531
1497
|
* @returns Item containing min value, or null if no items.
|
|
1532
1498
|
*/
|
|
1533
1499
|
min(field) {
|
|
@@ -1547,7 +1513,6 @@
|
|
|
1547
1513
|
* Find all distinct values of a specified field
|
|
1548
1514
|
*
|
|
1549
1515
|
* @param prop - The property name whose distinct values should be returned.
|
|
1550
|
-
*
|
|
1551
1516
|
* @returns Unordered array containing all distinct values. Items without specified property are ignored.
|
|
1552
1517
|
*/
|
|
1553
1518
|
distinct(prop) {
|
|
@@ -1577,7 +1542,6 @@
|
|
|
1577
1542
|
* Add a single item. Will fail when an item with the same id already exists.
|
|
1578
1543
|
*
|
|
1579
1544
|
* @param item - A new item to be added.
|
|
1580
|
-
*
|
|
1581
1545
|
* @returns Added item's id. An id is generated when it is not present in the item.
|
|
1582
1546
|
*/
|
|
1583
1547
|
_addItem(item) {
|
|
@@ -1597,7 +1561,6 @@
|
|
|
1597
1561
|
* Will fail when the item has no id, or when there does not exist an item with the same id.
|
|
1598
1562
|
*
|
|
1599
1563
|
* @param update - The new item
|
|
1600
|
-
*
|
|
1601
1564
|
* @returns The id of the updated item.
|
|
1602
1565
|
*/
|
|
1603
1566
|
_updateItem(update) {
|
|
@@ -1684,6 +1647,16 @@
|
|
|
1684
1647
|
* @typeParam IdProp - Name of the property that contains the id.
|
|
1685
1648
|
*/
|
|
1686
1649
|
class DataView extends DataSetPart {
|
|
1650
|
+
/** @inheritDoc */
|
|
1651
|
+
length = 0;
|
|
1652
|
+
/** @inheritDoc */
|
|
1653
|
+
get idProp() {
|
|
1654
|
+
return this.getDataSet().idProp;
|
|
1655
|
+
}
|
|
1656
|
+
_listener;
|
|
1657
|
+
_data; // constructor → setData
|
|
1658
|
+
_ids = new Set(); // ids of the items currently in memory (just contains a boolean true)
|
|
1659
|
+
_options;
|
|
1687
1660
|
/**
|
|
1688
1661
|
* Create a DataView.
|
|
1689
1662
|
*
|
|
@@ -1692,24 +1665,16 @@
|
|
|
1692
1665
|
*/
|
|
1693
1666
|
constructor(data, options) {
|
|
1694
1667
|
super();
|
|
1695
|
-
/** @inheritDoc */
|
|
1696
|
-
this.length = 0;
|
|
1697
|
-
this._ids = new Set(); // ids of the items currently in memory (just contains a boolean true)
|
|
1698
1668
|
this._options = options || {};
|
|
1699
1669
|
this._listener = this._onEvent.bind(this);
|
|
1700
1670
|
this.setData(data);
|
|
1701
1671
|
}
|
|
1702
|
-
/** @inheritDoc */
|
|
1703
|
-
get idProp() {
|
|
1704
|
-
return this.getDataSet().idProp;
|
|
1705
|
-
}
|
|
1706
1672
|
// TODO: implement a function .config() to dynamically update things like configured filter
|
|
1707
1673
|
// and trigger changes accordingly
|
|
1708
1674
|
/**
|
|
1709
1675
|
* Set a data source for the view.
|
|
1710
1676
|
*
|
|
1711
1677
|
* @param data - The instance containing data (directly or indirectly).
|
|
1712
|
-
*
|
|
1713
1678
|
* @remarks
|
|
1714
1679
|
* Note that when the data view is bound to a data set it won't be garbage
|
|
1715
1680
|
* collected unless the data set is too. Use `dataView.setData(null)` or
|
|
@@ -2031,7 +1996,6 @@
|
|
|
2031
1996
|
*
|
|
2032
1997
|
* @param idProp - The expected property to contain item id.
|
|
2033
1998
|
* @param v - The value to be tested.
|
|
2034
|
-
*
|
|
2035
1999
|
* @returns True if all expected values and methods match, false otherwise.
|
|
2036
2000
|
*/
|
|
2037
2001
|
function isDataSetLike(idProp, v) {
|
|
@@ -2063,7 +2027,6 @@
|
|
|
2063
2027
|
*
|
|
2064
2028
|
* @param idProp - The expected property to contain item id.
|
|
2065
2029
|
* @param v - The value to be tested.
|
|
2066
|
-
*
|
|
2067
2030
|
* @returns True if all expected values and methods match, false otherwise.
|
|
2068
2031
|
*/
|
|
2069
2032
|
function isDataViewLike(idProp, v) {
|
|
@@ -2084,9 +2047,7 @@
|
|
|
2084
2047
|
|
|
2085
2048
|
Object.defineProperty(exports, 'DELETE', {
|
|
2086
2049
|
enumerable: true,
|
|
2087
|
-
get: function () {
|
|
2088
|
-
return esnext.DELETE;
|
|
2089
|
-
}
|
|
2050
|
+
get: function () { return esnext.DELETE; }
|
|
2090
2051
|
});
|
|
2091
2052
|
exports.DataSet = DataSet;
|
|
2092
2053
|
exports.DataStream = DataStream;
|
|
@@ -2098,5 +2059,5 @@
|
|
|
2098
2059
|
|
|
2099
2060
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2100
2061
|
|
|
2101
|
-
}))
|
|
2062
|
+
}));
|
|
2102
2063
|
//# sourceMappingURL=vis-data.js.map
|