From b640cba04da57e979f77f0e83a705bb85b146be4 Mon Sep 17 00:00:00 2001 From: Alex de Mulder Date: Thu, 18 Sep 2014 11:12:30 +0200 Subject: [PATCH] fixed typo in docs, fixed times in history, updated dataset update listener in Network --- HISTORY.md | 4 +--- dist/vis.js | 24 ++++++++++++------------ docs/dataset.html | 2 +- lib/network/Network.js | 10 ++++------ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f08e5374..773b8c69 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,7 +1,7 @@ # vis.js history http://visjs.org -## 2014-10-16, version 3.5.1 SNAPSHOT, not yet released +## 2014-09-16, version 3.5.1 SNAPSHOT, not yet released ### Network @@ -11,8 +11,6 @@ http://visjs.org - Added getPositions() method to get the position of all nodes. - Added getCenterCoordinates() method to get the x and y position in canvas space of the center of the view. -## not yet released, version 3.5.1 - ### DataSet - Event listeners of `update` now receive an extra property `data`, diff --git a/dist/vis.js b/dist/vis.js index 293d2ed8..9c84637c 100644 --- a/dist/vis.js +++ b/dist/vis.js @@ -5,7 +5,7 @@ * A dynamic, browser-based visualization library. * * @version 3.5.0 - * @date 2014-09-17 + * @date 2014-09-18 * * @license * Copyright (C) 2011-2014 Almende B.V, http://almende.com @@ -4527,10 +4527,11 @@ return /******/ (function(modules) { // webpackBootstrap * @return {Array} updatedIds The ids of the added or updated items */ DataSet.prototype.update = function (data, senderId) { - var addedIds = [], - updatedIds = [], - me = this, - fieldId = me._fieldId; + var addedIds = []; + var updatedIds = []; + var updatedData = []; + var me = this; + var fieldId = me._fieldId; var addOrUpdate = function (item) { var id = item[fieldId]; @@ -4538,6 +4539,7 @@ return /******/ (function(modules) { // webpackBootstrap // update item id = me._updateItem(item); updatedIds.push(id); + updatedData.push(item); } else { // add new item @@ -4577,7 +4579,7 @@ return /******/ (function(modules) { // webpackBootstrap this._trigger('add', {items: addedIds}, senderId); } if (updatedIds.length) { - this._trigger('update', {items: updatedIds}, senderId); + this._trigger('update', {items: updatedIds, data: updatedData}, senderId); } return addedIds.concat(updatedIds); @@ -21227,7 +21229,7 @@ return /******/ (function(modules) { // webpackBootstrap network.start(); }, 'update': function (event, params) { - network._updateNodes(params.items); + network._updateNodes(params.items, params.data); network.start(); }, 'remove': function (event, params) { @@ -22343,13 +22345,12 @@ return /******/ (function(modules) { // webpackBootstrap * @param {Number[] | String[]} ids * @private */ - Network.prototype._updateNodes = function(ids) { - var nodes = this.nodes, - nodesData = this.nodesData; + Network.prototype._updateNodes = function(ids,changedData) { + var nodes = this.nodes; for (var i = 0, len = ids.length; i < len; i++) { var id = ids[i]; var node = nodes[id]; - var data = nodesData.get(id); + var data = changedData[i]; if (node) { // update node node.setProperties(data, this.constants); @@ -22366,7 +22367,6 @@ return /******/ (function(modules) { // webpackBootstrap this._setupHierarchicalLayout(); } this._updateNodeIndexList(); - this._reconnectEdges(); this._updateValueRange(nodes); }; diff --git a/docs/dataset.html b/docs/dataset.html index 17d2ab13..1110bdbf 100644 --- a/docs/dataset.html +++ b/docs/dataset.html @@ -216,7 +216,7 @@ var data = new vis.DataSet([data] [, options]) Object | Array | DataTable Get a single item, multiple items, or all items from the DataSet. - Usage examples can be found in section Getting Data, and the available options are described in section Data Selection. If parameter data isprovided, items will be appended to this array or table, which is required in case of Google DataTable. + Usage examples can be found in section Getting Data, and the available options are described in section Data Selection. If parameter data is provided, items will be appended to this array or table, which is required in case of Google DataTable. diff --git a/lib/network/Network.js b/lib/network/Network.js index 3118a83b..75ed92a2 100644 --- a/lib/network/Network.js +++ b/lib/network/Network.js @@ -297,7 +297,7 @@ function Network (container, data, options) { network.start(); }, 'update': function (event, params) { - network._updateNodes(params.items); + network._updateNodes(params.items, params.data); network.start(); }, 'remove': function (event, params) { @@ -1413,13 +1413,12 @@ Network.prototype._addNodes = function(ids) { * @param {Number[] | String[]} ids * @private */ -Network.prototype._updateNodes = function(ids) { - var nodes = this.nodes, - nodesData = this.nodesData; +Network.prototype._updateNodes = function(ids,changedData) { + var nodes = this.nodes; for (var i = 0, len = ids.length; i < len; i++) { var id = ids[i]; var node = nodes[id]; - var data = nodesData.get(id); + var data = changedData[i]; if (node) { // update node node.setProperties(data, this.constants); @@ -1436,7 +1435,6 @@ Network.prototype._updateNodes = function(ids) { this._setupHierarchicalLayout(); } this._updateNodeIndexList(); - this._reconnectEdges(); this._updateValueRange(nodes); };