Browse Source

fixed typo in docs, fixed times in history, updated dataset update listener in Network

v3_develop
Alex de Mulder 10 years ago
parent
commit
b640cba04d
4 changed files with 18 additions and 22 deletions
  1. +1
    -3
      HISTORY.md
  2. +12
    -12
      dist/vis.js
  3. +1
    -1
      docs/dataset.html
  4. +4
    -6
      lib/network/Network.js

+ 1
- 3
HISTORY.md View File

@ -1,7 +1,7 @@
# vis.js history # vis.js history
http://visjs.org 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 ### Network
@ -11,8 +11,6 @@ http://visjs.org
- Added getPositions() method to get the position of all nodes. - 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. - 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 ### DataSet
- Event listeners of `update` now receive an extra property `data`, - Event listeners of `update` now receive an extra property `data`,

+ 12
- 12
dist/vis.js View File

@ -5,7 +5,7 @@
* A dynamic, browser-based visualization library. * A dynamic, browser-based visualization library.
* *
* @version 3.5.0 * @version 3.5.0
* @date 2014-09-17
* @date 2014-09-18
* *
* @license * @license
* Copyright (C) 2011-2014 Almende B.V, http://almende.com * 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 * @return {Array} updatedIds The ids of the added or updated items
*/ */
DataSet.prototype.update = function (data, senderId) { 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 addOrUpdate = function (item) {
var id = item[fieldId]; var id = item[fieldId];
@ -4538,6 +4539,7 @@ return /******/ (function(modules) { // webpackBootstrap
// update item // update item
id = me._updateItem(item); id = me._updateItem(item);
updatedIds.push(id); updatedIds.push(id);
updatedData.push(item);
} }
else { else {
// add new item // add new item
@ -4577,7 +4579,7 @@ return /******/ (function(modules) { // webpackBootstrap
this._trigger('add', {items: addedIds}, senderId); this._trigger('add', {items: addedIds}, senderId);
} }
if (updatedIds.length) { if (updatedIds.length) {
this._trigger('update', {items: updatedIds}, senderId);
this._trigger('update', {items: updatedIds, data: updatedData}, senderId);
} }
return addedIds.concat(updatedIds); return addedIds.concat(updatedIds);
@ -21227,7 +21229,7 @@ return /******/ (function(modules) { // webpackBootstrap
network.start(); network.start();
}, },
'update': function (event, params) { 'update': function (event, params) {
network._updateNodes(params.items);
network._updateNodes(params.items, params.data);
network.start(); network.start();
}, },
'remove': function (event, params) { 'remove': function (event, params) {
@ -22343,13 +22345,12 @@ return /******/ (function(modules) { // webpackBootstrap
* @param {Number[] | String[]} ids * @param {Number[] | String[]} ids
* @private * @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++) { for (var i = 0, len = ids.length; i < len; i++) {
var id = ids[i]; var id = ids[i];
var node = nodes[id]; var node = nodes[id];
var data = nodesData.get(id);
var data = changedData[i];
if (node) { if (node) {
// update node // update node
node.setProperties(data, this.constants); node.setProperties(data, this.constants);
@ -22366,7 +22367,6 @@ return /******/ (function(modules) { // webpackBootstrap
this._setupHierarchicalLayout(); this._setupHierarchicalLayout();
} }
this._updateNodeIndexList(); this._updateNodeIndexList();
this._reconnectEdges();
this._updateValueRange(nodes); this._updateValueRange(nodes);
}; };

+ 1
- 1
docs/dataset.html View File

@ -216,7 +216,7 @@ var data = new vis.DataSet([data] [, options])
<td>Object | Array | DataTable</td> <td>Object | Array | DataTable</td>
<td> <td>
Get a single item, multiple items, or all items from the DataSet. Get a single item, multiple items, or all items from the DataSet.
Usage examples can be found in section <a href="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <a href="#Data_Selection">Data Selection</a>. If parameter <code>data</code> 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 <a href="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <a href="#Data_Selection">Data Selection</a>. If parameter <code>data</code> is provided, items will be appended to this array or table, which is required in case of Google DataTable.
</td> </td>
</tr> </tr>

+ 4
- 6
lib/network/Network.js View File

@ -297,7 +297,7 @@ function Network (container, data, options) {
network.start(); network.start();
}, },
'update': function (event, params) { 'update': function (event, params) {
network._updateNodes(params.items);
network._updateNodes(params.items, params.data);
network.start(); network.start();
}, },
'remove': function (event, params) { 'remove': function (event, params) {
@ -1413,13 +1413,12 @@ Network.prototype._addNodes = function(ids) {
* @param {Number[] | String[]} ids * @param {Number[] | String[]} ids
* @private * @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++) { for (var i = 0, len = ids.length; i < len; i++) {
var id = ids[i]; var id = ids[i];
var node = nodes[id]; var node = nodes[id];
var data = nodesData.get(id);
var data = changedData[i];
if (node) { if (node) {
// update node // update node
node.setProperties(data, this.constants); node.setProperties(data, this.constants);
@ -1436,7 +1435,6 @@ Network.prototype._updateNodes = function(ids) {
this._setupHierarchicalLayout(); this._setupHierarchicalLayout();
} }
this._updateNodeIndexList(); this._updateNodeIndexList();
this._reconnectEdges();
this._updateValueRange(nodes); this._updateValueRange(nodes);
}; };

Loading…
Cancel
Save