Item type that may or may not have an id.
Name of the property that contains the id.
DataSet configuration.
An initial set of items for the new instance.
DataSet configuration.
Add a single item. Will fail when an item with the same id already exists.
Remove an item by its id or reference.
Sort the provided array with items.
Update a single item: merge with existing item. Will fail when the item has no id, or when there does not exist an item with the same id.
Flush all queued calls.
The number of items.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
The key of id property.
Add a data item or an array with items.
After the items are added to the DataSet, the DataSet will trigger an event add
. When a senderId
is provided, this id will be passed with the triggered event to all subscribers.
// create a DataSet
const data = new vis.DataSet()
// add items
const ids = data.add([
{ id: 1, text: 'item 1' },
{ id: 2, text: 'item 2' },
{ text: 'item without an id' }
])
console.log(ids) // [1, 2, '<UUIDv4>']
Items to be added (ids will be generated if missing).
Sender id.
addedIds - Array with the ids (generated if not present) of the added items.
Clear the entire data set.
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.
Sender id.
removedIds - The ids of all removed items.
Execute a callback function for each item.
Executed in similar fashion to Array.forEach callback, but instead of item, index, array receives item, id.
Options to specify iteration details.
Get all the items.
An array containing all the items.
Get all the items.
Additional options.
An array containing requested items.
Get all the items.
Additional options.
An object map of items (may be an empty object if there are no items).
Get all the items.
Additional options.
An array containing requested items or if requested an object map of items (may be an empty object if there are no items).
Get one item.
The id of the item.
The item or null if the id doesn't correspond to any item.
Get one item.
The id of the item.
Additional options.
The item or null if the id doesn't correspond to any item.
Get one item.
The id of the item.
Additional options.
An object map of items (may be an empty object if no item was found).
Get one item.
The id of the item.
Additional options.
The item if found or null otherwise. If requested an object map with 0 to 1 items.
Get multiple items.
An array of requested ids.
An array of found items (ids that do not correspond to any item are omitted).
Get multiple items.
An array of requested ids.
Additional options.
An array of found items (ids that do not correspond to any item are omitted).
Get multiple items.
An array of requested ids.
Additional options.
An object map of items (may be an empty object if no item was found).
Get multiple items.
An array of requested ids.
Additional options.
An array of found items (ids that do not correspond to any item are omitted). If requested an object map of items (may be an empty object if no item was found).
Get items.
Id or ids to be returned.
Options to specify iteration details.
The items (format is determined by ids (single or array) and the options.
Get the DataSet to which the instance implementing this interface is connected. In case there is a chain of multiple DataViews, the root DataSet of this chain is returned.
The data set that actually contains the data.
Get ids of items.
Additional configuration.
An array of requested ids.
Map each item into different item and return them as an array.
Array.map-like callback, but only with the first two params.
Options to specify iteration details.
The mapped items.
Find the item with maximum value of a specified field.
Name of the property that should be searched for max value.
Item containing max value, or null if no items.
Find the item with minimum value of a specified field.
Name of the property that should be searched for min value.
Item containing min value, or null if no items.
Remove a universal event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Remove an add
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Remove a remove
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Remove an update
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Add a universal event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Add an add
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Add a remove
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Add an update
event listener.
Event name.
Callback function.
The name of the event (EventName).
Data about the items affected by this event.
A senderId, optionally provided by the application code which triggered the event. If senderId is not provided, the argument will be null
.
Remove an item or multiple items by “reference” (only the id is used) or by id.
The method ignores removal of non-existing items, and returns an array containing the ids of the items which are actually removed from the DataSet.
After the items are removed, the DataSet will trigger an event remove
for the removed items. When a senderId
is provided, this id will be passed with the triggered event to all subscribers.
// create a DataSet
const data = new vis.DataSet([
{ id: 1, text: 'item 1' },
{ id: 2, text: 'item 2' },
{ id: 3, text: 'item 3' }
])
// remove items
const ids = data.remove([2, { id: 3 }, 4])
console.log(ids) // [2, 3]
One or more items or ids of items to be removed.
Sender id.
The ids of the removed items.
Set new options.
The new options.
Stream.
Ids of the items to be included in this stream (missing are ignored), all if omitted.
The data stream for this data set.
Update existing items. When an item does not exist, it will be created.
Items to be updated (if the id is already present) or added (if the id is missing).
Sender id.
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.
Update existing items. When an item does not exist, an error will be thrown.
Updates (the id and optionally other props) to the items in this data set.
Sender id.
updatedIds - The ids of the updated items.
Generated using TypeDoc
DataSet
Vis.js comes with a flexible DataSet, which can be used to hold and manipulate unstructured data and listen for changes in the data. The DataSet is key/value based. Data items can be added, updated and removed from the DataSet, and one can subscribe to changes in the DataSet. The data in the DataSet can be filtered and ordered. Data can be normalized when appending it to the DataSet as well.
Example
The following example shows how to use a DataSet.