Skip to content

Commit 3477903

Browse files
committed
updates
1 parent 497de00 commit 3477903

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/components/Graph/graph-view-node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,10 @@ class GraphViewNode {
329329

330330
mapVectorToArray(v) {
331331
var arr = [];
332-
if (v.x) arr.push(v.x);
333-
if (v.y) arr.push(v.y);
334-
if (v.z) arr.push(v.z);
335-
if (v.w) arr.push(v.w);
332+
if (Number.isFinite(v.x)) arr.push(v.x);
333+
if (Number.isFinite(v.y)) arr.push(v.y);
334+
if (Number.isFinite(v.z)) arr.push(v.z);
335+
if (Number.isFinite(v.w)) arr.push(v.w);
336336
return arr;
337337
}
338338

src/components/Graph/index.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ var defaultConfig = {
2525
edgeHoverEffect: true,
2626
passiveUIEvents: false,
2727
readOnly: false,
28-
restrictTranslate: false
28+
restrictTranslate: false,
29+
incrementNodeNames: false
2930
};
3031

3132
class SelectedItem {
@@ -140,12 +141,12 @@ class Graph extends Element {
140141
...item,
141142
id: Number(`${Date.now()}${Math.floor(Math.random() * 10000)}`)
142143
};
144+
if (item.attributes) {
145+
node.attributes = { ...item.attributes };
146+
}
143147
delete node.action;
144148
delete node.text;
145149
delete node.onClick;
146-
if (node.name) {
147-
node.name = `${node.name} ${Object.keys(this._graphData.get('data.nodes')).length}`;
148-
}
149150
var nodeSchema = this._graphSchema.nodes[node.nodeType];
150151
if (nodeSchema.attributes && !node.attributes) {
151152
node.attributes = {};
@@ -157,6 +158,9 @@ class Graph extends Element {
157158
}
158159
});
159160
}
161+
if (this._config.incrementNodeNames && node.attributes.name) {
162+
node.attributes.name = `${node.attributes.name} ${Object.keys(this._graphData.get('data.nodes')).length}`;
163+
}
160164
let element = e.target;
161165
while (!element.classList.contains('pcui-contextmenu')) {
162166
element = element.parentElement;
@@ -355,6 +359,8 @@ class Graph extends Element {
355359
value.forEach((v, i) => {
356360
node.attributes[attributeKey][keyMap[i]] = v;
357361
});
362+
} else if (Object.keys(prevAttributeValue).includes('x') && Number.isFinite(value)) {
363+
node.attributes[attributeKey].x = value;
358364
} else {
359365
node.attributes[attributeKey] = value;
360366
}

0 commit comments

Comments
 (0)