Browse Source

Fixed support for DataSet with custom id fields (option `fieldId`). See #701.

v3_develop
jos 9 years ago
parent
commit
4c6d3310ca
2 changed files with 18 additions and 2 deletions
  1. +7
    -0
      HISTORY.md
  2. +11
    -2
      lib/network/Network.js

+ 7
- 0
HISTORY.md View File

@ -2,6 +2,13 @@
http://visjs.org http://visjs.org
## not yet released, version 3.11.1-SNAPSHOT
### Network
- Fixed support for DataSet with custom id fields (option `fieldId`).
## 2015-03-05, version 3.11.0 ## 2015-03-05, version 3.11.0
### Network ### Network

+ 11
- 2
lib/network/Network.js View File

@ -1657,9 +1657,14 @@ Network.prototype._setNodes = function(nodes) {
*/ */
Network.prototype._addNodes = function(ids) { Network.prototype._addNodes = function(ids) {
var id; var id;
var fieldId = this.nodesData._fieldId || null;
for (var i = 0, len = ids.length; i < len; i++) { for (var i = 0, len = ids.length; i < len; i++) {
id = ids[i]; id = ids[i];
var data = this.nodesData.get(id); var data = this.nodesData.get(id);
if (fieldId) {
data.id = data[fieldId];
}
var node = new Node(data, this.images, this.groups, this.constants); var node = new Node(data, this.images, this.groups, this.constants);
this.nodes[id] = node; // note: this may replace an existing node this.nodes[id] = node; // note: this may replace an existing node
if ((node.xFixed == false || node.yFixed == false) && (node.x === null || node.y === null)) { if ((node.xFixed == false || node.yFixed == false) && (node.x === null || node.y === null)) {
@ -1810,8 +1815,9 @@ Network.prototype._setEdges = function(edges) {
* @private * @private
*/ */
Network.prototype._addEdges = function (ids) { Network.prototype._addEdges = function (ids) {
var edges = this.edges,
edgesData = this.edgesData;
var edges = this.edges;
var edgesData = this.edgesData;
var fieldId = this.edgesData._fieldId;
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];
@ -1822,6 +1828,9 @@ Network.prototype._addEdges = function (ids) {
} }
var data = edgesData.get(id, {"showInternalIds" : true}); var data = edgesData.get(id, {"showInternalIds" : true});
if (fieldId) {
data.id = data[fieldId];
}
edges[id] = new Edge(data, this, this.constants); edges[id] = new Edge(data, this, this.constants);
} }
this.moving = true; this.moving = true;

Loading…
Cancel
Save